@@ -937,8 +937,8 @@ Not all files are formatted:
937
937
Future <void > validateSdkDocs () async {
938
938
await docSdk ();
939
939
const expectedLibCount = 0 ;
940
- const expectedSubLibCounts = { 19 , 20 , 21 } ;
941
- const expectedTotalCounts = { 19 , 20 , 21 } ;
940
+ const expectedSubLibCount = 20 ;
941
+ const expectedTotalCount = 20 ;
942
942
var indexHtml = File (path.join (_sdkDocsDir.path, 'index.html' ));
943
943
if (! indexHtml.existsSync ()) {
944
944
throw StateError ("No 'index.html' found for the SDK docs" );
@@ -953,10 +953,11 @@ Future<void> validateSdkDocs() async {
953
953
}
954
954
print ("Found $foundLibCount 'dart:' entries in 'index.html'" );
955
955
956
- var foundSubLibCount =
957
- _findCount (indexContents, '<li class="section-subitem"><a href="dart-' );
958
- if (! expectedSubLibCounts.contains (foundSubLibCount)) {
959
- throw StateError ("Expected $expectedSubLibCounts 'dart:' entries in "
956
+ var libLinkPattern =
957
+ RegExp ('<li class="section-subitem"><a [^>]*href="dart-' );
958
+ var foundSubLibCount = _findCount (indexContents, libLinkPattern);
959
+ if (expectedSubLibCount != foundSubLibCount) {
960
+ throw StateError ("Expected $expectedSubLibCount 'dart:' entries in "
960
961
"'index.html' to be in categories, but found $foundSubLibCount " );
961
962
}
962
963
print ('$foundSubLibCount index.html dart: entries in categories found' );
@@ -965,11 +966,11 @@ Future<void> validateSdkDocs() async {
965
966
var libraries =
966
967
_sdkDocsDir.listSync ().where ((fs) => fs.path.contains ('dart-' ));
967
968
var libraryCount = libraries.length;
968
- if (! expectedTotalCounts. contains ( libraryCount) ) {
969
+ if (expectedTotalCount != libraryCount) {
969
970
var libraryNames =
970
971
libraries.map ((l) => "'${path .basename (l .path )}'" ).join (', ' );
971
972
throw StateError ('Unexpected docs generated for SDK libraries; expected '
972
- '$expectedTotalCounts directories, but $libraryCount directories were '
973
+ '$expectedTotalCount directories, but $libraryCount directories were '
973
974
'generated: $libraryNames ' );
974
975
}
975
976
print ("Found $libraryCount 'dart:' libraries" );
@@ -987,12 +988,12 @@ final Directory _sdkDocsDir =
987
988
Directory .systemTemp.createTempSync ('sdkdocs' ).absolute;
988
989
989
990
/// Returns the number of (perhaps overlapping) occurrences of [str] in [match] .
990
- int _findCount (String str, String match) {
991
+ int _findCount (String str, Pattern match) {
991
992
var count = 0 ;
992
993
var index = str.indexOf (match);
993
994
while (index != - 1 ) {
994
995
count++ ;
995
- index = str.indexOf (match, index + match.length );
996
+ index = str.indexOf (match, index + 1 );
996
997
}
997
998
return count;
998
999
}
0 commit comments