-
Notifications
You must be signed in to change notification settings - Fork 659
Expand file tree
/
Copy pathts-docs-status.mts
More file actions
117 lines (98 loc) · 3.3 KB
/
ts-docs-status.mts
File metadata and controls
117 lines (98 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import path from 'node:path'
import glob from 'fast-glob'
import {compareTSDocsForComponent} from '@primer/doc-gen'
const rootDir = path.resolve(import.meta.dirname, '..')
const componentDocsFiles = glob.sync(path.join(rootDir, 'packages/react/src/**/*.docs.json'))
const componentSummary: Array<{
name: string
brokenProps: string[]
passingProps: string[]
}> = []
for (const componentDocFile of componentDocsFiles) {
const {docs, propCompareResults, subComponents} = compareTSDocsForComponent(componentDocFile)
const passingProps: string[] = []
const brokenProps: string[] = []
for (const [propName, propResult] of Object.entries(propCompareResults)) {
if (
propResult.missingInDocs ||
propResult.missingInTS ||
propResult.mismatchedDefaultValue ||
propResult.mismatchedRequired ||
// Ignore for now since this is likely to cause some noise in the short-term
// propResult.mismatchedType ||
propResult.missingJSDoc
) {
brokenProps.push(propName)
} else {
passingProps.push(propName)
}
}
componentSummary.push({
name: docs.name,
passingProps,
brokenProps,
})
for (const subCompInfo of subComponents ?? []) {
const subPassingProps: string[] = []
const subBrokenProps: string[] = []
if (!subCompInfo) {
continue
}
for (const [propName, propResult] of Object.entries(subCompInfo?.propCompareResults ?? {})) {
if (
propResult.missingInDocs ||
propResult.missingInTS ||
propResult.mismatchedDefaultValue ||
propResult.mismatchedRequired ||
// Ignore for now since this is likely to cause some noise in the short-term
// propResult.mismatchedType ||
propResult.missingJSDoc
) {
subPassingProps.push(propName)
} else {
subBrokenProps.push(propName)
}
}
componentSummary.push({
name: subCompInfo.componentName,
passingProps: subPassingProps,
brokenProps: subBrokenProps,
})
}
}
const {passingPropsCount, totalPropsCount, passingCompsCount} = componentSummary.reduce(
(acc, comp) => {
acc.passingPropsCount += comp.passingProps.length
acc.totalPropsCount += comp.passingProps.length + comp.brokenProps.length
if (comp.brokenProps.length === 0) {
acc.passingCompsCount += 1
}
return acc
},
{passingPropsCount: 0, totalPropsCount: 0, passingCompsCount: 0},
)
// eslint-disable-next-line no-console
console.log(`
## Component Documentation Status
**Status by component count**
 * 100)})
**Status by prop count**
 * 100)})
<details>
<summary>Detailed Component Summary</summary>
| Component Name | Passing Props (Count) | Passing Props | Broken Props (Count) | Broken Props |
|----------------|-----------------------|---------------|----------------------|--------------|
${componentSummary
.map(
component =>
`| ${[
component.name,
component.passingProps.length,
component.passingProps.join(', '),
component.brokenProps.length,
component.brokenProps.join(', '),
].join(' | ')} |`,
)
.join('\n')}
</details>
`)