politty 0.8.0 → 0.9.0

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.
Files changed (62) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/docs/index.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/{runner-D43SkHt5.js → runner-APRZYXUS.js} +74 -3
  5. package/package.json +20 -65
  6. package/dist/arg-registry-DDJpsUea.d.cts +0 -942
  7. package/dist/arg-registry-DDJpsUea.d.cts.map +0 -1
  8. package/dist/arg-registry-DDJpsUea.d.ts.map +0 -1
  9. package/dist/augment.cjs +0 -0
  10. package/dist/augment.d.cts +0 -17
  11. package/dist/augment.d.cts.map +0 -1
  12. package/dist/augment.d.ts.map +0 -1
  13. package/dist/cli.cjs +0 -54
  14. package/dist/cli.cjs.map +0 -1
  15. package/dist/cli.d.cts +0 -1
  16. package/dist/cli.js.map +0 -1
  17. package/dist/completion/index.cjs +0 -23
  18. package/dist/completion/index.d.cts +0 -3
  19. package/dist/completion-CLHO3Xaz.cjs +0 -5769
  20. package/dist/completion-CLHO3Xaz.cjs.map +0 -1
  21. package/dist/completion-DHnVx9Zk.js.map +0 -1
  22. package/dist/docs/index.cjs +0 -3127
  23. package/dist/docs/index.cjs.map +0 -1
  24. package/dist/docs/index.d.cts +0 -752
  25. package/dist/docs/index.d.cts.map +0 -1
  26. package/dist/docs/index.d.ts.map +0 -1
  27. package/dist/docs/index.js.map +0 -1
  28. package/dist/index-DKGn3lIl.d.ts.map +0 -1
  29. package/dist/index-WyViqW59.d.cts +0 -663
  30. package/dist/index-WyViqW59.d.cts.map +0 -1
  31. package/dist/index.cjs +0 -45
  32. package/dist/index.d.cts +0 -685
  33. package/dist/index.d.cts.map +0 -1
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/log-collector-DK32-73m.js.map +0 -1
  36. package/dist/log-collector-DUqC427m.cjs +0 -185
  37. package/dist/log-collector-DUqC427m.cjs.map +0 -1
  38. package/dist/prompt/clack/index.cjs +0 -33
  39. package/dist/prompt/clack/index.cjs.map +0 -1
  40. package/dist/prompt/clack/index.d.cts +0 -18
  41. package/dist/prompt/clack/index.d.cts.map +0 -1
  42. package/dist/prompt/clack/index.d.ts.map +0 -1
  43. package/dist/prompt/clack/index.js.map +0 -1
  44. package/dist/prompt/index.cjs +0 -7
  45. package/dist/prompt/index.d.cts +0 -108
  46. package/dist/prompt/index.d.cts.map +0 -1
  47. package/dist/prompt/index.d.ts.map +0 -1
  48. package/dist/prompt/inquirer/index.cjs +0 -48
  49. package/dist/prompt/inquirer/index.cjs.map +0 -1
  50. package/dist/prompt/inquirer/index.d.cts +0 -18
  51. package/dist/prompt/inquirer/index.d.cts.map +0 -1
  52. package/dist/prompt/inquirer/index.d.ts.map +0 -1
  53. package/dist/prompt/inquirer/index.js.map +0 -1
  54. package/dist/prompt-Bs9e-Em3.cjs +0 -196
  55. package/dist/prompt-Bs9e-Em3.cjs.map +0 -1
  56. package/dist/prompt-Cc8Tfmdv.js.map +0 -1
  57. package/dist/runner-D43SkHt5.js.map +0 -1
  58. package/dist/runner-DvFvokV6.cjs +0 -2865
  59. package/dist/runner-DvFvokV6.cjs.map +0 -1
  60. package/dist/schema-extractor-BxSRwLrx.cjs +0 -710
  61. package/dist/schema-extractor-BxSRwLrx.cjs.map +0 -1
  62. package/dist/schema-extractor-Dqe7_kyQ.js.map +0 -1
@@ -1,752 +0,0 @@
1
- import { C as Example, J as ResolvedFieldMeta, V as SubCommandValue, _ as AnyCommand, q as ExtractedFields, v as ArgsSchema } from "../arg-registry-DDJpsUea.cjs";
2
- import { z } from "zod";
3
- import * as fs from "node:fs";
4
-
5
- //#region src/executor/subcommand-router.d.ts
6
- /**
7
- * Resolve a lazy-loaded command (sync or async)
8
- *
9
- * @param cmd - The command or lazy loader function
10
- * @returns The resolved command
11
- */
12
- declare function resolveLazyCommand(cmd: SubCommandValue): Promise<AnyCommand>;
13
- //#endregion
14
- //#region src/docs/render-args.d.ts
15
- /**
16
- * Args shape type (Record of string keys to Zod schemas)
17
- * This matches the typical structure of `commonArgs`, `workspaceArgs`, etc.
18
- */
19
- type ArgsShape = Record<string, z.ZodType>;
20
- /**
21
- * Options for rendering args table
22
- */
23
- type ArgsTableOptions = {
24
- /** Columns to include in the table (default: all columns) */columns?: ("option" | "alias" | "description" | "required" | "default" | "env")[];
25
- };
26
- /**
27
- * Render args definition as a markdown options table
28
- *
29
- * This function takes raw args definitions (like `commonArgs`) and
30
- * renders them as a markdown table suitable for documentation.
31
- *
32
- * @example
33
- * import { renderArgsTable } from "politty/docs";
34
- * import { commonArgs, workspaceArgs } from "./args";
35
- *
36
- * const table = renderArgsTable({
37
- * ...commonArgs,
38
- * ...workspaceArgs,
39
- * });
40
- * // | Option | Alias | Description | Default |
41
- * // |--------|-------|-------------|---------|
42
- * // | `--env-file <ENV_FILE>` | `-e` | Path to environment file | - |
43
- * // ...
44
- *
45
- * @param args - Args shape (Record of string keys to Zod schemas with arg() metadata)
46
- * @param options - Rendering options
47
- * @returns Rendered markdown table string
48
- */
49
- declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
50
- //#endregion
51
- //#region src/docs/types.d.ts
52
- /** Heading level for markdown headings (1-6) */
53
- type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
54
- /**
55
- * Options for rendering command index
56
- */
57
- type CommandIndexOptions = {
58
- /** Base heading level (default: 3, which renders as ###) */headingLevel?: HeadingLevel; /** Only include leaf commands (commands without subcommands). Default: true */
59
- leafOnly?: boolean;
60
- };
61
- /**
62
- * Command information for rendering
63
- */
64
- interface CommandInfo {
65
- /** Command name */
66
- name: string;
67
- /** Command description */
68
- description?: string | undefined;
69
- /** Alternative names (aliases) for this command */
70
- aliases?: string[] | undefined;
71
- /** Full command path (e.g., "my-cli config get") */
72
- fullCommandPath: string;
73
- /** Command path relative to root (e.g., "" for root, "config" for subcommand) */
74
- commandPath: string;
75
- /** Command depth (1 for root commands, 2 for subcommands, etc.) */
76
- depth: number;
77
- /** Positional arguments */
78
- positionalArgs: ResolvedFieldMeta[];
79
- /** Options (non-positional arguments) */
80
- options: ResolvedFieldMeta[];
81
- /** Subcommand information */
82
- subCommands: SubCommandInfo[];
83
- /** Extracted field information from schema */
84
- extracted: ExtractedFields | null;
85
- /** Original command object */
86
- command: AnyCommand;
87
- /** Additional notes */
88
- notes?: string | undefined;
89
- /** File path where this command is rendered (for cross-file links) */
90
- filePath?: string | undefined;
91
- /** Map of command path to file path (for cross-file links) */
92
- fileMap?: Record<string, string> | undefined;
93
- /** Example definitions from command */
94
- examples?: Example[] | undefined;
95
- /** Example execution results (populated when examples are executed) */
96
- exampleResults?: ExampleExecutionResult[] | undefined;
97
- /** Path to root document file (for global options link generation) */
98
- rootDocPath?: string | undefined;
99
- /** Whether global options exist (for global options link generation) */
100
- hasGlobalOptions?: boolean;
101
- }
102
- /**
103
- * Subcommand information
104
- */
105
- interface SubCommandInfo {
106
- /** Subcommand name */
107
- name: string;
108
- /** Subcommand description */
109
- description?: string | undefined;
110
- /** Alternative names (aliases) for this subcommand */
111
- aliases?: string[] | undefined;
112
- /** Full command path */
113
- fullPath: string[];
114
- }
115
- /**
116
- * Example execution result
117
- */
118
- interface ExampleExecutionResult {
119
- /** Command arguments that were executed */
120
- cmd: string;
121
- /** Description of the example */
122
- desc: string;
123
- /** Expected output (if defined in example) */
124
- expectedOutput?: string | undefined;
125
- /** Captured stdout */
126
- stdout: string;
127
- /** Captured stderr */
128
- stderr: string;
129
- /** Whether execution was successful */
130
- success: boolean;
131
- }
132
- /**
133
- * Example execution config for a specific command path
134
- * If a command path is specified in ExampleConfig, its examples will be executed
135
- */
136
- interface ExampleCommandConfig {
137
- /** Mock setup before running examples */
138
- mock?: () => void | Promise<void>;
139
- /** Mock cleanup after running examples */
140
- cleanup?: () => void | Promise<void>;
141
- }
142
- /**
143
- * Example execution configuration
144
- * Key is command path (e.g., "", "config", "config get")
145
- * All specified command paths will have their examples executed
146
- *
147
- * @example
148
- * // With mock setup
149
- * { "": { mock: () => mockFs(), cleanup: () => restoreFs() } }
150
- *
151
- * // Without mock (just execute)
152
- * { "user": true }
153
- */
154
- type ExampleConfig = Record<string, ExampleCommandConfig | true>;
155
- /**
156
- * Render function type for custom markdown generation
157
- */
158
- type RenderFunction = (info: CommandInfo) => string;
159
- /**
160
- * Section render function type (legacy)
161
- * @param defaultContent - The default rendered content for this section
162
- * @param info - Command information
163
- * @returns The final content to render (return empty string to hide section)
164
- * @deprecated Use context-based render functions instead
165
- */
166
- type SectionRenderFunction = (defaultContent: string, info: CommandInfo) => string;
167
- /**
168
- * Render options for options/arguments
169
- */
170
- interface RenderContentOptions {
171
- /** Style for rendering */
172
- style?: "table" | "list";
173
- /** Include heading (default: true) */
174
- withHeading?: boolean;
175
- }
176
- /**
177
- * Options render context
178
- */
179
- interface OptionsRenderContext {
180
- /** Options to render */
181
- options: ResolvedFieldMeta[];
182
- /** Render function that accepts options and optional rendering options */
183
- render: (options: ResolvedFieldMeta[], opts?: RenderContentOptions) => string;
184
- /** Heading prefix (e.g., "###") */
185
- heading: string;
186
- /** Command information */
187
- info: CommandInfo;
188
- }
189
- type OptionsRenderFunction = (context: OptionsRenderContext) => string;
190
- /**
191
- * Arguments render context
192
- */
193
- interface ArgumentsRenderContext {
194
- /** Arguments to render */
195
- args: ResolvedFieldMeta[];
196
- /** Render function that accepts arguments and optional rendering options */
197
- render: (args: ResolvedFieldMeta[], opts?: RenderContentOptions) => string;
198
- /** Heading prefix (e.g., "###") */
199
- heading: string;
200
- /** Command information */
201
- info: CommandInfo;
202
- }
203
- type ArgumentsRenderFunction = (context: ArgumentsRenderContext) => string;
204
- /**
205
- * Subcommands render options
206
- */
207
- interface SubcommandsRenderOptions {
208
- /** Generate anchor links */
209
- generateAnchors?: boolean;
210
- /** Include heading (default: true) */
211
- withHeading?: boolean;
212
- }
213
- /**
214
- * Subcommands render context
215
- */
216
- interface SubcommandsRenderContext {
217
- /** Subcommands to render */
218
- subcommands: SubCommandInfo[];
219
- /** Render function that accepts subcommands and optional rendering options */
220
- render: (subcommands: SubCommandInfo[], opts?: SubcommandsRenderOptions) => string;
221
- /** Heading prefix (e.g., "###") */
222
- heading: string;
223
- /** Command information */
224
- info: CommandInfo;
225
- }
226
- type SubcommandsRenderFunction = (context: SubcommandsRenderContext) => string;
227
- /**
228
- * Examples render options
229
- */
230
- interface ExamplesRenderOptions {
231
- /** Include heading (default: true) */
232
- withHeading?: boolean;
233
- /** Show execution output (default: true when results available) */
234
- showOutput?: boolean;
235
- /** Command prefix to prepend to example commands (e.g., "my-cli config get") */
236
- commandPrefix?: string;
237
- }
238
- /**
239
- * Examples render context
240
- */
241
- interface ExamplesRenderContext {
242
- /** Examples to render */
243
- examples: Example[];
244
- /** Execution results (if examples were executed) */
245
- results?: ExampleExecutionResult[] | undefined;
246
- /** Render function that accepts examples, results, and optional rendering options */
247
- render: (examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions) => string;
248
- /** Heading prefix (e.g., "###") */
249
- heading: string;
250
- /** Command information */
251
- info: CommandInfo;
252
- }
253
- type ExamplesRenderFunction = (context: ExamplesRenderContext) => string;
254
- /**
255
- * Simple section render context (for description, usage, notes, footer)
256
- */
257
- interface SimpleRenderContext {
258
- /** Default content */
259
- content: string;
260
- /** Heading prefix (e.g., "###") */
261
- heading: string;
262
- /** Command information */
263
- info: CommandInfo;
264
- }
265
- type SimpleRenderFunction = (context: SimpleRenderContext) => string;
266
- /**
267
- * Default renderer customization options
268
- */
269
- interface DefaultRendererOptions {
270
- /** Heading level (default: 1) */
271
- headingLevel?: HeadingLevel;
272
- /** Option display style */
273
- optionStyle?: "table" | "list";
274
- /** Generate anchor links to subcommands */
275
- generateAnchors?: boolean;
276
- /** Include subcommand details */
277
- includeSubcommandDetails?: boolean;
278
- /**
279
- * Omit the `<!-- politty:...:start/end -->` section markers from the rendered
280
- * output. Used by marker-free `files` generation. When markers are omitted the
281
- * output can only be regenerated wholesale (sections can no longer be located
282
- * and updated in place), which is exactly how marker-free `files` mode works.
283
- */
284
- markerless?: boolean;
285
- /** Custom renderer for description section */
286
- renderDescription?: SimpleRenderFunction;
287
- /** Custom renderer for usage section */
288
- renderUsage?: SimpleRenderFunction;
289
- /** Custom renderer for arguments section */
290
- renderArguments?: ArgumentsRenderFunction;
291
- /** Custom renderer for options section */
292
- renderOptions?: OptionsRenderFunction;
293
- /** Custom renderer for subcommands section */
294
- renderSubcommands?: SubcommandsRenderFunction;
295
- /** Custom renderer for notes section */
296
- renderNotes?: SimpleRenderFunction;
297
- /** Custom renderer for footer (default content is empty) */
298
- renderFooter?: SimpleRenderFunction;
299
- /** Custom renderer for examples section */
300
- renderExamples?: ExamplesRenderFunction;
301
- }
302
- /**
303
- * Root document configuration
304
- * The root document contains global options tables and command index sections.
305
- */
306
- interface RootDocConfig {
307
- /** Output file path */
308
- path: string;
309
- /**
310
- * Global options configuration.
311
- * ArgsShape directly, or { args, options } for render options.
312
- */
313
- globalOptions?: ArgsShape | {
314
- args: ArgsShape;
315
- options?: ArgsTableOptions;
316
- };
317
- /** Heading level for the file header (default: 1) */
318
- headingLevel?: HeadingLevel;
319
- /** Index section rendering options */
320
- index?: CommandIndexOptions;
321
- }
322
- /**
323
- * Root command customization for the root document.
324
- * Controls the root document's title, description, header, and footer.
325
- */
326
- interface RootCommandInfo {
327
- /** Title (defaults to command.name) */
328
- title?: string;
329
- /** Description (defaults to command.description) */
330
- description?: string;
331
- /** Markdown placed after title/description */
332
- header?: string;
333
- /** Markdown placed at end of document */
334
- footer?: string;
335
- }
336
- /**
337
- * Path configuration for documentation output.
338
- * Simpler alternative to FileMapping for common patterns.
339
- *
340
- * @example
341
- * // All commands in one file
342
- * path: "docs/CLI.md"
343
- *
344
- * // Split files: root + specific commands in separate files
345
- * path: { root: "docs/CLI.md", commands: { "build": "docs/build.md" } }
346
- */
347
- type PathConfig = string | {
348
- root: string;
349
- commands?: Record<string, string>;
350
- };
351
- /**
352
- * Per-file configuration with custom renderer
353
- */
354
- interface FileConfig {
355
- /** Command paths to include in this file (e.g., ["", "user", "config get"]) */
356
- commands: string[];
357
- /** Custom renderer for this file (optional) */
358
- render?: RenderFunction;
359
- /** File title (prepended to the file content) */
360
- title?: string;
361
- /** File description (added after title) */
362
- description?: string;
363
- /** Skip subcommand expansion (commands are used as-is). @internal */
364
- noExpand?: boolean;
365
- }
366
- /**
367
- * File mapping configuration
368
- * Key: output file path (e.g., "docs/cli.md")
369
- * Value: command paths array or FileConfig object
370
- *
371
- * @example
372
- * // Simple: single file with multiple commands
373
- * { "docs/cli.md": ["", "user", "config"] }
374
- *
375
- * // With custom renderer
376
- * { "docs/cli.md": { commands: [""], render: customRenderer } }
377
- */
378
- type FileMapping = Record<string, string[] | FileConfig>;
379
- /**
380
- * generateDoc configuration
381
- */
382
- interface GenerateDocConfig {
383
- /** Command to generate documentation for */
384
- command: AnyCommand;
385
- /**
386
- * Root document configuration.
387
- * The root document contains global options tables and command index sections.
388
- * Title and description are derived from `command.name` and `command.description`.
389
- */
390
- rootDoc?: RootDocConfig;
391
- /**
392
- * Path configuration (simpler alternative to files).
393
- * Mutually exclusive with `files`.
394
- */
395
- path?: PathConfig;
396
- /** File output configuration (command path -> file mapping) */
397
- files?: FileMapping;
398
- /** Root command customization (title, description, header, footer) */
399
- rootInfo?: RootCommandInfo;
400
- /** Command paths to ignore (including their subcommands) */
401
- ignores?: string[];
402
- /** Default renderer options (used when render is not specified per file) */
403
- format?: DefaultRendererOptions;
404
- /** Formatter function to apply to generated content before comparison */
405
- formatter?: FormatterFunction;
406
- /** Example execution configuration (per command path) */
407
- examples?: ExampleConfig;
408
- /**
409
- * Target command paths to validate (e.g., ["read", "config get"])
410
- * When specified, only these commands' sections are validated.
411
- * The full document structure is used to maintain cross-file links.
412
- */
413
- targetCommands?: string[];
414
- /**
415
- * Global args schema (runtime schema alternative).
416
- * When provided, automatically derives `rootDoc.globalOptions` from this schema.
417
- */
418
- globalArgs?: ArgsSchema;
419
- /**
420
- * Template-based generation: output file path -> template file path.
421
- * The template mixes handwritten markdown with {{politty:...}} placeholders.
422
- * The output file is fully generated from the template and contains no
423
- * politty markers. Can be combined with `files` or `path`.
424
- */
425
- templates?: Record<string, string>;
426
- /**
427
- * Declare that you will hand-customize the `files` output.
428
- *
429
- * Default `false`: the output is fully generated and regenerated wholesale on
430
- * every run (with `targetCommands`, only files containing a target command are
431
- * regenerated, but each such file is rebuilt in full). The output carries no
432
- * `<!-- politty:...:start/end -->` markers — do not hand-edit it.
433
- *
434
- * Set to `true` when you want to hand-edit the output and have politty preserve
435
- * your edits: generated sections are wrapped in markers and updated in place
436
- * (with `targetCommands`), and handwritten content between them is kept. When a
437
- * command in the generated output gains a section the file does not yet have,
438
- * it is reported as a non-fatal warning (run with `POLITTY_DOCS_DOCTOR=true
439
- * POLITTY_DOCS_UPDATE=true` to insert it, or leave it removed to opt that
440
- * section out).
441
- *
442
- * This flag does not affect `path`/`rootDoc` output, which always uses markers
443
- * to inject generated sections into a handwritten file, nor `templates`, which
444
- * are always fully generated.
445
- */
446
- customizable?: boolean;
447
- }
448
- /**
449
- * generateDoc result
450
- */
451
- interface GenerateDocResult {
452
- /** Whether all files matched or were updated successfully */
453
- success: boolean;
454
- /** File processing results */
455
- files: Array<{
456
- /** File path */path: string; /** Status of this file */
457
- status: "match" | "created" | "updated" | "diff"; /** Diff content (only when status is "diff") */
458
- diff?: string | undefined;
459
- }>;
460
- /** Error message (when success is false) */
461
- error?: string | undefined;
462
- }
463
- /**
464
- * Formatter function type
465
- * Formats generated content before comparison
466
- */
467
- type FormatterFunction = (content: string) => string | Promise<string>;
468
- /**
469
- * Environment variable name for update mode
470
- */
471
- declare const UPDATE_GOLDEN_ENV = "POLITTY_DOCS_UPDATE";
472
- /**
473
- * Environment variable name for doctor mode.
474
- * When enabled alone, detects and reports missing section markers (read-only).
475
- * When combined with POLITTY_DOCS_UPDATE=true, auto-inserts missing markers.
476
- */
477
- declare const DOCTOR_ENV = "POLITTY_DOCS_DOCTOR";
478
- /**
479
- * All section types in rendering order
480
- */
481
- declare const SECTION_TYPES: readonly ["heading", "description", "usage", "arguments", "options", "global-options-link", "subcommands", "examples", "notes"];
482
- /**
483
- * Section types for command documentation markers
484
- */
485
- type SectionType = (typeof SECTION_TYPES)[number];
486
- /**
487
- * Marker prefix for command section markers in generated documentation
488
- * Format: <!-- politty:command:<scope>:<type>:start --> ... <!-- politty:command:<scope>:<type>:end -->
489
- */
490
- declare const SECTION_MARKER_PREFIX = "politty:command";
491
- /**
492
- * Generate start marker for a command section
493
- */
494
- declare function sectionStartMarker(type: SectionType, scope: string): string;
495
- /**
496
- * Generate end marker for a command section
497
- */
498
- declare function sectionEndMarker(type: SectionType, scope: string): string;
499
- /**
500
- * Marker prefix for global options sections in generated documentation
501
- * Format: <!-- politty:global-options:start --> ... <!-- politty:global-options:end -->
502
- */
503
- declare const GLOBAL_OPTIONS_MARKER_PREFIX = "politty:global-options";
504
- /**
505
- * Generate start marker for a global options section
506
- */
507
- declare function globalOptionsStartMarker(): string;
508
- /**
509
- * Generate end marker for a global options section
510
- */
511
- declare function globalOptionsEndMarker(): string;
512
- /**
513
- * Marker prefix for root header sections in generated documentation
514
- */
515
- declare const ROOT_HEADER_MARKER_PREFIX = "politty:root-header";
516
- declare function rootHeaderStartMarker(): string;
517
- declare function rootHeaderEndMarker(): string;
518
- /**
519
- * Marker prefix for root footer sections in generated documentation
520
- */
521
- declare const ROOT_FOOTER_MARKER_PREFIX = "politty:root-footer";
522
- declare function rootFooterStartMarker(): string;
523
- declare function rootFooterEndMarker(): string;
524
- /**
525
- * Marker prefix for index sections in generated documentation
526
- * Format: <!-- politty:index:<scope>:start --> ... <!-- politty:index:<scope>:end -->
527
- */
528
- declare const INDEX_MARKER_PREFIX = "politty:index";
529
- /**
530
- * Generate start marker for an index section
531
- */
532
- declare function indexStartMarker(scope: string): string;
533
- /**
534
- * Generate end marker for an index section
535
- */
536
- declare function indexEndMarker(scope: string): string;
537
- //#endregion
538
- //#region src/docs/default-renderers.d.ts
539
- /**
540
- * Render usage line
541
- */
542
- declare function renderUsage(info: CommandInfo): string;
543
- /**
544
- * Render arguments as table
545
- */
546
- declare function renderArgumentsTable(info: CommandInfo): string;
547
- /**
548
- * Render arguments as list
549
- */
550
- declare function renderArgumentsList(info: CommandInfo): string;
551
- /**
552
- * Render options as markdown table
553
- *
554
- * Features:
555
- * - Uses kebab-case (cliName) for option names (e.g., `--dry-run` instead of `--dryRun`)
556
- * - Automatically adds Env column when any option has env configured
557
- * - Displays multiple env vars as comma-separated list
558
- *
559
- * @example
560
- * | Option | Alias | Description | Required | Default | Env |
561
- * |--------|-------|-------------|----------|---------|-----|
562
- * | `--dry-run` | `-d` | Dry run mode | No | `false` | - |
563
- * | `--port <PORT>` | - | Server port | Yes | - | `PORT`, `SERVER_PORT` |
564
- */
565
- declare function renderOptionsTable(info: CommandInfo): string;
566
- /**
567
- * Render options as markdown list
568
- *
569
- * Features:
570
- * - Uses kebab-case (cliName) for option names (e.g., `--dry-run` instead of `--dryRun`)
571
- * - Appends env info at the end of each option (e.g., `[env: PORT, SERVER_PORT]`)
572
- *
573
- * @example
574
- * - `-d`, `--dry-run` - Dry run mode (default: false)
575
- * - `--port <PORT>` - Server port (required) [env: PORT, SERVER_PORT]
576
- */
577
- declare function renderOptionsList(info: CommandInfo): string;
578
- /**
579
- * Render subcommands as table
580
- */
581
- declare function renderSubcommandsTable(info: CommandInfo, generateAnchors?: boolean): string;
582
- /**
583
- * Render options from array as table
584
- */
585
- declare function renderOptionsTableFromArray(options: ResolvedFieldMeta[]): string;
586
- /**
587
- * Render options from array as list
588
- */
589
- declare function renderOptionsListFromArray(options: ResolvedFieldMeta[]): string;
590
- /**
591
- * Render arguments from array as table
592
- */
593
- declare function renderArgumentsTableFromArray(args: ResolvedFieldMeta[]): string;
594
- /**
595
- * Render arguments from array as list
596
- */
597
- declare function renderArgumentsListFromArray(args: ResolvedFieldMeta[]): string;
598
- /**
599
- * Render subcommands from array as table
600
- */
601
- declare function renderSubcommandsTableFromArray(subcommands: SubCommandInfo[], info: CommandInfo, generateAnchors?: boolean): string;
602
- /**
603
- * Render examples as markdown
604
- *
605
- * @example
606
- * **Basic usage**
607
- *
608
- * ```bash
609
- * $ greet World
610
- * ```
611
- *
612
- * Output:
613
- * ```
614
- * Hello, World!
615
- * ```
616
- */
617
- declare function renderExamplesDefault(examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions): string;
618
- declare function createCommandRenderer(options?: DefaultRendererOptions): RenderFunction;
619
- /**
620
- * Default renderers presets
621
- */
622
- declare const defaultRenderers: {
623
- /** Standard command documentation */command: (options?: DefaultRendererOptions) => RenderFunction; /** Table style options (default) */
624
- tableStyle: RenderFunction; /** List style options */
625
- listStyle: RenderFunction;
626
- };
627
- //#endregion
628
- //#region src/docs/doc-comparator.d.ts
629
- /**
630
- * Comparison result
631
- */
632
- interface CompareResult {
633
- /** Whether the content matches */
634
- match: boolean;
635
- /** Diff content (only when match is false) */
636
- diff?: string;
637
- /** Whether the file exists */
638
- fileExists: boolean;
639
- }
640
- /**
641
- * Compare generated content with existing file
642
- */
643
- declare function compareWithExisting(generatedContent: string, filePath: string): CompareResult;
644
- /**
645
- * Format diff between two strings in unified diff format
646
- */
647
- declare function formatDiff(expected: string, actual: string): string;
648
- /**
649
- * Write content to file, creating directories if needed
650
- */
651
- declare function writeFile(filePath: string, content: string): void;
652
- /**
653
- * Minimal fs interface for deleteFile
654
- */
655
- interface DeleteFileFs {
656
- existsSync: typeof fs.existsSync;
657
- unlinkSync: typeof fs.unlinkSync;
658
- }
659
- //#endregion
660
- //#region src/docs/doc-generator.d.ts
661
- /**
662
- * Build CommandInfo from a command
663
- */
664
- declare function buildCommandInfo(command: AnyCommand, rootName: string, commandPath?: string[]): Promise<CommandInfo>;
665
- /**
666
- * Collect all commands with their paths
667
- * Returns a map of command path -> CommandInfo
668
- */
669
- declare function collectAllCommands(command: AnyCommand, rootName?: string): Promise<Map<string, CommandInfo>>;
670
- //#endregion
671
- //#region src/docs/example-executor.d.ts
672
- /**
673
- * Execute examples for a command and capture output
674
- *
675
- * @param examples - Examples to execute
676
- * @param config - Execution configuration (mock setup/cleanup)
677
- * @param rootCommand - Root command to execute against
678
- * @param commandPath - Command path for subcommands (e.g., ["config", "get"])
679
- * @returns Array of execution results with captured stdout/stderr
680
- */
681
- declare function executeExamples(examples: Example[], config: ExampleCommandConfig, rootCommand: AnyCommand, commandPath?: string[]): Promise<ExampleExecutionResult[]>;
682
- //#endregion
683
- //#region src/docs/golden-test.d.ts
684
- /**
685
- * Generate documentation from command definition
686
- */
687
- declare function generateDoc(config: GenerateDocConfig): Promise<GenerateDocResult>;
688
- /**
689
- * Assert that documentation matches golden files
690
- * Throws an error if there are differences and update mode is not enabled
691
- */
692
- declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
693
- /**
694
- * Initialize documentation files by deleting them
695
- * Only deletes when update mode is enabled (POLITTY_DOCS_UPDATE=true)
696
- * Use this in beforeAll to ensure skipped tests don't leave stale sections
697
- * @param config - Config containing files to initialize, or a single file path
698
- * @param fileSystem - Optional fs implementation (useful when fs is mocked)
699
- */
700
- declare function initDocFile(config: Pick<GenerateDocConfig, "files" | "templates" | "rootDoc"> | string, fileSystem?: DeleteFileFs): void;
701
- //#endregion
702
- //#region src/docs/render-index.d.ts
703
- /**
704
- * Configuration for a command category
705
- */
706
- type CommandCategory = {
707
- /** Category title (e.g., "Application Commands") */title: string; /** Category description */
708
- description: string; /** Command paths to include (parent commands will auto-expand to leaf commands) */
709
- commands: string[]; /** Optional post-expansion allowlist, used when a caller has already applied ignores */
710
- allowedCommands?: string[]; /** Path to documentation file for links (e.g., "./cli/application.md") */
711
- docPath: string;
712
- /**
713
- * When true, `commands` are used verbatim as index rows without expanding
714
- * parent commands to their leaf subcommands. Used for template-derived
715
- * categories where only explicitly rendered scopes have headings.
716
- */
717
- noExpand?: boolean;
718
- };
719
- /**
720
- * Render command index from categories
721
- *
722
- * Generates a category-based index of commands with links to documentation.
723
- *
724
- * @example
725
- * const categories: CommandCategory[] = [
726
- * {
727
- * title: "Application Commands",
728
- * description: "Commands for managing applications.",
729
- * commands: ["init", "generate", "apply"],
730
- * docPath: "./cli/application.md",
731
- * },
732
- * ];
733
- *
734
- * const index = await renderCommandIndex(mainCommand, categories);
735
- * // ### [Application Commands](./cli/application.md)
736
- * //
737
- * // Commands for managing applications.
738
- * //
739
- * // | Command | Description |
740
- * // |---------|-------------|
741
- * // | [init](./cli/application.md#init) | Initialize a project |
742
- * // ...
743
- *
744
- * @param command - Root command to extract command information from
745
- * @param categories - Category definitions for grouping commands
746
- * @param options - Rendering options
747
- * @returns Rendered markdown string
748
- */
749
- declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
750
- //#endregion
751
- export { type ArgsShape, type ArgsTableOptions, type ArgumentsRenderContext, type ArgumentsRenderFunction, type CommandCategory, type CommandIndexOptions, type CommandInfo, DOCTOR_ENV, type DefaultRendererOptions, type DeleteFileFs, type ExampleCommandConfig, type ExampleConfig, type ExampleExecutionResult, type ExamplesRenderContext, type ExamplesRenderFunction, type ExamplesRenderOptions, type FileConfig, type FileMapping, type FormatterFunction, GLOBAL_OPTIONS_MARKER_PREFIX, type GenerateDocConfig, type GenerateDocResult, type HeadingLevel, INDEX_MARKER_PREFIX, type OptionsRenderContext, type OptionsRenderFunction, type PathConfig, ROOT_FOOTER_MARKER_PREFIX, ROOT_HEADER_MARKER_PREFIX, type RenderContentOptions, type RenderFunction, type RootCommandInfo, type RootDocConfig, SECTION_MARKER_PREFIX, SECTION_TYPES, type SectionRenderFunction, type SectionType, type SimpleRenderContext, type SimpleRenderFunction, type SubCommandInfo, type SubcommandsRenderContext, type SubcommandsRenderFunction, type SubcommandsRenderOptions, UPDATE_GOLDEN_ENV, assertDocMatch, buildCommandInfo, collectAllCommands, compareWithExisting, createCommandRenderer, defaultRenderers, executeExamples, formatDiff, generateDoc, globalOptionsEndMarker, globalOptionsStartMarker, indexEndMarker, indexStartMarker, initDocFile, renderArgsTable, renderArgumentsList, renderArgumentsListFromArray, renderArgumentsTable, renderArgumentsTableFromArray, renderCommandIndex, renderExamplesDefault, renderOptionsList, renderOptionsListFromArray, renderOptionsTable, renderOptionsTableFromArray, renderSubcommandsTable, renderSubcommandsTableFromArray, renderUsage, resolveLazyCommand, rootFooterEndMarker, rootFooterStartMarker, rootHeaderEndMarker, rootHeaderStartMarker, sectionEndMarker, sectionStartMarker, writeFile };
752
- //# sourceMappingURL=index.d.cts.map