Skip to content

Commit a504264

Browse files
authored
chore: fixup man-page generator (#128)
1 parent 4dbfd05 commit a504264

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/constants.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ export const DOC_TYPES_MAPPING_PRIMITIVES = {
102102
undefined: 'Undefined',
103103
};
104104

105+
// https://github.com/nodejs/node/blob/main/doc/api/cli.md#options
106+
// This slug should reference the section where the available
107+
// options are defined.
108+
export const DOC_SLUG_OPTIONS = 'options';
109+
110+
// https://github.com/nodejs/node/blob/main/doc/api/cli.md#environment-variables-1
111+
// This slug should reference the section where the available
112+
// environment variables are defined.
113+
export const DOC_SLUG_ENVIRONMENT = 'evironment-options-1';
114+
105115
// This is a mapping for types within the Markdown content and their respective
106116
// JavaScript globals types within the MDN JavaScript docs
107117
// @see DOC_MDN_BASE_URL_JS_GLOBALS

src/generators/man-page/index.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
convertEnvVarToMandoc,
99
} from './utils/converter.mjs';
1010

11+
import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from '../../constants.mjs';
12+
1113
/**
1214
* This generator generates a man page version of the CLI.md file.
1315
* See https://man.openbsd.org/mdoc.7 for the formatting.
@@ -29,13 +31,15 @@ export default {
2931
// Filter to only 'cli'.
3032
const components = input.filter(({ api }) => api === 'cli');
3133
if (!components.length) {
32-
throw new Error('CLI.md not found');
34+
throw new Error('Could not find any `cli` documentation.');
3335
}
3436

3537
// Find the appropriate headers
36-
const optionsStart = components.findIndex(({ slug }) => slug === 'options');
38+
const optionsStart = components.findIndex(
39+
({ slug }) => slug === DOC_SLUG_OPTIONS
40+
);
3741
const environmentStart = components.findIndex(
38-
({ slug }) => slug === 'environment-variables-1'
42+
({ slug }) => slug === DOC_SLUG_ENVIRONMENT
3943
);
4044
// The first header that is <3 in depth after environmentStart
4145
const environmentEnd = components.findIndex(

src/generators/man-page/template.1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
.\"
2-
.\" This file is automatically generated by api-docs-tooling.
3-
.\" Do not edit this file directly. Please make changes to CLI.md
4-
.\" and then regenerate this file.
2+
.\" This file was generated automatically by the api-docs-tooling tool.
3+
.\" Please do not edit this file manually. Make any updates to cli.md
4+
.\" and regenerate the file afterward.
55
.\"
6-
.\" For generation instructions using api-docs-tooling, see:
7-
.\" https://github.com/nodejs/api-docs-tooling
6+
.\" To regenerate this file, run `make doc/node.1`.
87
.\"
98
.\"======================================================================
109
.Dd $Mdocdate$
@@ -71,4 +70,4 @@ Documentation:
7170
.
7271
.Pp
7372
GitHub repository and issue tracker:
74-
.Sy https://github.com/nodejs/node
73+
.Sy https://github.com/nodejs/node

0 commit comments

Comments
 (0)