From dbac699299a2e221c2c336815f3122695721b638 Mon Sep 17 00:00:00 2001 From: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:24:33 -0400 Subject: [PATCH] chore: fixup `man-page` generator --- src/generators/man-page/index.mjs | 18 +++++++++++++++--- src/generators/man-page/template.1 | 14 +++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/generators/man-page/index.mjs b/src/generators/man-page/index.mjs index 94de839..24caf97 100644 --- a/src/generators/man-page/index.mjs +++ b/src/generators/man-page/index.mjs @@ -8,6 +8,16 @@ import { convertEnvVarToMandoc, } from './utils/converter.mjs'; +// https://github.com/nodejs/node/blob/main/doc/api/cli.md#options +// This slug should reference the section where the available +// options are defined. +const OPTIONS_SLUG = '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. +const ENVIRONMENT_SLUG = 'evironment-options-1'; + /** * This generator generates a man page version of the CLI.md file. * See https://man.openbsd.org/mdoc.7 for the formatting. @@ -29,13 +39,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 === OPTIONS_SLUG + ); const environmentStart = components.findIndex( - ({ slug }) => slug === 'environment-variables-1' + ({ slug }) => slug === ENVIRONMENT_SLUG ); // 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..55fea14 100644 --- a/src/generators/man-page/template.1 +++ b/src/generators/man-page/template.1 @@ -1,10 +1,14 @@ .\" -.\" 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, use the following command: +.\" +.\" npx https://github.com/nodejs/api-docs-tooling/tarball/main \ +.\" -t man-page \ +.\" -i doc/api/cli.md \ +.\" -t doc/node.1 .\" .\"====================================================================== .Dd $Mdocdate$