-
Notifications
You must be signed in to change notification settings - Fork 54
feat(docs): add documentation for doc-kit
#889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c5118db
139fcb4
cdb9458
1d783e3
09e884c
ec0d712
65c26db
9426ef2
82e80ef
0f9fb0f
a49ea50
c7d5a19
9e7655c
1f554c1
b714583
642a641
c0cb3d9
3f035e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: Documentation Site | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build docs site | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Harden Runner | ||
| uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Git Checkout | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build site | ||
| run: node --run docs:build | ||
|
|
||
| - name: Upload site artifact | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: docs-site | ||
| path: www/out | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Assembles `www/content/` — the input tree for the doc-kit documentation | ||
| // site — from three sources that live elsewhere in the repo: | ||
| // | ||
| // www/pages/*.md authored narrative pages, copied verbatim | ||
| // docs/*.md the existing reference docs | ||
| // src/generators/*/README.md per-generator config reference | ||
| // | ||
| // `www/content/` is a build artifact and is gitignored. Run this before | ||
| // invoking the `web` generator against it. | ||
|
|
||
| import { mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises'; | ||
| import { dirname, join } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const CONTENT = join(ROOT, 'www', 'content'); | ||
|
|
||
| /** | ||
| * Collects the `{ name, markdown }` pages to write into `www/content/`. | ||
| * | ||
| * @returns {Promise<Array<{ name: string, markdown: string }>>} | ||
| */ | ||
| const collectPages = async () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to use a glob for this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont have strong opinions either way, but knew that i
|
||
| const pages = []; | ||
|
|
||
| const pagesDir = join(ROOT, 'www', 'pages'); | ||
| for (const file of await readdir(pagesDir)) { | ||
| if (file.endsWith('.md')) { | ||
| pages.push({ | ||
| name: file, | ||
| markdown: await readFile(join(pagesDir, file), 'utf-8'), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const docsDir = join(ROOT, 'docs'); | ||
| for (const file of await readdir(docsDir)) { | ||
| if (file.endsWith('.md')) { | ||
| pages.push({ | ||
| name: file, | ||
| markdown: await readFile(join(docsDir, file), 'utf-8'), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| const generatorsDir = join(ROOT, 'src', 'generators'); | ||
| for (const generator of await readdir(generatorsDir, { | ||
| withFileTypes: true, | ||
| })) { | ||
| if (!generator.isDirectory()) { | ||
| continue; | ||
| } | ||
|
|
||
| const readme = join(generatorsDir, generator.name, 'README.md'); | ||
|
|
||
| try { | ||
| pages.push({ | ||
| name: `generator-${generator.name}.md`, | ||
| markdown: await readFile(readme, 'utf-8'), | ||
| }); | ||
| } catch (error) { | ||
| if (error.code !== 'ENOENT') { | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return pages; | ||
| }; | ||
|
|
||
| const pages = await collectPages(); | ||
|
|
||
| await rm(CONTENT, { recursive: true, force: true }); | ||
| await mkdir(CONTENT, { recursive: true }); | ||
|
|
||
| await Promise.all( | ||
| pages.map(({ name, markdown }) => writeFile(join(CONTENT, name), markdown)) | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent duplicate content filenamesMedium Severity
Reviewed by Cursor Bugbot for commit b714583. Configure here. |
||
|
|
||
| console.log(`Wrote ${pages.length} pages to www/content/`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uses console.log not loggerLow Severity The new content-assembly script logs build output with Triggered by learned rule: Use built-in logger instead of console methods Reviewed by Cursor Bugbot for commit 3f035e7. Configure here. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Build the doc-kit documentation site into `www/out/`. | ||
|
|
||
| node scripts/build-docs-content.mjs | ||
|
|
||
| node bin/cli.mjs generate \ | ||
| --config-file ./www/doc-kit.config.mjs \ | ||
| --log-level debug |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we deploy the docs on GH page ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont have strong opinions here other that continuing our current patterns.