@optique/man 1.0.0-dev.717 → 1.0.0-dev.721
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 +15 -15
- package/dist/cli.js +3 -3
- package/dist/{generator-ClO3ng-c.cjs → generator-BDKtMiuq.cjs} +2 -31
- package/dist/{generator-DJKw6tjR.js → generator-DGiXLyTu.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{man-plaC9W3J.js → man-CAYHrsaf.js} +81 -12
- package/dist/{man-ChfTnlBu.cjs → man-CT30XV48.cjs} +110 -12
- package/dist/{man-BMb0Vyt9.d.cts → man-Dh4GLG_Q.d.cts} +1 -0
- package/dist/{man-tclTvdWs.d.ts → man-DrdGbys8.d.ts} +2 -1
- 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,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const require_man = require('./man-CT30XV48.cjs');
|
|
3
3
|
require('./roff-EpcecLXU.cjs');
|
|
4
|
-
require('./
|
|
5
|
-
const __optique_core_constructs =
|
|
6
|
-
const __optique_core_primitives =
|
|
7
|
-
const __optique_core_valueparser =
|
|
8
|
-
const __optique_core_modifiers =
|
|
9
|
-
const __optique_core_message =
|
|
10
|
-
const __optique_core_program =
|
|
11
|
-
const __optique_run =
|
|
12
|
-
const node_fs =
|
|
13
|
-
const node_fs_promises =
|
|
14
|
-
const node_path =
|
|
15
|
-
const node_process =
|
|
16
|
-
const node_url =
|
|
4
|
+
const require_generator = require('./generator-BDKtMiuq.cjs');
|
|
5
|
+
const __optique_core_constructs = require_man.__toESM(require("@optique/core/constructs"));
|
|
6
|
+
const __optique_core_primitives = require_man.__toESM(require("@optique/core/primitives"));
|
|
7
|
+
const __optique_core_valueparser = require_man.__toESM(require("@optique/core/valueparser"));
|
|
8
|
+
const __optique_core_modifiers = require_man.__toESM(require("@optique/core/modifiers"));
|
|
9
|
+
const __optique_core_message = require_man.__toESM(require("@optique/core/message"));
|
|
10
|
+
const __optique_core_program = require_man.__toESM(require("@optique/core/program"));
|
|
11
|
+
const __optique_run = require_man.__toESM(require("@optique/run"));
|
|
12
|
+
const node_fs = require_man.__toESM(require("node:fs"));
|
|
13
|
+
const node_fs_promises = require_man.__toESM(require("node:fs/promises"));
|
|
14
|
+
const node_path = require_man.__toESM(require("node:path"));
|
|
15
|
+
const node_process = require_man.__toESM(require("node:process"));
|
|
16
|
+
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.721+1fa3c379";
|
|
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-C_MiRXVS.js";
|
|
3
|
-
import "./man-
|
|
4
|
-
import { generateManPageAsync } from "./generator-
|
|
3
|
+
import "./man-CAYHrsaf.js";
|
|
4
|
+
import { generateManPageAsync } from "./generator-DGiXLyTu.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.721+1fa3c379";
|
|
21
21
|
var license = "MIT";
|
|
22
22
|
var exports = {
|
|
23
23
|
".": "./src/index.ts",
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const require_man = require('./man-ChfTnlBu.cjs');
|
|
25
|
-
const __optique_core_parser = __toESM(require("@optique/core/parser"));
|
|
1
|
+
const require_man = require('./man-CT30XV48.cjs');
|
|
2
|
+
const __optique_core_parser = require_man.__toESM(require("@optique/core/parser"));
|
|
26
3
|
|
|
27
4
|
//#region src/generator.ts
|
|
28
5
|
/**
|
|
@@ -78,12 +55,6 @@ function generateManPage(parserOrProgram, options) {
|
|
|
78
55
|
}
|
|
79
56
|
|
|
80
57
|
//#endregion
|
|
81
|
-
Object.defineProperty(exports, '__toESM', {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () {
|
|
84
|
-
return __toESM;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
58
|
Object.defineProperty(exports, 'generateManPage', {
|
|
88
59
|
enumerable: true,
|
|
89
60
|
get: function () {
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_man = require('./man-CT30XV48.cjs');
|
|
2
2
|
const require_roff = require('./roff-EpcecLXU.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_generator = require('./generator-BDKtMiuq.cjs');
|
|
4
4
|
|
|
5
5
|
exports.escapeHyphens = require_roff.escapeHyphens;
|
|
6
6
|
exports.escapeRoff = require_roff.escapeRoff;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeRoff, formatMessageAsRoff } from "./roff-72Am6STB.cjs";
|
|
2
|
-
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-Dh4GLG_Q.cjs";
|
|
3
3
|
import { Mode, ModeValue, Parser } from "@optique/core/parser";
|
|
4
4
|
import { Program } from "@optique/core/program";
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeRoff, formatMessageAsRoff } from "./roff-B36zMxYc.js";
|
|
2
|
-
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-DrdGbys8.js";
|
|
3
3
|
import { Program } from "@optique/core/program";
|
|
4
4
|
import { Mode, ModeValue, Parser } from "@optique/core/parser";
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, escapeRoff, formatMessageAsRoff } from "./roff-C_MiRXVS.js";
|
|
2
|
-
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
3
|
-
import { generateManPage, generateManPageAsync, generateManPageSync } from "./generator-
|
|
2
|
+
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CAYHrsaf.js";
|
|
3
|
+
import { generateManPage, generateManPageAsync, generateManPageSync } from "./generator-DGiXLyTu.js";
|
|
4
4
|
|
|
5
5
|
export { escapeHyphens, escapeRoff, formatDateForMan, formatDocPageAsMan, formatMessageAsRoff, formatUsageTermAsRoff, generateManPage, generateManPageAsync, generateManPageSync };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeHyphens, formatMessageAsRoff } from "./roff-C_MiRXVS.js";
|
|
2
|
+
import { isDocHidden, isUsageHidden } from "@optique/core/usage";
|
|
2
3
|
|
|
3
4
|
//#region src/man.ts
|
|
4
5
|
/**
|
|
@@ -35,10 +36,11 @@ function escapeThField(value) {
|
|
|
35
36
|
*
|
|
36
37
|
* @param term The usage term to format.
|
|
37
38
|
* @returns The roff-formatted string.
|
|
39
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
38
40
|
* @since 0.10.0
|
|
39
41
|
*/
|
|
40
42
|
function formatUsageTermAsRoff(term) {
|
|
41
|
-
if ("hidden" in term && term.hidden) return "";
|
|
43
|
+
if ("hidden" in term && isUsageHidden(term.hidden)) return "";
|
|
42
44
|
switch (term.type) {
|
|
43
45
|
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
44
46
|
case "option": {
|
|
@@ -49,16 +51,20 @@ function formatUsageTermAsRoff(term) {
|
|
|
49
51
|
case "command": return `\\fB${term.name}\\fR`;
|
|
50
52
|
case "optional": {
|
|
51
53
|
const inner = formatUsageAsRoff(term.terms);
|
|
54
|
+
if (inner === "") return "";
|
|
52
55
|
return `[${inner}]`;
|
|
53
56
|
}
|
|
54
57
|
case "multiple": {
|
|
55
58
|
const inner = formatUsageAsRoff(term.terms);
|
|
59
|
+
if (inner === "") return "";
|
|
56
60
|
if (term.min < 1) return `[${inner} ...]`;
|
|
57
61
|
return `${inner} ...`;
|
|
58
62
|
}
|
|
59
63
|
case "exclusive": {
|
|
60
|
-
const alternatives = term.terms.map((t) => formatUsageAsRoff(t)).
|
|
61
|
-
|
|
64
|
+
const alternatives = term.terms.map((t) => formatUsageAsRoff(t)).filter((s) => s !== "");
|
|
65
|
+
if (alternatives.length === 0) return "";
|
|
66
|
+
if (alternatives.length === 1) return alternatives[0];
|
|
67
|
+
return `(${alternatives.join(" | ")})`;
|
|
62
68
|
}
|
|
63
69
|
case "literal": return term.value;
|
|
64
70
|
case "passthrough": return "[...]";
|
|
@@ -85,6 +91,7 @@ function formatUsageAsRoff(usage) {
|
|
|
85
91
|
* @returns The roff-formatted term string.
|
|
86
92
|
*/
|
|
87
93
|
function formatDocEntryTerm(term) {
|
|
94
|
+
if ("hidden" in term && isDocHidden(term.hidden)) return "";
|
|
88
95
|
switch (term.type) {
|
|
89
96
|
case "option": {
|
|
90
97
|
const names = term.names.map((name) => `\\fB${escapeHyphens(name)}\\fR`).join(", ");
|
|
@@ -94,10 +101,59 @@ function formatDocEntryTerm(term) {
|
|
|
94
101
|
case "command": return `\\fB${term.name}\\fR`;
|
|
95
102
|
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
96
103
|
case "literal": return term.value;
|
|
97
|
-
default: return
|
|
104
|
+
default: return formatDocUsageTermAsRoff(term);
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
/**
|
|
108
|
+
* Formats a {@link UsageTerm} as roff markup for doc rendering, filtering
|
|
109
|
+
* doc-hidden terms instead of usage-hidden terms.
|
|
110
|
+
*
|
|
111
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
112
|
+
*/
|
|
113
|
+
function formatDocUsageTermAsRoff(term) {
|
|
114
|
+
if ("hidden" in term && isDocHidden(term.hidden)) return "";
|
|
115
|
+
switch (term.type) {
|
|
116
|
+
case "optional": {
|
|
117
|
+
const inner = formatDocUsageAsRoff(term.terms);
|
|
118
|
+
if (inner === "") return "";
|
|
119
|
+
return `[${inner}]`;
|
|
120
|
+
}
|
|
121
|
+
case "multiple": {
|
|
122
|
+
const inner = formatDocUsageAsRoff(term.terms);
|
|
123
|
+
if (inner === "") return "";
|
|
124
|
+
if (term.min < 1) return `[${inner} ...]`;
|
|
125
|
+
return `${inner} ...`;
|
|
126
|
+
}
|
|
127
|
+
case "exclusive": {
|
|
128
|
+
const alternatives = term.terms.map((t) => formatDocUsageAsRoff(t)).filter((s) => s !== "");
|
|
129
|
+
if (alternatives.length === 0) return "";
|
|
130
|
+
if (alternatives.length === 1) return alternatives[0];
|
|
131
|
+
return `(${alternatives.join(" | ")})`;
|
|
132
|
+
}
|
|
133
|
+
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
134
|
+
case "option": {
|
|
135
|
+
const names = term.names.map((name) => `\\fB${escapeHyphens(name)}\\fR`).join(", ");
|
|
136
|
+
const metavarPart = term.metavar ? ` \\fI${term.metavar}\\fR` : "";
|
|
137
|
+
return `${names}${metavarPart}`;
|
|
138
|
+
}
|
|
139
|
+
case "command": return `\\fB${term.name}\\fR`;
|
|
140
|
+
case "literal": return term.value;
|
|
141
|
+
case "passthrough": return "[...]";
|
|
142
|
+
case "ellipsis": return "...";
|
|
143
|
+
default: {
|
|
144
|
+
const _exhaustive = term;
|
|
145
|
+
throw new TypeError(`Unknown usage term type: ${_exhaustive.type}.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Formats a {@link Usage} array as roff markup for doc rendering,
|
|
151
|
+
* filtering doc-hidden terms.
|
|
152
|
+
*/
|
|
153
|
+
function formatDocUsageAsRoff(usage) {
|
|
154
|
+
return usage.map(formatDocUsageTermAsRoff).filter((s) => s !== "").join(" ");
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
101
157
|
* Formats a {@link DocSection} as roff markup with .TP macros.
|
|
102
158
|
*
|
|
103
159
|
* @param section The section to format.
|
|
@@ -106,8 +162,10 @@ function formatDocEntryTerm(term) {
|
|
|
106
162
|
function formatDocSectionEntries(section) {
|
|
107
163
|
const lines = [];
|
|
108
164
|
for (const entry of section.entries) {
|
|
165
|
+
const termStr = formatDocEntryTerm(entry.term);
|
|
166
|
+
if (termStr === "") continue;
|
|
109
167
|
lines.push(".TP");
|
|
110
|
-
lines.push(
|
|
168
|
+
lines.push(termStr);
|
|
111
169
|
if (entry.description) {
|
|
112
170
|
let desc = formatMessageAsRoff(entry.description);
|
|
113
171
|
if (entry.default) desc += ` [${formatMessageAsRoff(entry.default)}]`;
|
|
@@ -172,21 +230,32 @@ function formatDocPageAsMan(page, options) {
|
|
|
172
230
|
}
|
|
173
231
|
for (const section of page.sections) {
|
|
174
232
|
if (section.entries.length === 0) continue;
|
|
233
|
+
const content = formatDocSectionEntries(section);
|
|
234
|
+
if (content === "") continue;
|
|
175
235
|
const title = section.title?.toUpperCase() ?? "OPTIONS";
|
|
176
236
|
lines.push(`.SH ${title}`);
|
|
177
|
-
lines.push(
|
|
237
|
+
lines.push(content);
|
|
178
238
|
}
|
|
179
239
|
if (options.environment && options.environment.entries.length > 0) {
|
|
180
|
-
|
|
181
|
-
|
|
240
|
+
const content = formatDocSectionEntries(options.environment);
|
|
241
|
+
if (content !== "") {
|
|
242
|
+
lines.push(".SH ENVIRONMENT");
|
|
243
|
+
lines.push(content);
|
|
244
|
+
}
|
|
182
245
|
}
|
|
183
246
|
if (options.files && options.files.entries.length > 0) {
|
|
184
|
-
|
|
185
|
-
|
|
247
|
+
const content = formatDocSectionEntries(options.files);
|
|
248
|
+
if (content !== "") {
|
|
249
|
+
lines.push(".SH FILES");
|
|
250
|
+
lines.push(content);
|
|
251
|
+
}
|
|
186
252
|
}
|
|
187
253
|
if (options.exitStatus && options.exitStatus.entries.length > 0) {
|
|
188
|
-
|
|
189
|
-
|
|
254
|
+
const content = formatDocSectionEntries(options.exitStatus);
|
|
255
|
+
if (content !== "") {
|
|
256
|
+
lines.push(".SH EXIT STATUS");
|
|
257
|
+
lines.push(content);
|
|
258
|
+
}
|
|
190
259
|
}
|
|
191
260
|
if (options.examples) {
|
|
192
261
|
lines.push(".SH EXAMPLES");
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
1
24
|
const require_roff = require('./roff-EpcecLXU.cjs');
|
|
25
|
+
const __optique_core_usage = __toESM(require("@optique/core/usage"));
|
|
2
26
|
|
|
3
27
|
//#region src/man.ts
|
|
4
28
|
/**
|
|
@@ -35,10 +59,11 @@ function escapeThField(value) {
|
|
|
35
59
|
*
|
|
36
60
|
* @param term The usage term to format.
|
|
37
61
|
* @returns The roff-formatted string.
|
|
62
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
38
63
|
* @since 0.10.0
|
|
39
64
|
*/
|
|
40
65
|
function formatUsageTermAsRoff(term) {
|
|
41
|
-
if ("hidden" in term && term.hidden) return "";
|
|
66
|
+
if ("hidden" in term && (0, __optique_core_usage.isUsageHidden)(term.hidden)) return "";
|
|
42
67
|
switch (term.type) {
|
|
43
68
|
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
44
69
|
case "option": {
|
|
@@ -49,16 +74,20 @@ function formatUsageTermAsRoff(term) {
|
|
|
49
74
|
case "command": return `\\fB${term.name}\\fR`;
|
|
50
75
|
case "optional": {
|
|
51
76
|
const inner = formatUsageAsRoff(term.terms);
|
|
77
|
+
if (inner === "") return "";
|
|
52
78
|
return `[${inner}]`;
|
|
53
79
|
}
|
|
54
80
|
case "multiple": {
|
|
55
81
|
const inner = formatUsageAsRoff(term.terms);
|
|
82
|
+
if (inner === "") return "";
|
|
56
83
|
if (term.min < 1) return `[${inner} ...]`;
|
|
57
84
|
return `${inner} ...`;
|
|
58
85
|
}
|
|
59
86
|
case "exclusive": {
|
|
60
|
-
const alternatives = term.terms.map((t) => formatUsageAsRoff(t)).
|
|
61
|
-
|
|
87
|
+
const alternatives = term.terms.map((t) => formatUsageAsRoff(t)).filter((s) => s !== "");
|
|
88
|
+
if (alternatives.length === 0) return "";
|
|
89
|
+
if (alternatives.length === 1) return alternatives[0];
|
|
90
|
+
return `(${alternatives.join(" | ")})`;
|
|
62
91
|
}
|
|
63
92
|
case "literal": return term.value;
|
|
64
93
|
case "passthrough": return "[...]";
|
|
@@ -85,6 +114,7 @@ function formatUsageAsRoff(usage) {
|
|
|
85
114
|
* @returns The roff-formatted term string.
|
|
86
115
|
*/
|
|
87
116
|
function formatDocEntryTerm(term) {
|
|
117
|
+
if ("hidden" in term && (0, __optique_core_usage.isDocHidden)(term.hidden)) return "";
|
|
88
118
|
switch (term.type) {
|
|
89
119
|
case "option": {
|
|
90
120
|
const names = term.names.map((name) => `\\fB${require_roff.escapeHyphens(name)}\\fR`).join(", ");
|
|
@@ -94,10 +124,59 @@ function formatDocEntryTerm(term) {
|
|
|
94
124
|
case "command": return `\\fB${term.name}\\fR`;
|
|
95
125
|
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
96
126
|
case "literal": return term.value;
|
|
97
|
-
default: return
|
|
127
|
+
default: return formatDocUsageTermAsRoff(term);
|
|
98
128
|
}
|
|
99
129
|
}
|
|
100
130
|
/**
|
|
131
|
+
* Formats a {@link UsageTerm} as roff markup for doc rendering, filtering
|
|
132
|
+
* doc-hidden terms instead of usage-hidden terms.
|
|
133
|
+
*
|
|
134
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
135
|
+
*/
|
|
136
|
+
function formatDocUsageTermAsRoff(term) {
|
|
137
|
+
if ("hidden" in term && (0, __optique_core_usage.isDocHidden)(term.hidden)) return "";
|
|
138
|
+
switch (term.type) {
|
|
139
|
+
case "optional": {
|
|
140
|
+
const inner = formatDocUsageAsRoff(term.terms);
|
|
141
|
+
if (inner === "") return "";
|
|
142
|
+
return `[${inner}]`;
|
|
143
|
+
}
|
|
144
|
+
case "multiple": {
|
|
145
|
+
const inner = formatDocUsageAsRoff(term.terms);
|
|
146
|
+
if (inner === "") return "";
|
|
147
|
+
if (term.min < 1) return `[${inner} ...]`;
|
|
148
|
+
return `${inner} ...`;
|
|
149
|
+
}
|
|
150
|
+
case "exclusive": {
|
|
151
|
+
const alternatives = term.terms.map((t) => formatDocUsageAsRoff(t)).filter((s) => s !== "");
|
|
152
|
+
if (alternatives.length === 0) return "";
|
|
153
|
+
if (alternatives.length === 1) return alternatives[0];
|
|
154
|
+
return `(${alternatives.join(" | ")})`;
|
|
155
|
+
}
|
|
156
|
+
case "argument": return `\\fI${term.metavar}\\fR`;
|
|
157
|
+
case "option": {
|
|
158
|
+
const names = term.names.map((name) => `\\fB${require_roff.escapeHyphens(name)}\\fR`).join(", ");
|
|
159
|
+
const metavarPart = term.metavar ? ` \\fI${term.metavar}\\fR` : "";
|
|
160
|
+
return `${names}${metavarPart}`;
|
|
161
|
+
}
|
|
162
|
+
case "command": return `\\fB${term.name}\\fR`;
|
|
163
|
+
case "literal": return term.value;
|
|
164
|
+
case "passthrough": return "[...]";
|
|
165
|
+
case "ellipsis": return "...";
|
|
166
|
+
default: {
|
|
167
|
+
const _exhaustive = term;
|
|
168
|
+
throw new TypeError(`Unknown usage term type: ${_exhaustive.type}.`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Formats a {@link Usage} array as roff markup for doc rendering,
|
|
174
|
+
* filtering doc-hidden terms.
|
|
175
|
+
*/
|
|
176
|
+
function formatDocUsageAsRoff(usage) {
|
|
177
|
+
return usage.map(formatDocUsageTermAsRoff).filter((s) => s !== "").join(" ");
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
101
180
|
* Formats a {@link DocSection} as roff markup with .TP macros.
|
|
102
181
|
*
|
|
103
182
|
* @param section The section to format.
|
|
@@ -106,8 +185,10 @@ function formatDocEntryTerm(term) {
|
|
|
106
185
|
function formatDocSectionEntries(section) {
|
|
107
186
|
const lines = [];
|
|
108
187
|
for (const entry of section.entries) {
|
|
188
|
+
const termStr = formatDocEntryTerm(entry.term);
|
|
189
|
+
if (termStr === "") continue;
|
|
109
190
|
lines.push(".TP");
|
|
110
|
-
lines.push(
|
|
191
|
+
lines.push(termStr);
|
|
111
192
|
if (entry.description) {
|
|
112
193
|
let desc = require_roff.formatMessageAsRoff(entry.description);
|
|
113
194
|
if (entry.default) desc += ` [${require_roff.formatMessageAsRoff(entry.default)}]`;
|
|
@@ -172,21 +253,32 @@ function formatDocPageAsMan(page, options) {
|
|
|
172
253
|
}
|
|
173
254
|
for (const section of page.sections) {
|
|
174
255
|
if (section.entries.length === 0) continue;
|
|
256
|
+
const content = formatDocSectionEntries(section);
|
|
257
|
+
if (content === "") continue;
|
|
175
258
|
const title = section.title?.toUpperCase() ?? "OPTIONS";
|
|
176
259
|
lines.push(`.SH ${title}`);
|
|
177
|
-
lines.push(
|
|
260
|
+
lines.push(content);
|
|
178
261
|
}
|
|
179
262
|
if (options.environment && options.environment.entries.length > 0) {
|
|
180
|
-
|
|
181
|
-
|
|
263
|
+
const content = formatDocSectionEntries(options.environment);
|
|
264
|
+
if (content !== "") {
|
|
265
|
+
lines.push(".SH ENVIRONMENT");
|
|
266
|
+
lines.push(content);
|
|
267
|
+
}
|
|
182
268
|
}
|
|
183
269
|
if (options.files && options.files.entries.length > 0) {
|
|
184
|
-
|
|
185
|
-
|
|
270
|
+
const content = formatDocSectionEntries(options.files);
|
|
271
|
+
if (content !== "") {
|
|
272
|
+
lines.push(".SH FILES");
|
|
273
|
+
lines.push(content);
|
|
274
|
+
}
|
|
186
275
|
}
|
|
187
276
|
if (options.exitStatus && options.exitStatus.entries.length > 0) {
|
|
188
|
-
|
|
189
|
-
|
|
277
|
+
const content = formatDocSectionEntries(options.exitStatus);
|
|
278
|
+
if (content !== "") {
|
|
279
|
+
lines.push(".SH EXIT STATUS");
|
|
280
|
+
lines.push(content);
|
|
281
|
+
}
|
|
190
282
|
}
|
|
191
283
|
if (options.examples) {
|
|
192
284
|
lines.push(".SH EXAMPLES");
|
|
@@ -216,6 +308,12 @@ function formatDocPageAsMan(page, options) {
|
|
|
216
308
|
}
|
|
217
309
|
|
|
218
310
|
//#endregion
|
|
311
|
+
Object.defineProperty(exports, '__toESM', {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function () {
|
|
314
|
+
return __toESM;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
219
317
|
Object.defineProperty(exports, 'formatDateForMan', {
|
|
220
318
|
enumerable: true,
|
|
221
319
|
get: function () {
|
|
@@ -90,6 +90,7 @@ declare function formatDateForMan(date: string | Date | undefined): string | und
|
|
|
90
90
|
*
|
|
91
91
|
* @param term The usage term to format.
|
|
92
92
|
* @returns The roff-formatted string.
|
|
93
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
93
94
|
* @since 0.10.0
|
|
94
95
|
*/
|
|
95
96
|
declare function formatUsageTermAsRoff(term: UsageTerm): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "@optique/core/message";
|
|
2
|
-
import { DocPage, DocSection } from "@optique/core/doc";
|
|
3
2
|
import { UsageTerm } from "@optique/core/usage";
|
|
3
|
+
import { DocPage, DocSection } from "@optique/core/doc";
|
|
4
4
|
|
|
5
5
|
//#region src/man.d.ts
|
|
6
6
|
|
|
@@ -90,6 +90,7 @@ declare function formatDateForMan(date: string | Date | undefined): string | und
|
|
|
90
90
|
*
|
|
91
91
|
* @param term The usage term to format.
|
|
92
92
|
* @returns The roff-formatted string.
|
|
93
|
+
* @throws {TypeError} If the term has an unknown type.
|
|
93
94
|
* @since 0.10.0
|
|
94
95
|
*/
|
|
95
96
|
declare function formatUsageTermAsRoff(term: UsageTerm): string;
|
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-Dh4GLG_Q.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-DrdGbys8.js";
|
|
2
2
|
export { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff };
|
package/dist/man.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./roff-C_MiRXVS.js";
|
|
2
|
-
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-
|
|
2
|
+
import { formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CAYHrsaf.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.721+1fa3c379",
|
|
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/
|
|
88
|
-
"@optique/
|
|
87
|
+
"@optique/core": "1.0.0-dev.721+1fa3c379",
|
|
88
|
+
"@optique/run": "1.0.0-dev.721+1fa3c379"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/node": "^20.19.9",
|