From 2e77ecb1718e56325ae6032e38846c41e2085d90 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 14 Jul 2025 15:39:11 -0400 Subject: [PATCH 1/4] feat(ui): generate docs --- .github/workflows/generate.yml | 84 +++++++++++++++++++++++++++++++ src/generators/man-page/index.mjs | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/generate.yml diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 00000000..c47a2940 --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,84 @@ +name: Generate Docs + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + generate: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - target: man-page + input: './node/doc/api/cli.md' + - target: addon-verify + input: './node/doc/api/addons.md' + - target: api-links + input: './node/lib/*.js' + - target: orama-db + input: './node/doc/api/*.md' + - target: json-simple + input: './node/doc/api/*.md' + - target: legacy-json + input: './node/doc/api/*.md' + - target: legacy-html + input: './node/doc/api/*.md' + - target: llms-txt + input: './node/doc/api/*.md' + fail-fast: false + + steps: + - name: Harden Runner + uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 + with: + egress-policy: audit + + - name: Git Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Git Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + repository: nodejs/node + path: node + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci --prod + + - name: Create output directory + run: mkdir -p out/${{ matrix.target }} + + - name: Generate ${{ matrix.target }} + run: | + node bin/cli.mjs generate \ + -t ${{ matrix.target }} \ + -i "${{ matrix.input }}" \ + -o "out/${{ matrix.target }}" \ + --index ./node/doc/api/index.md \ + --skip-lint + + - name: Upload ${{ matrix.target }} artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: ${{ matrix.target }}-${{ github.run_id }} + path: ${{ matrix.output }} diff --git a/src/generators/man-page/index.mjs b/src/generators/man-page/index.mjs index 2b6f1d87..80ebaa02 100644 --- a/src/generators/man-page/index.mjs +++ b/src/generators/man-page/index.mjs @@ -77,7 +77,7 @@ export default { .replace('__ENVIRONMENT__', output.env); if (options.output) { - await writeFile(options.output, filledTemplate); + await writeFile(join(options.output, 'node.1'), filledTemplate); } return filledTemplate; From 1bf02306b2cfdb1017d6f677966c5c99ddc01376 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 14 Jul 2025 15:45:08 -0400 Subject: [PATCH 2/4] fixup! --- .github/workflows/generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index c47a2940..ca35946e 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -63,7 +63,7 @@ jobs: cache: 'npm' - name: Install dependencies - run: npm ci --prod + run: npm ci - name: Create output directory run: mkdir -p out/${{ matrix.target }} From babb5966d7c4b7b3ac5cc0cdf8f9cbddc9504eaa Mon Sep 17 00:00:00 2001 From: avivkeller Date: Mon, 14 Jul 2025 15:47:10 -0400 Subject: [PATCH 3/4] fixup! --- .github/workflows/generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index ca35946e..fb549eb5 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -81,4 +81,4 @@ jobs: uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ matrix.target }}-${{ github.run_id }} - path: ${{ matrix.output }} + path: out/${{ matrix.target }} From e1857e6dc28a85d20cc93af685e94961fbee2cb8 Mon Sep 17 00:00:00 2001 From: avivkeller Date: Tue, 15 Jul 2025 15:13:17 -0400 Subject: [PATCH 4/4] fixup! --- src/generators/man-page/constants.mjs | 4 ++++ src/generators/man-page/index.mjs | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/generators/man-page/constants.mjs b/src/generators/man-page/constants.mjs index a4ae9458..d26b0895 100644 --- a/src/generators/man-page/constants.mjs +++ b/src/generators/man-page/constants.mjs @@ -5,6 +5,10 @@ // options are defined. export const DOC_SLUG_OPTIONS = 'options'; +// This is the filename of the manpage. +// The format is `.1` (Hence, `node.1`) +export const OUTPUT_FILENAME = 'node.1'; + // https://github.com/nodejs/node/blob/main/doc/api/cli.md#environment-variables-1 // This slug should reference the section where the available // environment variables are defined. diff --git a/src/generators/man-page/index.mjs b/src/generators/man-page/index.mjs index 80ebaa02..229e1126 100644 --- a/src/generators/man-page/index.mjs +++ b/src/generators/man-page/index.mjs @@ -3,7 +3,11 @@ import { writeFile, readFile } from 'node:fs/promises'; import { join } from 'node:path'; -import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from './constants.mjs'; +import { + DOC_SLUG_ENVIRONMENT, + DOC_SLUG_OPTIONS, + OUTPUT_FILENAME, +} from './constants.mjs'; import { convertOptionToMandoc, convertEnvVarToMandoc, @@ -77,7 +81,7 @@ export default { .replace('__ENVIRONMENT__', output.env); if (options.output) { - await writeFile(join(options.output, 'node.1'), filledTemplate); + await writeFile(join(options.output, OUTPUT_FILENAME), filledTemplate); } return filledTemplate;