|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 | 3 | import path from "node:path";
|
4 | 4 |
|
5 |
| -import { documentComponents, documentTestUtils } from "@cloudscape-design/documenter"; |
| 5 | +import { documentTestUtils, writeComponentsDocumentation } from "@cloudscape-design/documenter"; |
6 | 6 |
|
7 |
| -import { listPublicDirs, writeSourceFile } from "./utils.js"; |
| 7 | +import { writeSourceFile } from "./utils.js"; |
8 | 8 |
|
9 |
| -const publicDirs = listPublicDirs("src"); |
10 | 9 | const targetDir = "lib/components/internal/api-docs";
|
11 | 10 |
|
12 | 11 | componentDocs();
|
13 | 12 | testUtilDocs();
|
14 | 13 |
|
15 |
| -function validatePublicFiles(definitionFiles) { |
16 |
| - for (const publicDir of publicDirs) { |
17 |
| - if (!definitionFiles.includes(publicDir)) { |
18 |
| - throw new Error(`Directory src/${publicDir} does not have a corresponding API definition`); |
19 |
| - } |
20 |
| - } |
21 |
| -} |
22 |
| - |
23 | 14 | function componentDocs() {
|
24 |
| - const definitions = documentComponents({ |
| 15 | + writeComponentsDocumentation({ |
| 16 | + outDir: path.join(targetDir, "components"), |
25 | 17 | tsconfigPath: path.resolve("tsconfig.json"),
|
26 | 18 | publicFilesGlob: "src/*/index.tsx",
|
27 | 19 | });
|
28 |
| - const outDir = path.join(targetDir, "components"); |
29 |
| - for (const definition of definitions) { |
30 |
| - writeSourceFile( |
31 |
| - path.join(outDir, definition.dashCaseName + ".js"), |
32 |
| - `module.exports = ${JSON.stringify(definition, null, 2)};`, |
33 |
| - ); |
34 |
| - } |
35 |
| - const indexContent = `module.exports = { |
36 |
| - ${definitions.map((definition) => `${JSON.stringify(definition.dashCaseName)}:require('./${definition.dashCaseName}')`).join(",\n")} |
37 |
| - }`; |
38 |
| - writeSourceFile(path.join(outDir, "index.js"), indexContent); |
39 |
| - validatePublicFiles(definitions.map((def) => def.dashCaseName)); |
40 | 20 | }
|
41 | 21 |
|
42 | 22 | function testUtilDocs() {
|
|
0 commit comments