Skip to content

Commit 41ce248

Browse files
authored
feat(ci): generate docs (#351)
* feat(ui): generate docs * fixup! * fixup! * fixup!
1 parent 6fa7d1b commit 41ce248

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

.github/workflows/generate.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
generate:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
include:
23+
- target: man-page
24+
input: './node/doc/api/cli.md'
25+
- target: addon-verify
26+
input: './node/doc/api/addons.md'
27+
- target: api-links
28+
input: './node/lib/*.js'
29+
- target: orama-db
30+
input: './node/doc/api/*.md'
31+
- target: json-simple
32+
input: './node/doc/api/*.md'
33+
- target: legacy-json
34+
input: './node/doc/api/*.md'
35+
- target: legacy-html
36+
input: './node/doc/api/*.md'
37+
- target: llms-txt
38+
input: './node/doc/api/*.md'
39+
fail-fast: false
40+
41+
steps:
42+
- name: Harden Runner
43+
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
44+
with:
45+
egress-policy: audit
46+
47+
- name: Git Checkout
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with:
50+
persist-credentials: false
51+
52+
- name: Git Checkout
53+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
with:
55+
persist-credentials: false
56+
repository: nodejs/node
57+
path: node
58+
59+
- name: Setup Node.js
60+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
61+
with:
62+
node-version-file: '.nvmrc'
63+
cache: 'npm'
64+
65+
- name: Install dependencies
66+
run: npm ci
67+
68+
- name: Create output directory
69+
run: mkdir -p out/${{ matrix.target }}
70+
71+
- name: Generate ${{ matrix.target }}
72+
run: |
73+
node bin/cli.mjs generate \
74+
-t ${{ matrix.target }} \
75+
-i "${{ matrix.input }}" \
76+
-o "out/${{ matrix.target }}" \
77+
--index ./node/doc/api/index.md \
78+
--skip-lint
79+
80+
- name: Upload ${{ matrix.target }} artifacts
81+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
82+
with:
83+
name: ${{ matrix.target }}-${{ github.run_id }}
84+
path: out/${{ matrix.target }}

src/generators/man-page/constants.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
// options are defined.
66
export const DOC_SLUG_OPTIONS = 'options';
77

8+
// This is the filename of the manpage.
9+
// The format is `<command>.1` (Hence, `node.1`)
10+
export const OUTPUT_FILENAME = 'node.1';
11+
812
// https://github.com/nodejs/node/blob/main/doc/api/cli.md#environment-variables-1
913
// This slug should reference the section where the available
1014
// environment variables are defined.

src/generators/man-page/index.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import { writeFile, readFile } from 'node:fs/promises';
44
import { join } from 'node:path';
55

6-
import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from './constants.mjs';
6+
import {
7+
DOC_SLUG_ENVIRONMENT,
8+
DOC_SLUG_OPTIONS,
9+
OUTPUT_FILENAME,
10+
} from './constants.mjs';
711
import {
812
convertOptionToMandoc,
913
convertEnvVarToMandoc,
@@ -77,7 +81,7 @@ export default {
7781
.replace('__ENVIRONMENT__', output.env);
7882

7983
if (options.output) {
80-
await writeFile(options.output, filledTemplate);
84+
await writeFile(join(options.output, OUTPUT_FILENAME), filledTemplate);
8185
}
8286

8387
return filledTemplate;

0 commit comments

Comments
 (0)