@@ -12,6 +12,7 @@ import 'package:crypto/crypto.dart' as crypto;
12
12
import 'package:dartdoc/src/io_utils.dart' ;
13
13
import 'package:dartdoc/src/package_meta.dart' ;
14
14
import 'package:path/path.dart' as path;
15
+ import 'package:sass/sass.dart' as sass;
15
16
import 'package:yaml/yaml.dart' as yaml;
16
17
import 'package:yaml/yaml.dart' ;
17
18
@@ -177,7 +178,15 @@ Future<void> buildWeb({bool debug = false}) async {
177
178
]);
178
179
_delete (File ('lib/resources/docs.dart.js.deps' ));
179
180
180
- var compileSig = await _calcDartFilesSig (Directory ('web' ));
181
+ final compileResult = sass.compileToResult ('web/styles/styles.scss' );
182
+ if (compileResult.css.isNotEmpty) {
183
+ File ('lib/resources/styles.css' ).writeAsStringSync (compileResult.css);
184
+ } else {
185
+ throw StateError ('Compiled CSS was empty.' );
186
+ }
187
+
188
+ var compileSig =
189
+ await _calcFilesSig (Directory ('web' ), extensions: {'.dart' , '.scss' });
181
190
File (path.join ('web' , 'sig.txt' )).writeAsStringSync ('$compileSig \n ' );
182
191
}
183
192
@@ -189,14 +198,14 @@ void _delete(FileSystemEntity entity) {
189
198
}
190
199
}
191
200
192
- /// Yields all of the trimmed lines of all of the `.dart` files in [dir] .
193
- Stream <String > _dartFileLines (Directory dir) {
201
+ /// Yields all of the trimmed lines of all of the files in [dir] with
202
+ /// one of the specified [extensions] .
203
+ Stream <String > _fileLines (Directory dir, {required Set <String > extensions}) {
194
204
var files = dir
195
205
.listSync (recursive: true )
196
206
.whereType <File >()
197
- .where ((file) => file.path.endsWith ('.dart' ))
198
- .toList ()
199
- ..sort ((a, b) => compareAsciiLowerCase (a.path, b.path));
207
+ .where ((file) => extensions.contains (path.extension (file.path)))
208
+ .sorted ((a, b) => compareAsciiLowerCase (a.path, b.path));
200
209
201
210
return Stream .fromIterable ([
202
211
for (var file in files)
@@ -824,11 +833,12 @@ Rebuild them with "dart tool/task.dart build" and check the results in.
824
833
}
825
834
826
835
// Verify that the web frontend has been compiled.
827
- final currentCodeSig = await _calcDartFilesSig (Directory ('web' ));
836
+ final currentSig =
837
+ await _calcFilesSig (Directory ('web' ), extensions: {'.dart' , '.scss' });
828
838
final lastCompileSig =
829
839
File (path.join ('web' , 'sig.txt' )).readAsStringSync ().trim ();
830
- if (currentCodeSig != lastCompileSig) {
831
- print ('current files: $currentCodeSig ' );
840
+ if (currentSig != lastCompileSig) {
841
+ print ('current files: $currentSig ' );
832
842
print ('cached sig : $lastCompileSig ' );
833
843
throw StateError (
834
844
'The web frontend (web/docs.dart) needs to be recompiled; rebuild it '
@@ -985,8 +995,9 @@ int _findCount(String str, String match) {
985
995
return count;
986
996
}
987
997
988
- Future <String > _calcDartFilesSig (Directory dir) async {
989
- final digest = await _dartFileLines (dir)
998
+ Future <String > _calcFilesSig (Directory dir,
999
+ {required Set <String > extensions}) async {
1000
+ final digest = await _fileLines (dir, extensions: extensions)
990
1001
.transform (utf8.encoder)
991
1002
.transform (crypto.md5)
992
1003
.single;
0 commit comments