@@ -4,7 +4,7 @@ import path from "node:path";
44
55import { documentComponents , documentTestUtils } from "@cloudscape-design/documenter" ;
66
7- import { dashCase , listPublicDirs , writeSourceFile } from "./utils.js" ;
7+ import { listPublicDirs , writeSourceFile } from "./utils.js" ;
88
99const publicDirs = listPublicDirs ( "src" ) ;
1010const targetDir = "lib/components/internal/api-docs" ;
@@ -21,28 +21,24 @@ function validatePublicFiles(definitionFiles) {
2121}
2222
2323function componentDocs ( ) {
24- const definitions = documentComponents ( path . resolve ( "scripts/tsconfig.docs.json" ) , "src/*/index.tsx" ) ;
24+ const definitions = documentComponents ( {
25+ tsconfigPath : path . resolve ( "tsconfig.json" ) ,
26+ publicFilesGlob : "src/*/index.tsx" ,
27+ } ) ;
2528 const outDir = path . join ( targetDir , "components" ) ;
26- const fileNames = definitions
27- . filter ( ( definition ) => {
28- const fileName = dashCase ( definition . name ) ;
29- if ( ! publicDirs . includes ( fileName ) ) {
30- console . warn ( `Excluded "${ fileName } " from components definitions.` ) ;
31- return false ;
32- }
33- return true ;
34- } )
35- . map ( ( definition ) => {
36- const fileName = dashCase ( definition . name ) ;
37- writeSourceFile ( path . join ( outDir , fileName + ".js" ) , `module.exports = ${ JSON . stringify ( definition , null , 2 ) } ;` ) ;
38- return fileName ;
39- } ) ;
40- validatePublicFiles ( fileNames ) ;
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+ }
4135 const indexContent = `module.exports = {
42- ${ fileNames . map ( ( name ) => `${ JSON . stringify ( name ) } :require('./${ name } ')` ) . join ( ",\n" ) }
36+ ${ definitions . map ( ( definition ) => `${ JSON . stringify ( definition . dashCaseName ) } :require('./${ definition . dashCaseName } ')` ) . join ( ",\n" ) }
4337 }` ;
4438 writeSourceFile ( path . join ( outDir , "index.js" ) , indexContent ) ;
39+ validatePublicFiles ( definitions . map ( ( def ) => def . dashCaseName ) ) ;
4540}
41+
4642function testUtilDocs ( ) {
4743 const tsconfig = path . resolve ( "src/test-utils/tsconfig.json" ) ;
4844 [ "dom" , "selectors" ] . forEach ( ( testUtilType ) => {
0 commit comments