diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 00000000..fb549eb5 --- /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 + + - 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: out/${{ matrix.target }} 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 2b6f1d87..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(options.output, filledTemplate); + await writeFile(join(options.output, OUTPUT_FILENAME), filledTemplate); } return filledTemplate;