@@ -937,8 +937,8 @@ Not all files are formatted:
937937Future <void > validateSdkDocs () async {
938938 await docSdk ();
939939 const expectedLibCount = 0 ;
940- const expectedSubLibCounts = { 19 , 20 , 21 } ;
941- const expectedTotalCounts = { 19 , 20 , 21 } ;
940+ const expectedSubLibCount = 20 ;
941+ const expectedTotalCount = 20 ;
942942 var indexHtml = File (path.join (_sdkDocsDir.path, 'index.html' ));
943943 if (! indexHtml.existsSync ()) {
944944 throw StateError ("No 'index.html' found for the SDK docs" );
@@ -953,10 +953,11 @@ Future<void> validateSdkDocs() async {
953953 }
954954 print ("Found $foundLibCount 'dart:' entries in 'index.html'" );
955955
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 "
960961 "'index.html' to be in categories, but found $foundSubLibCount " );
961962 }
962963 print ('$foundSubLibCount index.html dart: entries in categories found' );
@@ -965,11 +966,11 @@ Future<void> validateSdkDocs() async {
965966 var libraries =
966967 _sdkDocsDir.listSync ().where ((fs) => fs.path.contains ('dart-' ));
967968 var libraryCount = libraries.length;
968- if (! expectedTotalCounts. contains ( libraryCount) ) {
969+ if (expectedTotalCount != libraryCount) {
969970 var libraryNames =
970971 libraries.map ((l) => "'${path .basename (l .path )}'" ).join (', ' );
971972 throw StateError ('Unexpected docs generated for SDK libraries; expected '
972- '$expectedTotalCounts directories, but $libraryCount directories were '
973+ '$expectedTotalCount directories, but $libraryCount directories were '
973974 'generated: $libraryNames ' );
974975 }
975976 print ("Found $libraryCount 'dart:' libraries" );
@@ -987,12 +988,12 @@ final Directory _sdkDocsDir =
987988 Directory .systemTemp.createTempSync ('sdkdocs' ).absolute;
988989
989990/// 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) {
991992 var count = 0 ;
992993 var index = str.indexOf (match);
993994 while (index != - 1 ) {
994995 count++ ;
995- index = str.indexOf (match, index + match.length );
996+ index = str.indexOf (match, index + 1 );
996997 }
997998 return count;
998999}
0 commit comments