Skip to content

Commit b126d64

Browse files
authored
Log all kind of statistics when generating docs (#3617)
1 parent 9ae368d commit b126d64

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

scripts/docs/buildDocsCommon.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const VALID_COMPONENTS_CATEGORIES = [
3131

3232
function buildDocs(apiFolders, componentsPreProcess) {
3333
let components = readComponentsFromApiFiles(apiFolders);
34+
35+
logStatistics(components);
36+
3437
components = componentsPreProcess?.(components) ?? components;
3538
resetDocsDir();
3639
processComponents(components);
@@ -134,6 +137,22 @@ function generateExtendsLink(extendsLink) {
134137
return extendsText;
135138
}
136139

140+
function logStatistics(components) {
141+
const groupedComponents = _.countBy(components, 'name');
142+
const duplicateComponents = Object.entries(groupedComponents)
143+
.filter(([_, count]) => count > 1)
144+
.map(([name, count]) => `${name} (${count} times)`);
145+
146+
if (duplicateComponents.length > 0) {
147+
console.log('Components with multiple occurrences:\n-', duplicateComponents.join('\n- '));
148+
}
149+
150+
const componentsWithoutSnippet = components.filter(c => !c.snippet).map(c => c.name);
151+
if (componentsWithoutSnippet.length > 0) {
152+
console.log('Components missing snippet:\n-', componentsWithoutSnippet.join('\n- '));
153+
}
154+
}
155+
137156
function buildOldDocs(component) {
138157
let content = '';
139158
content += `import UILivePreview from '@site/src/components/UILivePreview';\n\n`;
@@ -197,8 +216,6 @@ function buildOldDocs(component) {
197216
?.map(item => _.replace(item, new RegExp(/\$[1-9]/, 'g'), ''))
198217
.join('\n')
199218
.toString()}\`}/>\n\n`;
200-
} else {
201-
console.warn(`${component.name} does not have a snippet`);
202219
}
203220

204221
/* Props */

0 commit comments

Comments
 (0)