@@ -12,7 +12,7 @@ import { JsiiBuild } from './projenrc/jsii';
1212import { LargePrChecker } from './projenrc/large-pr-checker' ;
1313import { PrLabeler } from './projenrc/pr-labeler' ;
1414import { RecordPublishingTimestamp } from './projenrc/record-publishing-timestamp' ;
15- import { S3DocsPublishing } from './projenrc/s3-docs-publishing' ;
15+ import { DocType , S3DocsPublishing } from './projenrc/s3-docs-publishing' ;
1616
1717// 5.7 sometimes gives a weird error in `ts-jest` in `@aws-cdk/cli-lib-alpha`
1818// https://github.com/microsoft/TypeScript/issues/60159
@@ -880,6 +880,7 @@ const toolkitLib = configureProject(
880880 '[email protected] ' , // use this specific version because newer versions are much slower. This is a temporary arrangement we hope to remove soon anyway. 881881 'esbuild' ,
882882 'typedoc' ,
883+ '@microsoft/api-extractor' ,
883884 ] ,
884885 // Watch 2 directories at once
885886 releasableCommits : transitiveToolkitPackages ( '@aws-cdk/toolkit-lib' ) ,
@@ -914,11 +915,64 @@ const toolkitLib = configureProject(
914915 } ) ,
915916) ;
916917
918+ // TypeDoc documentation publishing
917919new S3DocsPublishing ( toolkitLib , {
918920 docsStream : 'toolkit-lib' ,
919921 artifactPath : 'docs.zip' ,
920922 bucketName : '${{ vars.DOCS_BUCKET_NAME }}' ,
921923 roleToAssume : '${{ vars.PUBLISH_TOOLKIT_LIB_DOCS_ROLE_ARN }}' ,
924+ docType : DocType . TYPEDOC ,
925+ } ) ;
926+
927+ // API Extractor documentation publishing
928+ new S3DocsPublishing ( toolkitLib , {
929+ docsStream : 'toolkit-lib' ,
930+ artifactPath : 'api-extractor-docs.zip' ,
931+ bucketName : '${{ vars.DOCS_BUCKET_NAME }}' ,
932+ roleToAssume : '${{ vars.PUBLISH_TOOLKIT_LIB_DOCS_ROLE_ARN }}' ,
933+ docType : DocType . API_EXTRACTOR ,
934+ } ) ;
935+
936+ // Add API Extractor configuration
937+ new pj . JsonFile ( toolkitLib , 'api-extractor.json' , {
938+ marker : false ,
939+ obj : {
940+ projectFolder : '.' ,
941+ mainEntryPointFilePath : '<projectFolder>/lib/index.d.ts' ,
942+ bundledPackages : [ ] ,
943+ apiReport : {
944+ enabled : false ,
945+ } ,
946+ docModel : {
947+ enabled : true ,
948+ apiJsonFilePath : './dist/<unscopedPackageName>.api.json' ,
949+ projectFolderUrl : 'https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib' ,
950+ } ,
951+ dtsRollup : {
952+ enabled : false ,
953+ } ,
954+ tsdocMetadata : {
955+ enabled : false ,
956+ } ,
957+ messages : {
958+ compilerMessageReporting : {
959+ default : {
960+ logLevel : 'warning' ,
961+ } ,
962+ } ,
963+ extractorMessageReporting : {
964+ default : {
965+ logLevel : 'warning' ,
966+ } ,
967+ } ,
968+ tsdocMessageReporting : {
969+ default : {
970+ logLevel : 'warning' ,
971+ } ,
972+ } ,
973+ } ,
974+ } ,
975+ committed : true ,
922976} ) ;
923977
924978// Eslint rules
@@ -990,12 +1044,35 @@ toolkitLib.gitignore.addPatterns(
9901044 '!test/_fixtures/**/cdk.out' ,
9911045) ;
9921046
993- // Add a command for the docs
1047+ // Add a command for the Typedoc docs
9941048const toolkitLibDocs = toolkitLib . addTask ( 'docs' , {
9951049 exec : 'typedoc lib/index.ts' ,
9961050 receiveArgs : true ,
9971051} ) ;
9981052
1053+ // Add commands for the API Extractor docs
1054+ const apiExtractorDocsTask = toolkitLib . addTask ( 'api-extractor-docs' , {
1055+ exec : [
1056+ // Run api-extractor to generate the API model
1057+ 'api-extractor run --diagnostics || true' ,
1058+ // Create a directory for the API model
1059+ 'mkdir -p dist/api-extractor-docs/cdk/api/toolkit-lib' ,
1060+ // Copy the API model to the directory (with error handling)
1061+ 'if [ -f dist/toolkit-lib.api.json ]; then cp dist/toolkit-lib.api.json dist/api-extractor-docs/cdk/api/toolkit-lib/; else echo "Warning: API JSON file not found"; fi' ,
1062+ // Add version file
1063+ '(cat dist/version.txt || echo "latest") > dist/api-extractor-docs/cdk/api/toolkit-lib/VERSION' ,
1064+ // Copy README.md if it exists
1065+ 'if [ -f README.md ]; then cp README.md dist/api-extractor-docs/cdk/api/toolkit-lib/; fi' ,
1066+ // Copy all files from docs directory if it exists
1067+ 'if [ -d docs ]; then mkdir -p dist/api-extractor-docs/cdk/api/toolkit-lib/docs && cp -r docs/* dist/api-extractor-docs/cdk/api/toolkit-lib/docs/; fi' ,
1068+ // Zip the API model and docs files
1069+ 'cd dist/api-extractor-docs && zip -r ../api-extractor-docs.zip cdk' ,
1070+ ] . join ( ' && ' ) ,
1071+ } ) ;
1072+
1073+ // Add the API Extractor docs task to the package task
1074+ toolkitLib . packageTask . spawn ( apiExtractorDocsTask ) ;
1075+
9991076// When packaging, output the docs into a specific nested directory
10001077// This is required because the zip file needs to have this structure when created
10011078toolkitLib . packageTask . spawn ( toolkitLibDocs , { args : [ '--out dist/docs/cdk/api/toolkit-lib' ] } ) ;
0 commit comments