@optique/man 1.1.0-dev.2096 → 1.1.0-dev.2148

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 CHANGED
@@ -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.1.0-dev.2096+8eda4929";
20
+ var version = "1.1.0-dev.2148+ab56ac96";
21
21
  var license = "MIT";
22
22
  var exports$1 = {
23
23
  ".": "./src/index.ts",
@@ -25,14 +25,17 @@ var exports$1 = {
25
25
  "./man": "./src/man.ts",
26
26
  "./cli": "./src/cli.ts"
27
27
  };
28
- var imports = { "tsx/esm/api": "npm:tsx@^4.21.0/esm/api" };
28
+ var imports = {
29
+ "#src/": "./src/",
30
+ "tsx/esm/api": "npm:tsx@^4.21.0/esm/api"
31
+ };
29
32
  var exclude = ["dist/", "tsdown.config.ts"];
30
33
  var tasks = {
31
34
  "build": "pnpm build",
32
35
  "test": "deno test",
33
36
  "test:node": {
34
37
  "dependencies": ["build"],
35
- "command": "node --experimental-transform-types --test"
38
+ "command": "node --test"
36
39
  },
37
40
  "test:bun": {
38
41
  "dependencies": ["build"],
package/dist/cli.js CHANGED
@@ -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.1.0-dev.2096+8eda4929";
20
+ var version = "1.1.0-dev.2148+ab56ac96";
21
21
  var license = "MIT";
22
22
  var exports = {
23
23
  ".": "./src/index.ts",
@@ -25,14 +25,17 @@ var exports = {
25
25
  "./man": "./src/man.ts",
26
26
  "./cli": "./src/cli.ts"
27
27
  };
28
- var imports = { "tsx/esm/api": "npm:tsx@^4.21.0/esm/api" };
28
+ var imports = {
29
+ "#src/": "./src/",
30
+ "tsx/esm/api": "npm:tsx@^4.21.0/esm/api"
31
+ };
29
32
  var exclude = ["dist/", "tsdown.config.ts"];
30
33
  var tasks = {
31
34
  "build": "pnpm build",
32
35
  "test": "deno test",
33
36
  "test:node": {
34
37
  "dependencies": ["build"],
35
- "command": "node --experimental-transform-types --test"
38
+ "command": "node --test"
36
39
  },
37
40
  "test:bun": {
38
41
  "dependencies": ["build"],
@@ -0,0 +1,161 @@
1
+ import { ManPageOptions } from "./man-C3FUTPuQ.cjs";
2
+ import { Mode, ModeValue, Parser } from "@optique/core/parser";
3
+ import { Program } from "@optique/core/program";
4
+
5
+ //#region src/generator.d.ts
6
+
7
+ /**
8
+ * Options for generating a man page from a parser.
9
+ * Extends {@link ManPageOptions} with the same configuration.
10
+ * @since 0.10.0
11
+ */
12
+ interface GenerateManPageOptions extends ManPageOptions {}
13
+ /**
14
+ * Options for generating a man page from a {@link Program}.
15
+ *
16
+ * For Program inputs, `name`, `version`, `author`, `bugs`, `examples`,
17
+ * `brief`, `description`, and `footer` default to values from
18
+ * `program.metadata`.
19
+ * These fields are optional here and may be provided to override metadata.
20
+ *
21
+ * @since 0.10.0
22
+ */
23
+ interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "section">>, Pick<ManPageOptions, "section"> {}
24
+ /**
25
+ * Generates a man page from a parser synchronously.
26
+ *
27
+ * This function extracts documentation from the parser's structure
28
+ * and formats it as a complete man page in roff format.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { generateManPageSync } from "@optique/man";
33
+ * import { object, option, flag } from "@optique/core/primitives";
34
+ * import { string } from "@optique/core/valueparser";
35
+ *
36
+ * const parser = object({
37
+ * verbose: flag("-v", "--verbose"),
38
+ * config: option("-c", "--config", string()),
39
+ * });
40
+ *
41
+ * const manPage = generateManPageSync(parser, {
42
+ * name: "myapp",
43
+ * section: 1,
44
+ * version: "1.0.0",
45
+ * });
46
+ *
47
+ * console.log(manPage);
48
+ * ```
49
+ *
50
+ * @param parserOrProgram The parser or program to generate documentation from.
51
+ * @param options The man page generation options.
52
+ * @returns The complete man page in roff format.
53
+ * @throws {TypeError} If the input is not a valid Parser or Program.
54
+ * @since 0.10.0
55
+ */
56
+ declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
57
+ declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
58
+ /**
59
+ * Generates a man page from a parser asynchronously.
60
+ *
61
+ * This function extracts documentation from the parser's structure
62
+ * and formats it as a complete man page in roff format. It supports
63
+ * both sync and async parsers.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { generateManPageAsync } from "@optique/man";
68
+ * import { object, option } from "@optique/core/primitives";
69
+ * import { string } from "@optique/core/valueparser";
70
+ *
71
+ * const parser = object({
72
+ * config: option("-c", "--config", string()),
73
+ * });
74
+ *
75
+ * const manPage = await generateManPageAsync(parser, {
76
+ * name: "myapp",
77
+ * section: 1,
78
+ * });
79
+ * ```
80
+ *
81
+ * @param parserOrProgram The parser or program to generate documentation from.
82
+ * @param options The man page generation options.
83
+ * @returns A promise that resolves to the complete man page in roff format.
84
+ * @throws {TypeError} If the input is not a valid Parser or Program.
85
+ * @since 0.10.0
86
+ */
87
+ declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
88
+ declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
89
+ /**
90
+ * Generates a man page from a parser or program.
91
+ *
92
+ * This function extracts documentation from the parser's structure
93
+ * and formats it as a complete man page in roff format.
94
+ *
95
+ * For sync parsers, it returns the man page directly.
96
+ * For async parsers, it returns a Promise that resolves to the man page.
97
+ *
98
+ * @example Parser-based API
99
+ * ```typescript
100
+ * import { generateManPage } from "@optique/man";
101
+ * import { object, option, flag } from "@optique/core/primitives";
102
+ * import { string, integer } from "@optique/core/valueparser";
103
+ * import { message } from "@optique/core/message";
104
+ *
105
+ * const parser = object({
106
+ * verbose: flag("-v", "--verbose", {
107
+ * description: message`Enable verbose output.`,
108
+ * }),
109
+ * port: option("-p", "--port", integer(), {
110
+ * description: message`Port to listen on.`,
111
+ * }),
112
+ * });
113
+ *
114
+ * const manPage = generateManPage(parser, {
115
+ * name: "myapp",
116
+ * section: 1,
117
+ * version: "1.0.0",
118
+ * date: new Date(),
119
+ * author: message`Hong Minhee`,
120
+ * });
121
+ *
122
+ * // Write to file
123
+ * import { writeFileSync } from "node:fs";
124
+ * writeFileSync("myapp.1", manPage);
125
+ * ```
126
+ *
127
+ * @example Program-based API
128
+ * ```typescript
129
+ * import { generateManPage } from "@optique/man";
130
+ * import { defineProgram } from "@optique/core/program";
131
+ * import { object, flag } from "@optique/core/primitives";
132
+ * import { message } from "@optique/core/message";
133
+ *
134
+ * const prog = defineProgram({
135
+ * parser: object({
136
+ * verbose: flag("-v", "--verbose"),
137
+ * }),
138
+ * metadata: {
139
+ * name: "myapp",
140
+ * version: "1.0.0",
141
+ * author: message`Hong Minhee`,
142
+ * },
143
+ * });
144
+ *
145
+ * // Metadata is automatically extracted from the program
146
+ * const manPage = generateManPage(prog, { section: 1 });
147
+ * ```
148
+ *
149
+ * @param parserOrProgram The parser or program to generate documentation from.
150
+ * @param options The man page generation options.
151
+ * @returns The complete man page in roff format, or a Promise for async parsers.
152
+ * @throws {TypeError} If the input is not a valid Parser or Program.
153
+ * @since 0.10.0
154
+ */
155
+ declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
156
+ declare function generateManPage<T>(program: Program<"async", T>, options: GenerateManPageProgramOptions): Promise<string>;
157
+ declare function generateManPage(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
158
+ declare function generateManPage(parser: Parser<"async", unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
159
+ declare function generateManPage<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): ModeValue<M, string>;
160
+ //#endregion
161
+ export { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync };
@@ -0,0 +1,161 @@
1
+ import { ManPageOptions } from "./man-CHYiSoI_.js";
2
+ import { Program } from "@optique/core/program";
3
+ import { Mode, ModeValue, Parser } from "@optique/core/parser";
4
+
5
+ //#region src/generator.d.ts
6
+
7
+ /**
8
+ * Options for generating a man page from a parser.
9
+ * Extends {@link ManPageOptions} with the same configuration.
10
+ * @since 0.10.0
11
+ */
12
+ interface GenerateManPageOptions extends ManPageOptions {}
13
+ /**
14
+ * Options for generating a man page from a {@link Program}.
15
+ *
16
+ * For Program inputs, `name`, `version`, `author`, `bugs`, `examples`,
17
+ * `brief`, `description`, and `footer` default to values from
18
+ * `program.metadata`.
19
+ * These fields are optional here and may be provided to override metadata.
20
+ *
21
+ * @since 0.10.0
22
+ */
23
+ interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "section">>, Pick<ManPageOptions, "section"> {}
24
+ /**
25
+ * Generates a man page from a parser synchronously.
26
+ *
27
+ * This function extracts documentation from the parser's structure
28
+ * and formats it as a complete man page in roff format.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { generateManPageSync } from "@optique/man";
33
+ * import { object, option, flag } from "@optique/core/primitives";
34
+ * import { string } from "@optique/core/valueparser";
35
+ *
36
+ * const parser = object({
37
+ * verbose: flag("-v", "--verbose"),
38
+ * config: option("-c", "--config", string()),
39
+ * });
40
+ *
41
+ * const manPage = generateManPageSync(parser, {
42
+ * name: "myapp",
43
+ * section: 1,
44
+ * version: "1.0.0",
45
+ * });
46
+ *
47
+ * console.log(manPage);
48
+ * ```
49
+ *
50
+ * @param parserOrProgram The parser or program to generate documentation from.
51
+ * @param options The man page generation options.
52
+ * @returns The complete man page in roff format.
53
+ * @throws {TypeError} If the input is not a valid Parser or Program.
54
+ * @since 0.10.0
55
+ */
56
+ declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
57
+ declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
58
+ /**
59
+ * Generates a man page from a parser asynchronously.
60
+ *
61
+ * This function extracts documentation from the parser's structure
62
+ * and formats it as a complete man page in roff format. It supports
63
+ * both sync and async parsers.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { generateManPageAsync } from "@optique/man";
68
+ * import { object, option } from "@optique/core/primitives";
69
+ * import { string } from "@optique/core/valueparser";
70
+ *
71
+ * const parser = object({
72
+ * config: option("-c", "--config", string()),
73
+ * });
74
+ *
75
+ * const manPage = await generateManPageAsync(parser, {
76
+ * name: "myapp",
77
+ * section: 1,
78
+ * });
79
+ * ```
80
+ *
81
+ * @param parserOrProgram The parser or program to generate documentation from.
82
+ * @param options The man page generation options.
83
+ * @returns A promise that resolves to the complete man page in roff format.
84
+ * @throws {TypeError} If the input is not a valid Parser or Program.
85
+ * @since 0.10.0
86
+ */
87
+ declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
88
+ declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
89
+ /**
90
+ * Generates a man page from a parser or program.
91
+ *
92
+ * This function extracts documentation from the parser's structure
93
+ * and formats it as a complete man page in roff format.
94
+ *
95
+ * For sync parsers, it returns the man page directly.
96
+ * For async parsers, it returns a Promise that resolves to the man page.
97
+ *
98
+ * @example Parser-based API
99
+ * ```typescript
100
+ * import { generateManPage } from "@optique/man";
101
+ * import { object, option, flag } from "@optique/core/primitives";
102
+ * import { string, integer } from "@optique/core/valueparser";
103
+ * import { message } from "@optique/core/message";
104
+ *
105
+ * const parser = object({
106
+ * verbose: flag("-v", "--verbose", {
107
+ * description: message`Enable verbose output.`,
108
+ * }),
109
+ * port: option("-p", "--port", integer(), {
110
+ * description: message`Port to listen on.`,
111
+ * }),
112
+ * });
113
+ *
114
+ * const manPage = generateManPage(parser, {
115
+ * name: "myapp",
116
+ * section: 1,
117
+ * version: "1.0.0",
118
+ * date: new Date(),
119
+ * author: message`Hong Minhee`,
120
+ * });
121
+ *
122
+ * // Write to file
123
+ * import { writeFileSync } from "node:fs";
124
+ * writeFileSync("myapp.1", manPage);
125
+ * ```
126
+ *
127
+ * @example Program-based API
128
+ * ```typescript
129
+ * import { generateManPage } from "@optique/man";
130
+ * import { defineProgram } from "@optique/core/program";
131
+ * import { object, flag } from "@optique/core/primitives";
132
+ * import { message } from "@optique/core/message";
133
+ *
134
+ * const prog = defineProgram({
135
+ * parser: object({
136
+ * verbose: flag("-v", "--verbose"),
137
+ * }),
138
+ * metadata: {
139
+ * name: "myapp",
140
+ * version: "1.0.0",
141
+ * author: message`Hong Minhee`,
142
+ * },
143
+ * });
144
+ *
145
+ * // Metadata is automatically extracted from the program
146
+ * const manPage = generateManPage(prog, { section: 1 });
147
+ * ```
148
+ *
149
+ * @param parserOrProgram The parser or program to generate documentation from.
150
+ * @param options The man page generation options.
151
+ * @returns The complete man page in roff format, or a Promise for async parsers.
152
+ * @throws {TypeError} If the input is not a valid Parser or Program.
153
+ * @since 0.10.0
154
+ */
155
+ declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
156
+ declare function generateManPage<T>(program: Program<"async", T>, options: GenerateManPageProgramOptions): Promise<string>;
157
+ declare function generateManPage(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
158
+ declare function generateManPage(parser: Parser<"async", unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
159
+ declare function generateManPage<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): ModeValue<M, string>;
160
+ //#endregion
161
+ export { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync };
@@ -0,0 +1,7 @@
1
+ require('./man-C44Q4VSc.cjs');
2
+ require('./roff-C8MvQ2tL.cjs');
3
+ const require_generator = require('./generator-CtkCu_MS.cjs');
4
+
5
+ exports.generateManPage = require_generator.generateManPage;
6
+ exports.generateManPageAsync = require_generator.generateManPageAsync;
7
+ exports.generateManPageSync = require_generator.generateManPageSync;
@@ -0,0 +1,3 @@
1
+ import "./man-C3FUTPuQ.cjs";
2
+ import { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync } from "./generator-I9cXlw1Z.cjs";
3
+ export { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync };
@@ -0,0 +1,3 @@
1
+ import "./man-CHYiSoI_.js";
2
+ import { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync } from "./generator-MbR1I1SH.js";
3
+ export { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync };
@@ -0,0 +1,5 @@
1
+ import "./roff-Bh9bsH6u.js";
2
+ import "./man-Cq0qfXg0.js";
3
+ import { generateManPage, generateManPageAsync, generateManPageSync } from "./generator-DywTJCMH.js";
4
+
5
+ export { generateManPage, generateManPageAsync, generateManPageSync };
package/dist/index.d.cts CHANGED
@@ -1,162 +1,4 @@
1
- import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-Cc-M-Skg.cjs";
2
- import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-D0niZIHu.cjs";
3
- import { Mode, ModeValue, Parser } from "@optique/core/parser";
4
- import { Program } from "@optique/core/program";
5
-
6
- //#region src/generator.d.ts
7
-
8
- /**
9
- * Options for generating a man page from a parser.
10
- * Extends {@link ManPageOptions} with the same configuration.
11
- * @since 0.10.0
12
- */
13
- interface GenerateManPageOptions extends ManPageOptions {}
14
- /**
15
- * Options for generating a man page from a {@link Program}.
16
- *
17
- * For Program inputs, `name`, `version`, `author`, `bugs`, `examples`,
18
- * `brief`, `description`, and `footer` default to values from
19
- * `program.metadata`.
20
- * These fields are optional here and may be provided to override metadata.
21
- *
22
- * @since 0.10.0
23
- */
24
- interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "section">>, Pick<ManPageOptions, "section"> {}
25
- /**
26
- * Generates a man page from a parser synchronously.
27
- *
28
- * This function extracts documentation from the parser's structure
29
- * and formats it as a complete man page in roff format.
30
- *
31
- * @example
32
- * ```typescript
33
- * import { generateManPageSync } from "@optique/man";
34
- * import { object, option, flag } from "@optique/core/primitives";
35
- * import { string } from "@optique/core/valueparser";
36
- *
37
- * const parser = object({
38
- * verbose: flag("-v", "--verbose"),
39
- * config: option("-c", "--config", string()),
40
- * });
41
- *
42
- * const manPage = generateManPageSync(parser, {
43
- * name: "myapp",
44
- * section: 1,
45
- * version: "1.0.0",
46
- * });
47
- *
48
- * console.log(manPage);
49
- * ```
50
- *
51
- * @param parserOrProgram The parser or program to generate documentation from.
52
- * @param options The man page generation options.
53
- * @returns The complete man page in roff format.
54
- * @throws {TypeError} If the input is not a valid Parser or Program.
55
- * @since 0.10.0
56
- */
57
- declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
58
- declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
59
- /**
60
- * Generates a man page from a parser asynchronously.
61
- *
62
- * This function extracts documentation from the parser's structure
63
- * and formats it as a complete man page in roff format. It supports
64
- * both sync and async parsers.
65
- *
66
- * @example
67
- * ```typescript
68
- * import { generateManPageAsync } from "@optique/man";
69
- * import { object, option } from "@optique/core/primitives";
70
- * import { string } from "@optique/core/valueparser";
71
- *
72
- * const parser = object({
73
- * config: option("-c", "--config", string()),
74
- * });
75
- *
76
- * const manPage = await generateManPageAsync(parser, {
77
- * name: "myapp",
78
- * section: 1,
79
- * });
80
- * ```
81
- *
82
- * @param parserOrProgram The parser or program to generate documentation from.
83
- * @param options The man page generation options.
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.
86
- * @since 0.10.0
87
- */
88
- declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
89
- declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
90
- /**
91
- * Generates a man page from a parser or program.
92
- *
93
- * This function extracts documentation from the parser's structure
94
- * and formats it as a complete man page in roff format.
95
- *
96
- * For sync parsers, it returns the man page directly.
97
- * For async parsers, it returns a Promise that resolves to the man page.
98
- *
99
- * @example Parser-based API
100
- * ```typescript
101
- * import { generateManPage } from "@optique/man";
102
- * import { object, option, flag } from "@optique/core/primitives";
103
- * import { string, integer } from "@optique/core/valueparser";
104
- * import { message } from "@optique/core/message";
105
- *
106
- * const parser = object({
107
- * verbose: flag("-v", "--verbose", {
108
- * description: message`Enable verbose output.`,
109
- * }),
110
- * port: option("-p", "--port", integer(), {
111
- * description: message`Port to listen on.`,
112
- * }),
113
- * });
114
- *
115
- * const manPage = generateManPage(parser, {
116
- * name: "myapp",
117
- * section: 1,
118
- * version: "1.0.0",
119
- * date: new Date(),
120
- * author: message`Hong Minhee`,
121
- * });
122
- *
123
- * // Write to file
124
- * import { writeFileSync } from "node:fs";
125
- * writeFileSync("myapp.1", manPage);
126
- * ```
127
- *
128
- * @example Program-based API
129
- * ```typescript
130
- * import { generateManPage } from "@optique/man";
131
- * import { defineProgram } from "@optique/core/program";
132
- * import { object, flag } from "@optique/core/primitives";
133
- * import { message } from "@optique/core/message";
134
- *
135
- * const prog = defineProgram({
136
- * parser: object({
137
- * verbose: flag("-v", "--verbose"),
138
- * }),
139
- * metadata: {
140
- * name: "myapp",
141
- * version: "1.0.0",
142
- * author: message`Hong Minhee`,
143
- * },
144
- * });
145
- *
146
- * // Metadata is automatically extracted from the program
147
- * const manPage = generateManPage(prog, { section: 1 });
148
- * ```
149
- *
150
- * @param parserOrProgram The parser or program to generate documentation from.
151
- * @param options The man page generation options.
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.
154
- * @since 0.10.0
155
- */
156
- declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
157
- declare function generateManPage<T>(program: Program<"async", T>, options: GenerateManPageProgramOptions): Promise<string>;
158
- declare function generateManPage(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
159
- declare function generateManPage(parser: Parser<"async", unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
160
- declare function generateManPage<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): ModeValue<M, string>;
161
- //#endregion
1
+ import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-C3FUTPuQ.cjs";
2
+ import { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync } from "./generator-I9cXlw1Z.cjs";
3
+ import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-Cpm_FJok.cjs";
162
4
  export { type GenerateManPageOptions, type GenerateManPageProgramOptions, type ManPageOptions, type RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatDateForMan, formatDocPageAsMan, formatMessageAsRoff, formatUsageTermAsRoff, generateManPage, generateManPageAsync, generateManPageSync };
package/dist/index.d.ts CHANGED
@@ -1,162 +1,4 @@
1
- import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-BbJgRI8t.js";
2
- import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-C4QCIEKf.js";
3
- import { Program } from "@optique/core/program";
4
- import { Mode, ModeValue, Parser } from "@optique/core/parser";
5
-
6
- //#region src/generator.d.ts
7
-
8
- /**
9
- * Options for generating a man page from a parser.
10
- * Extends {@link ManPageOptions} with the same configuration.
11
- * @since 0.10.0
12
- */
13
- interface GenerateManPageOptions extends ManPageOptions {}
14
- /**
15
- * Options for generating a man page from a {@link Program}.
16
- *
17
- * For Program inputs, `name`, `version`, `author`, `bugs`, `examples`,
18
- * `brief`, `description`, and `footer` default to values from
19
- * `program.metadata`.
20
- * These fields are optional here and may be provided to override metadata.
21
- *
22
- * @since 0.10.0
23
- */
24
- interface GenerateManPageProgramOptions extends Partial<Omit<ManPageOptions, "section">>, Pick<ManPageOptions, "section"> {}
25
- /**
26
- * Generates a man page from a parser synchronously.
27
- *
28
- * This function extracts documentation from the parser's structure
29
- * and formats it as a complete man page in roff format.
30
- *
31
- * @example
32
- * ```typescript
33
- * import { generateManPageSync } from "@optique/man";
34
- * import { object, option, flag } from "@optique/core/primitives";
35
- * import { string } from "@optique/core/valueparser";
36
- *
37
- * const parser = object({
38
- * verbose: flag("-v", "--verbose"),
39
- * config: option("-c", "--config", string()),
40
- * });
41
- *
42
- * const manPage = generateManPageSync(parser, {
43
- * name: "myapp",
44
- * section: 1,
45
- * version: "1.0.0",
46
- * });
47
- *
48
- * console.log(manPage);
49
- * ```
50
- *
51
- * @param parserOrProgram The parser or program to generate documentation from.
52
- * @param options The man page generation options.
53
- * @returns The complete man page in roff format.
54
- * @throws {TypeError} If the input is not a valid Parser or Program.
55
- * @since 0.10.0
56
- */
57
- declare function generateManPageSync<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
58
- declare function generateManPageSync(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
59
- /**
60
- * Generates a man page from a parser asynchronously.
61
- *
62
- * This function extracts documentation from the parser's structure
63
- * and formats it as a complete man page in roff format. It supports
64
- * both sync and async parsers.
65
- *
66
- * @example
67
- * ```typescript
68
- * import { generateManPageAsync } from "@optique/man";
69
- * import { object, option } from "@optique/core/primitives";
70
- * import { string } from "@optique/core/valueparser";
71
- *
72
- * const parser = object({
73
- * config: option("-c", "--config", string()),
74
- * });
75
- *
76
- * const manPage = await generateManPageAsync(parser, {
77
- * name: "myapp",
78
- * section: 1,
79
- * });
80
- * ```
81
- *
82
- * @param parserOrProgram The parser or program to generate documentation from.
83
- * @param options The man page generation options.
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.
86
- * @since 0.10.0
87
- */
88
- declare function generateManPageAsync<M extends Mode, T>(program: Program<M, T>, options: GenerateManPageProgramOptions): Promise<string>;
89
- declare function generateManPageAsync<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
90
- /**
91
- * Generates a man page from a parser or program.
92
- *
93
- * This function extracts documentation from the parser's structure
94
- * and formats it as a complete man page in roff format.
95
- *
96
- * For sync parsers, it returns the man page directly.
97
- * For async parsers, it returns a Promise that resolves to the man page.
98
- *
99
- * @example Parser-based API
100
- * ```typescript
101
- * import { generateManPage } from "@optique/man";
102
- * import { object, option, flag } from "@optique/core/primitives";
103
- * import { string, integer } from "@optique/core/valueparser";
104
- * import { message } from "@optique/core/message";
105
- *
106
- * const parser = object({
107
- * verbose: flag("-v", "--verbose", {
108
- * description: message`Enable verbose output.`,
109
- * }),
110
- * port: option("-p", "--port", integer(), {
111
- * description: message`Port to listen on.`,
112
- * }),
113
- * });
114
- *
115
- * const manPage = generateManPage(parser, {
116
- * name: "myapp",
117
- * section: 1,
118
- * version: "1.0.0",
119
- * date: new Date(),
120
- * author: message`Hong Minhee`,
121
- * });
122
- *
123
- * // Write to file
124
- * import { writeFileSync } from "node:fs";
125
- * writeFileSync("myapp.1", manPage);
126
- * ```
127
- *
128
- * @example Program-based API
129
- * ```typescript
130
- * import { generateManPage } from "@optique/man";
131
- * import { defineProgram } from "@optique/core/program";
132
- * import { object, flag } from "@optique/core/primitives";
133
- * import { message } from "@optique/core/message";
134
- *
135
- * const prog = defineProgram({
136
- * parser: object({
137
- * verbose: flag("-v", "--verbose"),
138
- * }),
139
- * metadata: {
140
- * name: "myapp",
141
- * version: "1.0.0",
142
- * author: message`Hong Minhee`,
143
- * },
144
- * });
145
- *
146
- * // Metadata is automatically extracted from the program
147
- * const manPage = generateManPage(prog, { section: 1 });
148
- * ```
149
- *
150
- * @param parserOrProgram The parser or program to generate documentation from.
151
- * @param options The man page generation options.
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.
154
- * @since 0.10.0
155
- */
156
- declare function generateManPage<T>(program: Program<"sync", T>, options: GenerateManPageProgramOptions): string;
157
- declare function generateManPage<T>(program: Program<"async", T>, options: GenerateManPageProgramOptions): Promise<string>;
158
- declare function generateManPage(parser: Parser<"sync", unknown, unknown>, options: GenerateManPageOptions): string;
159
- declare function generateManPage(parser: Parser<"async", unknown, unknown>, options: GenerateManPageOptions): Promise<string>;
160
- declare function generateManPage<M extends Mode>(parser: Parser<M, unknown, unknown>, options: GenerateManPageOptions): ModeValue<M, string>;
161
- //#endregion
1
+ import { ManPageOptions, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CHYiSoI_.js";
2
+ import { GenerateManPageOptions, GenerateManPageProgramOptions, generateManPage, generateManPageAsync, generateManPageSync } from "./generator-MbR1I1SH.js";
3
+ import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-DkJvVQ1o.js";
162
4
  export { type GenerateManPageOptions, type GenerateManPageProgramOptions, type ManPageOptions, type RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatDateForMan, formatDocPageAsMan, formatMessageAsRoff, formatUsageTermAsRoff, generateManPage, generateManPageAsync, generateManPageSync };
@@ -1,5 +1,5 @@
1
- import { Message } from "@optique/core/message";
2
1
  import { DocPage, DocSection } from "@optique/core/doc";
2
+ import { Message } from "@optique/core/message";
3
3
  import { UsageTerm } from "@optique/core/usage";
4
4
 
5
5
  //#region src/man.d.ts
package/dist/man.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-D0niZIHu.cjs";
1
+ import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-C3FUTPuQ.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-C4QCIEKf.js";
1
+ import { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff } from "./man-CHYiSoI_.js";
2
2
  export { ManPageOptions, ManPageSection, formatDateForMan, formatDocPageAsMan, formatUsageTermAsRoff };
package/dist/roff.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-Cc-M-Skg.cjs";
1
+ import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-Cpm_FJok.cjs";
2
2
  export { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff };
package/dist/roff.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-BbJgRI8t.js";
1
+ import { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff } from "./roff-DkJvVQ1o.js";
2
2
  export { RoffFormatOptions, escapeHyphens, escapeQuotedValue, escapeRequestArg, escapeRoff, formatMessageAsRoff };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/man",
3
- "version": "1.1.0-dev.2096",
3
+ "version": "1.1.0-dev.2148",
4
4
  "description": "Man page generator for Optique CLI parsers",
5
5
  "keywords": [
6
6
  "CLI",
@@ -79,13 +79,19 @@
79
79
  "require": "./dist/cli.cjs"
80
80
  }
81
81
  },
82
+ "imports": {
83
+ "#src/*.ts": {
84
+ "node": "./dist/*.js",
85
+ "default": "./src/*.ts"
86
+ }
87
+ },
82
88
  "sideEffects": false,
83
89
  "bin": {
84
90
  "optique-man": "./dist/cli.js"
85
91
  },
86
92
  "dependencies": {
87
- "@optique/run": "1.1.0-dev.2096+8eda4929",
88
- "@optique/core": "1.1.0-dev.2096+8eda4929"
93
+ "@optique/core": "1.1.0-dev.2148+ab56ac96",
94
+ "@optique/run": "1.1.0-dev.2148+ab56ac96"
89
95
  },
90
96
  "devDependencies": {
91
97
  "@types/node": "^24.0.0",
@@ -96,9 +102,9 @@
96
102
  "scripts": {
97
103
  "build": "tsdown",
98
104
  "prepublish": "tsdown",
99
- "test": "node --experimental-transform-types --test 'src/**/*.test.ts'",
105
+ "test": "node --test 'src/**/*.test.ts'",
100
106
  "test:bun": "bun test src/",
101
107
  "test:deno": "deno test",
102
- "test-all": "tsdown && node --experimental-transform-types --test 'src/**/*.test.ts' && bun test src/ && deno test"
108
+ "test-all": "tsdown && node --test 'src/**/*.test.ts' && bun test src/ && deno test"
103
109
  }
104
110
  }
File without changes