-
Notifications
You must be signed in to change notification settings - Fork 770
/
index.ts
51 lines (47 loc) · 1.75 KB
/
index.ts
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
import { isOutputTargetDocsReadme } from '@utils';
import type * as d from '../../../declarations';
import { generateReadme } from './output-docs';
export const generateReadmeDocs = async (
config: d.ValidatedConfig,
compilerCtx: d.CompilerCtx,
docsData: d.JsonDocs,
outputTargets: d.OutputTarget[],
) => {
const readmeOutputTargets = outputTargets.filter(isOutputTargetDocsReadme);
if (readmeOutputTargets.length === 0) {
return;
}
const strictCheck = readmeOutputTargets.some((o) => o.strict);
if (strictCheck) {
strictCheckDocs(config, docsData);
}
await Promise.all(
docsData.components.map((cmpData) => {
return generateReadme(config, compilerCtx, readmeOutputTargets, cmpData, docsData.components);
}),
);
};
export const strictCheckDocs = (config: d.ValidatedConfig, docsData: d.JsonDocs) => {
docsData.components.forEach((component) => {
component.props.forEach((prop) => {
if (!prop.docs && prop.deprecation === undefined) {
config.logger.warn(`Property "${prop.name}" of "${component.tag}" is not documented. ${component.filePath}`);
}
});
component.methods.forEach((method) => {
if (!method.docs && method.deprecation === undefined) {
config.logger.warn(`Method "${method.name}" of "${component.tag}" is not documented. ${component.filePath}`);
}
});
component.events.forEach((ev) => {
if (!ev.docs && ev.deprecation === undefined) {
config.logger.warn(`Event "${ev.event}" of "${component.tag}" is not documented. ${component.filePath}`);
}
});
component.parts.forEach((ev) => {
if (ev.docs === '') {
config.logger.warn(`Part "${ev.name}" of "${component.tag}" is not documented. ${component.filePath}`);
}
});
});
};