@optique/man 1.0.0-dev.896 → 1.0.0-dev.908
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +3 -3
- package/dist/cli.js +3 -3
- package/dist/{generator-Bal_ioLr.cjs → generator-BORgW1yS.cjs} +27 -2
- package/dist/{generator-CdDVvD4r.js → generator-Di1pIRAG.js} +27 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2 -2
- package/dist/{man-BBDifH_Y.js → man-CcjsLpyb.js} +12 -9
- package/dist/{man-xPX8GhXq.d.cts → man-D2t8hkyn.d.cts} +9 -1
- package/dist/{man-CGKLHWkS.d.ts → man-DXQgwt1g.d.ts} +9 -1
- package/dist/{man-DFKETOWN.cjs → man-NL-hVPdd.cjs} +12 -9
- package/dist/man.cjs +1 -1
- package/dist/man.d.cts +1 -1
- package/dist/man.d.ts +1 -1
- package/dist/man.js +1 -1
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_man = require('./man-
|
|
2
|
+
const require_man = require('./man-NL-hVPdd.cjs');
|
|
3
3
|
require('./roff-Cl0vekdg.cjs');
|
|
4
|
-
const require_generator = require('./generator-
|
|
4
|
+
const require_generator = require('./generator-BORgW1yS.cjs');
|
|
5
5
|
const __optique_core_constructs = require_man.__toESM(require("@optique/core/constructs"));
|
|
6
6
|
const __optique_core_primitives = require_man.__toESM(require("@optique/core/primitives"));
|
|
7
7
|
const __optique_core_valueparser = require_man.__toESM(require("@optique/core/valueparser"));
|
|
@@ -17,7 +17,7 @@ const node_url = require_man.__toESM(require("node:url"));
|
|
|
17
17
|
|
|
18
18
|
//#region deno.json
|
|
19
19
|
var name = "@optique/man";
|
|
20
|
-
var version = "1.0.0-dev.
|
|
20
|
+
var version = "1.0.0-dev.908+f60f037d";
|
|
21
21
|
var license = "MIT";
|
|
22
22
|
var exports$1 = {
|
|
23
23
|
".": "./src/index.ts",
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "./roff-CwBRpWCo.js";
|
|
3
|
-
import "./man-
|
|
4
|
-
import { generateManPageAsync } from "./generator-
|
|
3
|
+
import "./man-CcjsLpyb.js";
|
|
4
|
+
import { generateManPageAsync } from "./generator-Di1pIRAG.js";
|
|
5
5
|
import { object } from "@optique/core/constructs";
|
|
6
6
|
import { argument, option } from "@optique/core/primitives";
|
|
7
7
|
import { choice, string } from "@optique/core/valueparser";
|
|
@@ -17,7 +17,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
17
17
|
|
|
18
18
|
//#region deno.json
|
|
19
19
|
var name = "@optique/man";
|
|
20
|
-
var version = "1.0.0-dev.
|
|
20
|
+
var version = "1.0.0-dev.908+f60f037d";
|
|
21
21
|
var license = "MIT";
|
|
22
22
|
var exports = {
|
|
23
23
|
".": "./src/index.ts",
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
const require_man = require('./man-
|
|
1
|
+
const require_man = require('./man-NL-hVPdd.cjs');
|
|
2
2
|
const __optique_core_parser = require_man.__toESM(require("@optique/core/parser"));
|
|
3
3
|
|
|
4
4
|
//#region src/generator.ts
|
|
5
5
|
/**
|
|
6
|
+
* Checks if the given value looks like a {@link Parser} at runtime.
|
|
7
|
+
*/
|
|
8
|
+
function isParser(value) {
|
|
9
|
+
try {
|
|
10
|
+
if (value == null || typeof value !== "object") return false;
|
|
11
|
+
const p = value;
|
|
12
|
+
return "parse" in p && typeof p.parse === "function" && "complete" in p && typeof p.complete === "function" && "$mode" in p && (p.$mode === "sync" || p.$mode === "async") && "usage" in p && Array.isArray(p.usage) && "initialState" in p && "suggest" in p && typeof p.suggest === "function" && "getDocFragments" in p && typeof p.getDocFragments === "function";
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
6
18
|
* Checks if the given value is a {@link Program} object.
|
|
7
19
|
*/
|
|
8
20
|
function isProgram(value) {
|
|
9
|
-
|
|
21
|
+
try {
|
|
22
|
+
return typeof value === "object" && value !== null && "parser" in value && "metadata" in value && typeof value.metadata === "object" && value.metadata !== null && "name" in value.metadata && typeof value.metadata.name === "string";
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates that the extracted parser is a genuine Optique parser.
|
|
29
|
+
* @throws {TypeError} If the value is not a valid Parser.
|
|
30
|
+
*/
|
|
31
|
+
function validateParser(value) {
|
|
32
|
+
if (!isParser(value)) throw new TypeError("The given value is not a valid Parser or Program.");
|
|
10
33
|
}
|
|
11
34
|
/**
|
|
12
35
|
* Extracts parser and merged options from a parser or program.
|
|
13
36
|
*/
|
|
14
37
|
function extractParserAndOptions(parserOrProgram, options) {
|
|
15
38
|
if (isProgram(parserOrProgram)) {
|
|
39
|
+
validateParser(parserOrProgram.parser);
|
|
16
40
|
const { metadata } = parserOrProgram;
|
|
17
41
|
const programOptions = options;
|
|
18
42
|
return {
|
|
@@ -33,6 +57,7 @@ function extractParserAndOptions(parserOrProgram, options) {
|
|
|
33
57
|
}
|
|
34
58
|
};
|
|
35
59
|
}
|
|
60
|
+
validateParser(parserOrProgram);
|
|
36
61
|
return {
|
|
37
62
|
parser: parserOrProgram,
|
|
38
63
|
mergedOptions: options
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import { formatDocPageAsMan } from "./man-
|
|
1
|
+
import { formatDocPageAsMan } from "./man-CcjsLpyb.js";
|
|
2
2
|
import { getDocPageAsync, getDocPageSync } from "@optique/core/parser";
|
|
3
3
|
|
|
4
4
|
//#region src/generator.ts
|
|
5
5
|
/**
|
|
6
|
+
* Checks if the given value looks like a {@link Parser} at runtime.
|
|
7
|
+
*/
|
|
8
|
+
function isParser(value) {
|
|
9
|
+
try {
|
|
10
|
+
if (value == null || typeof value !== "object") return false;
|
|
11
|
+
const p = value;
|
|
12
|
+
return "parse" in p && typeof p.parse === "function" && "complete" in p && typeof p.complete === "function" && "$mode" in p && (p.$mode === "sync" || p.$mode === "async") && "usage" in p && Array.isArray(p.usage) && "initialState" in p && "suggest" in p && typeof p.suggest === "function" && "getDocFragments" in p && typeof p.getDocFragments === "function";
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
6
18
|
* Checks if the given value is a {@link Program} object.
|
|
7
19
|
*/
|
|
8
20
|
function isProgram(value) {
|
|
9
|
-
|
|
21
|
+
try {
|
|
22
|
+
return typeof value === "object" && value !== null && "parser" in value && "metadata" in value && typeof value.metadata === "object" && value.metadata !== null && "name" in value.metadata && typeof value.metadata.name === "string";
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates that the extracted parser is a genuine Optique parser.
|
|
29
|
+
* @throws {TypeError} If the value is not a valid Parser.
|
|
30
|
+
*/
|
|
31
|
+
function validateParser(value) {
|
|
32
|
+
if (!isParser(value)) throw new TypeError("The given value is not a valid Parser or Program.");
|
|
10
33
|
}
|
|
11
34
|
/**
|
|
12
35
|
* Extracts parser and merged options from a parser or program.
|
|
13
36
|
*/
|
|
14
37
|
function extractParserAndOptions(parserOrProgram, options) {
|
|
15
38
|
if (isProgram(parserOrProgram)) {
|
|
39
|
+
validateParser(parserOrProgram.parser);
|
|
16
40
|
const { metadata } = parserOrProgram;
|
|
17
41
|
const programOptions = options;
|
|
18
42
|
return {
|
|
@@ -33,6 +57,7 @@ function extractParserAndOptions(parserOrProgram, options) {
|
|
|
33
57
|
}
|
|
34
58
|
};
|
|
35
59
|
}
|
|
60
|
+
validateParser(parserOrProgram);
|
|
36
61
|
return {
|
|
37
62
|
parser: parserOrProgram,
|
|
38
63
|
mergedOptions: options
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_man = require('./man-
|
|
1
|
+
const require_man = require('./man-NL-hVPdd.cjs');
|
|
2
2
|
const require_roff = require('./roff-Cl0vekdg.cjs');
|
|
3
|
-
const require_generator = require('./generator-
|
|
3
|
+
const require_generator = require('./generator-BORgW1yS.cjs');
|
|
4
4
|
|
|
5
5
|
exports.escapeHyphens = require_roff.escapeHyphens;
|
|
6
6
|
exports.escapeQuotedValue = require_roff.escapeQuotedValue;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-C_87xXP6.cjs";
|
|
2
|
-
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-D2t8hkyn.cjs";
|
|
3
3
|
import { Mode, ModeValue, Parser } from "@optique/core/parser";
|
|
4
4
|
import { Program } from "@optique/core/program";
|
|
5
5
|
|
|
@@ -48,9 +48,10 @@ interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "se
|
|
|
48
48
|
* console.log(manPage);
|
|
49
49
|
* ```
|
|
50
50
|
*
|
|
51
|
-
* @param
|
|
51
|
+
* @param parserOrProgram The parser or program to generate documentation from.
|
|
52
52
|
* @param options The man page generation options.
|
|
53
53
|
* @returns The complete man page in roff format.
|
|
54
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
54
55
|
* @since 0.10.0
|
|
55
56
|
*/
|
|
56
57
|
declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
|
|
@@ -78,9 +79,10 @@ declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, o
|
|
|
78
79
|
* });
|
|
79
80
|
* ```
|
|
80
81
|
*
|
|
81
|
-
* @param
|
|
82
|
+
* @param parserOrProgram The parser or program to generate documentation from.
|
|
82
83
|
* @param options The man page generation options.
|
|
83
84
|
* @returns A promise that resolves to the complete man page in roff format.
|
|
85
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
84
86
|
* @since 0.10.0
|
|
85
87
|
*/
|
|
86
88
|
declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
|
|
@@ -148,6 +150,7 @@ declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown,
|
|
|
148
150
|
* @param parserOrProgram The parser or program to generate documentation from.
|
|
149
151
|
* @param options The man page generation options.
|
|
150
152
|
* @returns The complete man page in roff format, or a Promise for async parsers.
|
|
153
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
151
154
|
* @since 0.10.0
|
|
152
155
|
*/
|
|
153
156
|
declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-DlmeL3KB.js";
|
|
2
|
-
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-DXQgwt1g.js";
|
|
3
3
|
import { Program } from "@optique/core/program";
|
|
4
4
|
import { Mode, ModeValue, Parser } from "@optique/core/parser";
|
|
5
5
|
|
|
@@ -48,9 +48,10 @@ interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "se
|
|
|
48
48
|
* console.log(manPage);
|
|
49
49
|
* ```
|
|
50
50
|
*
|
|
51
|
-
* @param
|
|
51
|
+
* @param parserOrProgram The parser or program to generate documentation from.
|
|
52
52
|
* @param options The man page generation options.
|
|
53
53
|
* @returns The complete man page in roff format.
|
|
54
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
54
55
|
* @since 0.10.0
|
|
55
56
|
*/
|
|
56
57
|
declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
|
|
@@ -78,9 +79,10 @@ declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, o
|
|
|
78
79
|
* });
|
|
79
80
|
* ```
|
|
80
81
|
*
|
|
81
|
-
* @param
|
|
82
|
+
* @param parserOrProgram The parser or program to generate documentation from.
|
|
82
83
|
* @param options The man page generation options.
|
|
83
84
|
* @returns A promise that resolves to the complete man page in roff format.
|
|
85
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
84
86
|
* @since 0.10.0
|
|
85
87
|
*/
|
|
86
88
|
declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
|
|
@@ -148,6 +150,7 @@ declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown,
|
|
|
148
150
|
* @param parserOrProgram The parser or program to generate documentation from.
|
|
149
151
|
* @param options The man page generation options.
|
|
150
152
|
* @returns The complete man page in roff format, or a Promise for async parsers.
|
|
153
|
+
* @throws {TypeError} If the input is not a valid Parser or Program.
|
|
151
154
|
* @since 0.10.0
|
|
152
155
|
*/
|
|
153
156
|
declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-CwBRpWCo.js";
|
|
2
|
-
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
3
|
-
import { generateManPage, generateManPageAsync, generateManPageSync } from "./generator-
|
|
2
|
+
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CcjsLpyb.js";
|
|
3
|
+
import { generateManPage, generateManPageAsync, generateManPageSync } from "./generator-Di1pIRAG.js";
|
|
4
4
|
|
|
5
5
|
export { escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatDateForMan, formatDocPageAsMan, formatMessageAsRoff, formatUsageTermAsRoff, generateManPage, generateManPageAsync, generateManPageSync };
|
|
@@ -5,6 +5,12 @@ import { isDocHidden, isUsageHidden } from "@optique/core/usage";
|
|
|
5
5
|
/**
|
|
6
6
|
* Formats a date for use in man pages.
|
|
7
7
|
*
|
|
8
|
+
* When a `Date` object is given, the month and year are extracted using
|
|
9
|
+
* the host's local timezone (`getMonth()` / `getFullYear()`). This means
|
|
10
|
+
* the same `Date` instant may produce different output on machines in
|
|
11
|
+
* different timezones. Pass a pre-formatted string (e.g., `"January 2026"`)
|
|
12
|
+
* if you need timezone-independent output.
|
|
13
|
+
*
|
|
8
14
|
* @param date The date to format, or undefined.
|
|
9
15
|
* @returns The formatted date string, or undefined.
|
|
10
16
|
* @since 0.10.0
|
|
@@ -28,9 +34,6 @@ function formatDateForMan(date) {
|
|
|
28
34
|
];
|
|
29
35
|
return `${months[date.getMonth()]} ${date.getFullYear()}`;
|
|
30
36
|
}
|
|
31
|
-
function escapeThField(value) {
|
|
32
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
33
|
-
}
|
|
34
37
|
function formatCommandNameAsRoff(name) {
|
|
35
38
|
return `\\fB${escapeHyphens(escapeRoff(name))}\\fR`;
|
|
36
39
|
}
|
|
@@ -221,22 +224,22 @@ function formatDocPageAsMan(page, options) {
|
|
|
221
224
|
throw new RangeError(`Invalid man page section number (must be 1–8): ${repr}`);
|
|
222
225
|
}
|
|
223
226
|
const lines = [];
|
|
224
|
-
const thParts = [escapeHyphens(
|
|
227
|
+
const thParts = [`"${escapeHyphens(escapeRequestArg(options.name.toUpperCase()))}"`, options.section.toString()];
|
|
225
228
|
const hasDate = options.date != null && options.date !== "";
|
|
226
229
|
const hasVersion = options.version != null && options.version !== "";
|
|
227
230
|
const hasManual = options.manual != null && options.manual !== "";
|
|
228
|
-
if (hasDate) thParts.push(`"${
|
|
231
|
+
if (hasDate) thParts.push(`"${escapeRequestArg(formatDateForMan(options.date))}"`);
|
|
229
232
|
else if (hasVersion || hasManual) thParts.push("\"\"");
|
|
230
|
-
if (hasVersion) thParts.push(`"${escapeHyphens(
|
|
233
|
+
if (hasVersion) thParts.push(`"${escapeHyphens(escapeRequestArg(options.name))} ${escapeRequestArg(options.version)}"`);
|
|
231
234
|
else if (hasManual) thParts.push("\"\"");
|
|
232
|
-
if (hasManual) thParts.push(`"${
|
|
235
|
+
if (hasManual) thParts.push(`"${escapeRequestArg(options.manual)}"`);
|
|
233
236
|
lines.push(`.TH ${thParts.join(" ")}`);
|
|
234
237
|
lines.push(".SH NAME");
|
|
235
238
|
if (page.brief) lines.push(`${escapeHyphens(escapeRoff(options.name))} \\- ${formatMessageAsRoff(page.brief)}`);
|
|
236
239
|
else lines.push(escapeHyphens(escapeRoff(options.name)));
|
|
237
240
|
if (page.usage) {
|
|
238
241
|
lines.push(".SH SYNOPSIS");
|
|
239
|
-
lines.push(`.B ${escapeHyphens(
|
|
242
|
+
lines.push(`.B "${escapeHyphens(escapeRequestArg(options.name))}"`);
|
|
240
243
|
const usageStr = formatUsageAsRoff(page.usage);
|
|
241
244
|
if (usageStr) lines.push(usageStr);
|
|
242
245
|
}
|
|
@@ -285,7 +288,7 @@ function formatDocPageAsMan(page, options) {
|
|
|
285
288
|
lines.push(".SH SEE ALSO");
|
|
286
289
|
const refs = options.seeAlso.map((ref, i) => {
|
|
287
290
|
const suffix = i < options.seeAlso.length - 1 ? "," : "";
|
|
288
|
-
return `.BR ${escapeHyphens(
|
|
291
|
+
return `.BR "${escapeHyphens(escapeRequestArg(ref.name))}" (${ref.section})${suffix}`;
|
|
289
292
|
});
|
|
290
293
|
lines.push(refs.join("\n"));
|
|
291
294
|
}
|
|
@@ -32,7 +32,9 @@ interface ManPageOptions {
|
|
|
32
32
|
readonly section: ManPageSection;
|
|
33
33
|
/**
|
|
34
34
|
* The date to display in the man page footer.
|
|
35
|
-
* If a Date object is provided, it will be formatted as "Month Year"
|
|
35
|
+
* If a `Date` object is provided, it will be formatted as `"Month Year"`
|
|
36
|
+
* using the host's local timezone. For timezone-independent output (e.g.,
|
|
37
|
+
* in CI), pass a pre-formatted string instead.
|
|
36
38
|
* If a string is provided, it will be used as-is.
|
|
37
39
|
*/
|
|
38
40
|
readonly date?: string | Date;
|
|
@@ -80,6 +82,12 @@ interface ManPageOptions {
|
|
|
80
82
|
/**
|
|
81
83
|
* Formats a date for use in man pages.
|
|
82
84
|
*
|
|
85
|
+
* When a `Date` object is given, the month and year are extracted using
|
|
86
|
+
* the host's local timezone (`getMonth()` / `getFullYear()`). This means
|
|
87
|
+
* the same `Date` instant may produce different output on machines in
|
|
88
|
+
* different timezones. Pass a pre-formatted string (e.g., `"January 2026"`)
|
|
89
|
+
* if you need timezone-independent output.
|
|
90
|
+
*
|
|
83
91
|
* @param date The date to format, or undefined.
|
|
84
92
|
* @returns The formatted date string, or undefined.
|
|
85
93
|
* @since 0.10.0
|
|
@@ -32,7 +32,9 @@ interface ManPageOptions {
|
|
|
32
32
|
readonly section: ManPageSection;
|
|
33
33
|
/**
|
|
34
34
|
* The date to display in the man page footer.
|
|
35
|
-
* If a Date object is provided, it will be formatted as "Month Year"
|
|
35
|
+
* If a `Date` object is provided, it will be formatted as `"Month Year"`
|
|
36
|
+
* using the host's local timezone. For timezone-independent output (e.g.,
|
|
37
|
+
* in CI), pass a pre-formatted string instead.
|
|
36
38
|
* If a string is provided, it will be used as-is.
|
|
37
39
|
*/
|
|
38
40
|
readonly date?: string | Date;
|
|
@@ -80,6 +82,12 @@ interface ManPageOptions {
|
|
|
80
82
|
/**
|
|
81
83
|
* Formats a date for use in man pages.
|
|
82
84
|
*
|
|
85
|
+
* When a `Date` object is given, the month and year are extracted using
|
|
86
|
+
* the host's local timezone (`getMonth()` / `getFullYear()`). This means
|
|
87
|
+
* the same `Date` instant may produce different output on machines in
|
|
88
|
+
* different timezones. Pass a pre-formatted string (e.g., `"January 2026"`)
|
|
89
|
+
* if you need timezone-independent output.
|
|
90
|
+
*
|
|
83
91
|
* @param date The date to format, or undefined.
|
|
84
92
|
* @returns The formatted date string, or undefined.
|
|
85
93
|
* @since 0.10.0
|
|
@@ -28,6 +28,12 @@ const __optique_core_usage = __toESM(require("@optique/core/usage"));
|
|
|
28
28
|
/**
|
|
29
29
|
* Formats a date for use in man pages.
|
|
30
30
|
*
|
|
31
|
+
* When a `Date` object is given, the month and year are extracted using
|
|
32
|
+
* the host's local timezone (`getMonth()` / `getFullYear()`). This means
|
|
33
|
+
* the same `Date` instant may produce different output on machines in
|
|
34
|
+
* different timezones. Pass a pre-formatted string (e.g., `"January 2026"`)
|
|
35
|
+
* if you need timezone-independent output.
|
|
36
|
+
*
|
|
31
37
|
* @param date The date to format, or undefined.
|
|
32
38
|
* @returns The formatted date string, or undefined.
|
|
33
39
|
* @since 0.10.0
|
|
@@ -51,9 +57,6 @@ function formatDateForMan(date) {
|
|
|
51
57
|
];
|
|
52
58
|
return `${months[date.getMonth()]} ${date.getFullYear()}`;
|
|
53
59
|
}
|
|
54
|
-
function escapeThField(value) {
|
|
55
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
56
|
-
}
|
|
57
60
|
function formatCommandNameAsRoff(name) {
|
|
58
61
|
return `\\fB${require_roff.escapeHyphens(require_roff.escapeRoff(name))}\\fR`;
|
|
59
62
|
}
|
|
@@ -244,22 +247,22 @@ function formatDocPageAsMan(page, options) {
|
|
|
244
247
|
throw new RangeError(`Invalid man page section number (must be 1–8): ${repr}`);
|
|
245
248
|
}
|
|
246
249
|
const lines = [];
|
|
247
|
-
const thParts = [require_roff.escapeHyphens(
|
|
250
|
+
const thParts = [`"${require_roff.escapeHyphens(require_roff.escapeRequestArg(options.name.toUpperCase()))}"`, options.section.toString()];
|
|
248
251
|
const hasDate = options.date != null && options.date !== "";
|
|
249
252
|
const hasVersion = options.version != null && options.version !== "";
|
|
250
253
|
const hasManual = options.manual != null && options.manual !== "";
|
|
251
|
-
if (hasDate) thParts.push(`"${
|
|
254
|
+
if (hasDate) thParts.push(`"${require_roff.escapeRequestArg(formatDateForMan(options.date))}"`);
|
|
252
255
|
else if (hasVersion || hasManual) thParts.push("\"\"");
|
|
253
|
-
if (hasVersion) thParts.push(`"${require_roff.escapeHyphens(
|
|
256
|
+
if (hasVersion) thParts.push(`"${require_roff.escapeHyphens(require_roff.escapeRequestArg(options.name))} ${require_roff.escapeRequestArg(options.version)}"`);
|
|
254
257
|
else if (hasManual) thParts.push("\"\"");
|
|
255
|
-
if (hasManual) thParts.push(`"${
|
|
258
|
+
if (hasManual) thParts.push(`"${require_roff.escapeRequestArg(options.manual)}"`);
|
|
256
259
|
lines.push(`.TH ${thParts.join(" ")}`);
|
|
257
260
|
lines.push(".SH NAME");
|
|
258
261
|
if (page.brief) lines.push(`${require_roff.escapeHyphens(require_roff.escapeRoff(options.name))} \\- ${require_roff.formatMessageAsRoff(page.brief)}`);
|
|
259
262
|
else lines.push(require_roff.escapeHyphens(require_roff.escapeRoff(options.name)));
|
|
260
263
|
if (page.usage) {
|
|
261
264
|
lines.push(".SH SYNOPSIS");
|
|
262
|
-
lines.push(`.B ${require_roff.escapeHyphens(require_roff.
|
|
265
|
+
lines.push(`.B "${require_roff.escapeHyphens(require_roff.escapeRequestArg(options.name))}"`);
|
|
263
266
|
const usageStr = formatUsageAsRoff(page.usage);
|
|
264
267
|
if (usageStr) lines.push(usageStr);
|
|
265
268
|
}
|
|
@@ -308,7 +311,7 @@ function formatDocPageAsMan(page, options) {
|
|
|
308
311
|
lines.push(".SH SEE ALSO");
|
|
309
312
|
const refs = options.seeAlso.map((ref, i) => {
|
|
310
313
|
const suffix = i < options.seeAlso.length - 1 ? "," : "";
|
|
311
|
-
return `.BR ${require_roff.escapeHyphens(require_roff.
|
|
314
|
+
return `.BR "${require_roff.escapeHyphens(require_roff.escapeRequestArg(ref.name))}" (${ref.section})${suffix}`;
|
|
312
315
|
});
|
|
313
316
|
lines.push(refs.join("\n"));
|
|
314
317
|
}
|
package/dist/man.cjs
CHANGED
package/dist/man.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
1
|
+
import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-D2t8hkyn.cjs";
|
|
2
2
|
export { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff };
|
package/dist/man.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
1
|
+
import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-DXQgwt1g.js";
|
|
2
2
|
export { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff };
|
package/dist/man.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./roff-CwBRpWCo.js";
|
|
2
|
-
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CcjsLpyb.js";
|
|
3
3
|
|
|
4
4
|
export { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/man",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.908+f60f037d",
|
|
4
4
|
"description": "Man page generator for Optique CLI parsers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"optique-man": "./dist/cli.js"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@optique/run": "1.0.0-dev.
|
|
88
|
-
"@optique/core": "1.0.0-dev.
|
|
87
|
+
"@optique/run": "1.0.0-dev.908+f60f037d",
|
|
88
|
+
"@optique/core": "1.0.0-dev.908+f60f037d"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/node": "^20.19.9",
|