Skip to content

Commit dc60fd6

Browse files
authored
Documentation generation (#10)
* Script to generate docs for local packages * Add Jekyll site * Add example jsdoc for construct * Use GFM for proper rendering * Add log for build process * Add doc footer content * Prefer lowercase title * Add website helper command * Cleanup script * Add link to earthdata-playbook * Mv earthdata-playbook link to footer, link to Github * Improve build tools * Update contribution guidelines * Small jekyll updates * Add docs on building documentation * Update README.md * Update docgen.js * Apply suggestions from code review * Update scripts/docgen.js
1 parent 13cb667 commit dc60fd6

File tree

17 files changed

+1791
-109
lines changed

17 files changed

+1791
-109
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
npm-debug.log
33
lerna-debug.log
4+
docs

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.2

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,56 @@
33
1. Create empty package: `npx lerna create @cdk-seed/<package-name>`
44
1. Prepare package: `npx jsii-config-p ./packages/<package-name>/package.json`
55

6+
All TypeScript tooling is managed by [`jsii`](https://github.com/aws/jsii) and generated by running `npm build`. There is no need to add or modify TypeScript build configuration (e.g. `tsconfig.json`).
7+
8+
## Documentation
9+
10+
To support others who want to use our distributed constructs, we want to ensure that each package distributed by CDK Seed is well documented.
11+
12+
### README
13+
14+
Each package should contain a `README.md` at its root. We use [Github Flavored Markdown](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) to render the content into HTML. The README should be formatted as follows:
15+
16+
```markdown
17+
# <!--Construct Name -->
18+
19+
<!-- A brief description of what the construct's purpose -->
20+
21+
## Use Cases
22+
23+
<!-- Some examples of when a user may want to utilize this construct -->
24+
25+
## Examples
26+
27+
<!-- Examples of how to use the construct -->
28+
29+
## Requirements
30+
31+
<!-- Expectations of user's VPC configuration, etc -->
32+
```
33+
34+
Code samples can be included alongside text within in markdown files as such:
35+
36+
<div class="code-example">
37+
38+
Below is an example of doing something with code!
39+
40+
</div>
41+
42+
```ts
43+
console.log("Look, I'm doing something!")
44+
```
45+
46+
For more UI components, see the [Just the Docs](https://pmarsceill.github.io/just-the-docs/docs/ui-components) documentation.
47+
48+
_NOTE: Just the Docs' examples utilize Kramdown to render its markdown, not Github Flavored Markdown. Being that we use Github Flavored Markdown, shorthand such as `{: .btn }` is not available. Any non-standard markdown should be written as HTML._
49+
50+
### JSDocs
51+
52+
Code documentation is generated automatically from the [JSDoc](https://jsdoc.app/) comment blocks provided within the TypeScript source code. At a minimum, every member of the `props` interface and the exported `Construct` should be annotated with JSDoc information.
53+
54+
_NOTE: At time of writing, it appears that only the `@deprecated` tag makes its way from the JSDoc annotations to the rendered markdown. As such, content from other tags (e.g. `@default`) should be duplicated within the textual messaging of the JSDoc description._
55+
656
## Additional Resources
757

858
- [jsii - Getting Started](https://github.com/aws/jsii#getting-started)

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ If you get an error that the version of node is not installed, run:
1818

1919
### Commands
2020

21+
#### `npm start`
22+
23+
Watch packages for updates to code and documentation, triggering builds of both on change.
24+
2125
#### `npm run bootstrap`
2226

2327
Install dependencies for each package.
@@ -41,3 +45,18 @@ Run tests for all packages.
4145
## Adding packages
4246

4347
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
48+
49+
## Generating documentation
50+
51+
The generation of our documentation website is a three part process:
52+
53+
1. `jsii` must be run within each package (this is done by running `npm run build` from the project base dir). This produces a `.jsii` in the root of each package.
54+
2. `scripts/docgen.js` should be run to gather each package's `.jsii` file and to export markdown documentation for each package into the `site/docs` directory.
55+
3. [Jekyll](https://jekyllrb.com/) should be run to generate HTML from the markdown documentation.
56+
57+
This process can be made easier by running two processes in separate terminals:
58+
59+
1. `npm start` which concurrently runs two operations:
60+
* trigger `jsii` builds on changes to packages' `README.md` or `lib/*.ts` files.
61+
* trigger `scripts/docgen.js` to run on changes to packages' `.jsii` files.
62+
2. `npm run website` which starts the Jekyll server. It is assumed that Jekyll has been previously installed on the system. See [Jekyll's documentation](https://jekyllrb.com/docs/installation/) for more information.

0 commit comments

Comments
 (0)