diff --git a/src/constants.mjs b/src/constants.mjs index 43677d6..fa0bf85 100644 --- a/src/constants.mjs +++ b/src/constants.mjs @@ -102,6 +102,16 @@ export const DOC_TYPES_MAPPING_PRIMITIVES = { undefined: 'Undefined', }; +// https://github.com/nodejs/node/blob/main/doc/api/cli.md#options +// This slug should reference the section where the available +// options are defined. +export const DOC_SLUG_OPTIONS = 'options'; + +// 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. +export const DOC_SLUG_ENVIRONMENT = 'evironment-options-1'; + // This is a mapping for types within the Markdown content and their respective // JavaScript globals types within the MDN JavaScript docs // @see DOC_MDN_BASE_URL_JS_GLOBALS diff --git a/src/generators/man-page/index.mjs b/src/generators/man-page/index.mjs index 94de839..5a5ca47 100644 --- a/src/generators/man-page/index.mjs +++ b/src/generators/man-page/index.mjs @@ -8,6 +8,8 @@ import { convertEnvVarToMandoc, } from './utils/converter.mjs'; +import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from '../../constants.mjs'; + /** * This generator generates a man page version of the CLI.md file. * See https://man.openbsd.org/mdoc.7 for the formatting. @@ -29,13 +31,15 @@ export default { // Filter to only 'cli'. const components = input.filter(({ api }) => api === 'cli'); if (!components.length) { - throw new Error('CLI.md not found'); + throw new Error('Could not find any `cli` documentation.'); } // Find the appropriate headers - const optionsStart = components.findIndex(({ slug }) => slug === 'options'); + const optionsStart = components.findIndex( + ({ slug }) => slug === DOC_SLUG_OPTIONS + ); const environmentStart = components.findIndex( - ({ slug }) => slug === 'environment-variables-1' + ({ slug }) => slug === DOC_SLUG_ENVIRONMENT ); // The first header that is <3 in depth after environmentStart const environmentEnd = components.findIndex( diff --git a/src/generators/man-page/template.1 b/src/generators/man-page/template.1 index 4e82775..0edab3d 100644 --- a/src/generators/man-page/template.1 +++ b/src/generators/man-page/template.1 @@ -1,10 +1,9 @@ .\" -.\" This file is automatically generated by api-docs-tooling. -.\" Do not edit this file directly. Please make changes to CLI.md -.\" and then regenerate this file. +.\" This file was generated automatically by the api-docs-tooling tool. +.\" Please do not edit this file manually. Make any updates to cli.md +.\" and regenerate the file afterward. .\" -.\" For generation instructions using api-docs-tooling, see: -.\" https://github.com/nodejs/api-docs-tooling +.\" To regenerate this file, run `make doc/node.1`. .\" .\"====================================================================== .Dd $Mdocdate$ @@ -71,4 +70,4 @@ Documentation: . .Pp GitHub repository and issue tracker: -.Sy https://github.com/nodejs/node \ No newline at end of file +.Sy https://github.com/nodejs/node