Skip to content

Commit

Permalink
chore: prepare projen docs for GitHub pages (projen#1566)
Browse files Browse the repository at this point in the history
Moving API.md to the docs directory so it can be rendered on GitHub pages.

Also deleted the empty `mutable-builds.md` (file contents were moved to `build.md` some eons ago)

Closes projen#1507

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
Chriscbr authored Jan 26, 2022
1 parent 89a6642 commit 7a91b88
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const project = new cdk.JsiiProject({

autoApproveUpgrades: true,
autoApproveOptions: { allowedUsernames: ["cdklabs-automation"] },

docgenFilePath: "docs/api/API.md",
});

// this script is what we use as the projen command in this project
Expand Down
25 changes: 25 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Documentation

* [AWS CDK Applications](awscdk-apps.md)
* [AWS CDK Construct Library](awscdk-construct.md)
* [AWS Cloud Projects](awscdk.md)
* [Build](build.md)
* [Bundling](bundling.md)
* [Components](components.md)
* [Dependencies](deps.md)
* [Escape hatches](escape-hatches.md)
* [Ejecting](eject.md)
* [GitLab](gitlab.md)
* [Java Projects](java.md)
* [Node.js Projects](node.md)
* [Programmatic API](programmatic-api.md)
* [Publishing Modules](publisher.md)
* [Python Projects](python.md)
* [Releases and Versioning](releases.md)
* [Subprojects](subproject.md)
* [Tasks](tasks.md)
* [TypeScript Projects](typescript.md)

## API Reference

* [TypeScript](api/API.md)
34 changes: 31 additions & 3 deletions API.md → docs/api/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Name|Description
[awscdk.LambdaRuntime](#projen-awscdk-lambdaruntime)|The runtime for the AWS Lambda function.
[build.BuildWorkflow](#projen-build-buildworkflow)|*No description*
[cdk.ConstructLibrary](#projen-cdk-constructlibrary)|A multi-language library for CDK constructs.
[cdk.JsiiDocgen](#projen-cdk-jsiidocgen)|Creates an API.md file based on the jsii manifest: - Adds a `docgen` script to package.json - Runs `jsii-docgen` after compilation - Enforces that API.md is checked in.
[cdk.JsiiDocgen](#projen-cdk-jsiidocgen)|Creates a markdown file based on the jsii manifest: - Adds a `docgen` script to package.json - Runs `jsii-docgen` after compilation - Enforces that markdown file is checked in.
[cdk.JsiiProject](#projen-cdk-jsiiproject)|Multi-language jsii library project.
[cdk8s.Cdk8sTypeScriptApp](#projen-cdk8s-cdk8stypescriptapp)|CDK8s app in TypeScript.
[cdk8s.ConstructLibraryCdk8s](#projen-cdk8s-constructlibrarycdk8s)|CDK8s construct library project.
Expand Down Expand Up @@ -188,6 +188,7 @@ Name|Description
[build.BuildWorkflowOptions](#projen-build-buildworkflowoptions)|*No description*
[cdk.Catalog](#projen-cdk-catalog)|*No description*
[cdk.ConstructLibraryOptions](#projen-cdk-constructlibraryoptions)|*No description*
[cdk.JsiiDocgenOptions](#projen-cdk-jsiidocgenoptions)|Options for `JsiiDocgen`.
[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)|*No description*
[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)|Go target configuration.
[cdk.JsiiJavaTarget](#projen-cdk-jsiijavatarget)|*No description*
Expand Down Expand Up @@ -3117,6 +3118,7 @@ new awscdk.AwsCdkConstructLibrary(options: AwsCdkConstructLibraryOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand Down Expand Up @@ -3898,6 +3900,7 @@ new awscdk.ConstructLibraryAws(options: AwsCdkConstructLibraryOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand Down Expand Up @@ -4323,6 +4326,7 @@ new cdk.ConstructLibrary(options: ConstructLibraryOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand All @@ -4338,7 +4342,7 @@ new cdk.ConstructLibrary(options: ConstructLibraryOptions)

## class JsiiDocgen 🔹 <a id="projen-cdk-jsiidocgen"></a>

Creates an API.md file based on the jsii manifest: - Adds a `docgen` script to package.json - Runs `jsii-docgen` after compilation - Enforces that API.md is checked in.
Creates a markdown file based on the jsii manifest: - Adds a `docgen` script to package.json - Runs `jsii-docgen` after compilation - Enforces that markdown file is checked in.

__Submodule__: cdk

Expand All @@ -4349,10 +4353,12 @@ __Submodule__: cdk


```ts
new cdk.JsiiDocgen(project: JsiiProject)
new cdk.JsiiDocgen(project: JsiiProject, options?: JsiiDocgenOptions)
```

* **project** (<code>[cdk.JsiiProject](#projen-cdk-jsiiproject)</code>) *No description*
* **options** (<code>[cdk.JsiiDocgenOptions](#projen-cdk-jsiidocgenoptions)</code>) *No description*
* **filePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"



Expand Down Expand Up @@ -4509,6 +4515,7 @@ new cdk.JsiiProject(options: JsiiProjectOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand Down Expand Up @@ -4857,6 +4864,7 @@ new cdk8s.ConstructLibraryCdk8s(options: ConstructLibraryCdk8sOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand Down Expand Up @@ -5040,6 +5048,7 @@ new cdktf.ConstructLibraryCdktf(options: ConstructLibraryCdktfOptions)
* **repositoryUrl** (<code>string</code>) Git repository URL.
* **compat** (<code>boolean</code>) Automatically run API compatibility test against the latest version published to npm after compilation. __*Default*__: false
* **compatIgnore** (<code>string</code>) Name of the ignore file for API compatibility tests. __*Default*__: ".compatignore"
* **docgenFilePath** (<code>string</code>) File path for generated docs. __*Default*__: "API.md"
* **dotnet** (<code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code>) *No description* __*Optional*__
* **excludeTypescript** (<code>Array<string></code>) Accepts a list of glob patterns. __*Optional*__
* **publishToGo** (<code>[cdk.JsiiGoTarget](#projen-cdk-jsiigotarget)</code>) Publish Go bindings to a git repository. __*Default*__: no publishing
Expand Down Expand Up @@ -11136,6 +11145,7 @@ Name | Type | Description
**devDeps**?🔹 | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?🔹 | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?🔹 | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?🔹 | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?🔹 | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down Expand Up @@ -11625,6 +11635,7 @@ Name | Type | Description
**devDeps**?⚠️ | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?⚠️ | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?⚠️ | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?⚠️ | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?⚠️ | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?⚠️ | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down Expand Up @@ -11914,6 +11925,7 @@ Name | Type | Description
**devDeps**?🔹 | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?🔹 | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?🔹 | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?🔹 | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?🔹 | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down Expand Up @@ -12018,6 +12030,19 @@ Name | Type | Description



## struct JsiiDocgenOptions 🔹 <a id="projen-cdk-jsiidocgenoptions"></a>


Options for `JsiiDocgen`.



Name | Type | Description
-----|------|-------------
**filePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"



## struct JsiiDotNetTarget 🔹 <a id="projen-cdk-jsiidotnettarget"></a>


Expand Down Expand Up @@ -12131,6 +12156,7 @@ Name | Type | Description
**devDeps**?🔹 | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?🔹 | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?🔹 | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?🔹 | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?🔹 | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down Expand Up @@ -12461,6 +12487,7 @@ Name | Type | Description
**devDeps**?🔹 | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?🔹 | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?🔹 | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?🔹 | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?🔹 | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down Expand Up @@ -12617,6 +12644,7 @@ Name | Type | Description
**devDeps**?🔹 | <code>Array<string></code> | Build dependencies for this module.<br/>__*Default*__: []
**disableTsconfig**?🔹 | <code>boolean</code> | Do not generate a `tsconfig.json` file (used by jsii projects since tsconfig.json is generated by the jsii compiler).<br/>__*Default*__: false
**docgen**?🔹 | <code>boolean</code> | Docgen by Typedoc.<br/>__*Default*__: false
**docgenFilePath**?🔹 | <code>string</code> | File path for generated docs.<br/>__*Default*__: "API.md"
**docsDirectory**?🔹 | <code>string</code> | Docs directory.<br/>__*Default*__: "docs"
**dotnet**?⚠️ | <code>[cdk.JsiiDotNetTarget](#projen-cdk-jsiidotnettarget)</code> | __*Optional*__
**entrypoint**?🔹 | <code>string</code> | Module entrypoint (`main` in `package.json`).<br/>__*Default*__: "lib/index.js"
Expand Down
Empty file removed docs/mutable-builds.md
Empty file.
23 changes: 18 additions & 5 deletions src/cdk/jsii-docgen.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import { JsiiProject } from "./jsii-project";

/**
* Creates an API.md file based on the jsii manifest:
* Options for `JsiiDocgen`
*/
export interface JsiiDocgenOptions {
/**
* File path for generated docs.
* @default "API.md"
*/
readonly filePath?: string;
}

/**
* Creates a markdown file based on the jsii manifest:
* - Adds a `docgen` script to package.json
* - Runs `jsii-docgen` after compilation
* - Enforces that API.md is checked in
* - Enforces that markdown file is checked in
*/
export class JsiiDocgen {
constructor(project: JsiiProject) {
constructor(project: JsiiProject, options: JsiiDocgenOptions = {}) {
project.addDevDeps("jsii-docgen");

const filePath = options.filePath ?? "API.md";

const docgen = project.addTask("docgen", {
description: "Generate API.md from .jsii manifest",
exec: "jsii-docgen",
exec: `jsii-docgen -o ${filePath}`,
});

// spawn docgen after compilation (requires the .jsii manifest).
project.postCompileTask.spawn(docgen);
project.gitignore.include("/API.md");
project.gitignore.include(`/${filePath}`);
}
}
8 changes: 7 additions & 1 deletion src/cdk/jsii-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export interface JsiiProjectOptions extends TypeScriptProjectOptions {
* that cannot be compiled with jsii's compiler settings.
*/
readonly excludeTypescript?: string[];

/**
* File path for generated docs.
* @default "API.md"
*/
readonly docgenFilePath?: string;
}

export enum Stability {
Expand Down Expand Up @@ -319,7 +325,7 @@ export class JsiiProject extends TypeScriptProject {
this.npmignore?.include(".jsii");

if (options.docgen ?? true) {
new JsiiDocgen(this);
new JsiiDocgen(this, { filePath: options.docgenFilePath });
}

// jsii updates .npmignore, so we make it writable
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/integ.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions test/__snapshots__/inventory.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7a91b88

Please sign in to comment.