Procházet zdrojové kódy

Improved a log that informs while building snippets.

Kamil Piechaczek před 5 roky
rodič
revize
9f242458b7
1 změnil soubory, kde provedl 18 přidání a 2 odebrání
  1. 18 2
      scripts/docs/snippetadapter.js

+ 18 - 2
scripts/docs/snippetadapter.js

@@ -85,7 +85,8 @@ module.exports = function snippetAdapter( snippets, options, umbertoHelpers ) {
 		filterWhitelistedSnippets( snippets, options.whitelistedSnippets );
 		filterWhitelistedSnippets( snippets, options.whitelistedSnippets );
 	}
 	}
 
 
-	console.log( `Building ${ snippets.size } snippets...` );
+	console.log( `Found ${ snippets.size } "{@snippet ...}" tags...` );
+	console.log( `Building ${ countUniqueSnippets( snippets ) } snippets...` );
 
 
 	const groupedSnippetsByLanguage = {};
 	const groupedSnippetsByLanguage = {};
 
 
@@ -209,7 +210,7 @@ module.exports = function snippetAdapter( snippets, options, umbertoHelpers ) {
 			}
 			}
 		} )
 		} )
 		.then( () => {
 		.then( () => {
-			console.log( `Finished building ${ snippets.size } snippets.` );
+			console.log( 'Finished building snippets.' );
 		} );
 		} );
 };
 };
 
 
@@ -451,6 +452,21 @@ function getHTMLImports( files, mapFunction ) {
 		.replace( /^\s+/, '' );
 		.replace( /^\s+/, '' );
 }
 }
 
 
+/**
+ * Returns a number of unique snippet names that will be built.
+ *
+ * @param {Set.<Snippet>} snippets Snippet collection extracted from documentation files.
+ * @returns {Number}
+ */
+function countUniqueSnippets( snippets ) {
+	const uniqueSnippetNames = new Set();
+
+	for ( const snippet of snippets ) {
+		uniqueSnippetNames.add( snippet.snippetName );
+	}
+	return uniqueSnippetNames.size;
+}
+
 /**
 /**
  * @typedef {Object} Snippet
  * @typedef {Object} Snippet
  *
  *