politty 0.1.1 → 0.2.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.
- package/dist/{arg-registry-D4NsqcNZ.d.ts → arg-registry-i6SA4l-E.d.cts} +1 -2
- package/dist/arg-registry-i6SA4l-E.d.cts.map +1 -0
- package/dist/{arg-registry-ClI2WGgH.d.cts → arg-registry-w5mMKJkZ.d.ts} +1 -2
- package/dist/arg-registry-w5mMKJkZ.d.ts.map +1 -0
- package/dist/augment.d.cts +1 -2
- package/dist/augment.d.cts.map +1 -1
- package/dist/augment.d.ts +1 -2
- package/dist/augment.d.ts.map +1 -1
- package/dist/{command-CvKyk4ag.js → command-DCpFEZFM.js} +1 -1
- package/dist/{command-CvKyk4ag.js.map → command-DCpFEZFM.js.map} +1 -1
- package/dist/completion/index.cjs +1 -1
- package/dist/completion/index.cjs.map +1 -1
- package/dist/completion/index.d.cts +1 -3
- package/dist/completion/index.d.cts.map +1 -1
- package/dist/completion/index.d.ts +1 -3
- package/dist/completion/index.d.ts.map +1 -1
- package/dist/completion/index.js +3 -3
- package/dist/completion/index.js.map +1 -1
- package/dist/docs/index.cjs +252 -26
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +95 -13
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +95 -13
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +269 -45
- package/dist/docs/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/runner-BkhekqT9.cjs +4 -0
- package/dist/{runner-DceWXOwD.js → runner-CyxuNkT1.js} +18 -18
- package/dist/runner-CyxuNkT1.js.map +1 -0
- package/dist/runner-DzzbIwEy.js +4 -0
- package/dist/{runner-BZuYiRhi.cjs → runner-ttyvfYGi.cjs} +16 -16
- package/dist/runner-ttyvfYGi.cjs.map +1 -0
- package/dist/schema-extractor-B9D3Rf22.cjs.map +1 -1
- package/dist/{schema-extractor-kkajLb9E.d.ts → schema-extractor-CXeUTW_Z.d.cts} +1 -2
- package/dist/schema-extractor-CXeUTW_Z.d.cts.map +1 -0
- package/dist/{schema-extractor-D-Eo7I77.d.cts → schema-extractor-Cl_D04BX.d.ts} +1 -2
- package/dist/schema-extractor-Cl_D04BX.d.ts.map +1 -0
- package/dist/{schema-extractor-Dk5Z0Iei.js → schema-extractor-D0q5Fj2R.js} +1 -1
- package/dist/schema-extractor-D0q5Fj2R.js.map +1 -0
- package/dist/{subcommand-router-BiSvDXHg.js → subcommand-router-D9QSLX56.js} +1 -1
- package/dist/subcommand-router-D9QSLX56.js.map +1 -0
- package/dist/subcommand-router-Vf-0w9P4.cjs.map +1 -1
- package/package.json +13 -13
- package/dist/arg-registry-ClI2WGgH.d.cts.map +0 -1
- package/dist/arg-registry-D4NsqcNZ.d.ts.map +0 -1
- package/dist/runner-BZuYiRhi.cjs.map +0 -1
- package/dist/runner-D2BXiWtg.cjs +0 -4
- package/dist/runner-DceWXOwD.js.map +0 -1
- package/dist/runner-KCql2UKz.js +0 -4
- package/dist/schema-extractor-D-Eo7I77.d.cts.map +0 -1
- package/dist/schema-extractor-Dk5Z0Iei.js.map +0 -1
- package/dist/schema-extractor-kkajLb9E.d.ts.map +0 -1
- package/dist/subcommand-router-BiSvDXHg.js.map +0 -1
package/dist/docs/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as ResolvedFieldMeta, p as Example, s as AnyCommand, t as ExtractedFields } from "../schema-extractor-
|
|
1
|
+
import { n as ResolvedFieldMeta, p as Example, s as AnyCommand, t as ExtractedFields } from "../schema-extractor-CXeUTW_Z.cjs";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import * as fs from "node:fs";
|
|
3
4
|
|
|
4
5
|
//#region src/executor/subcommand-router.d.ts
|
|
5
|
-
|
|
6
6
|
/**
|
|
7
7
|
* Resolve a lazy-loaded command (sync or async)
|
|
8
8
|
*
|
|
@@ -178,6 +178,8 @@ interface ExamplesRenderOptions {
|
|
|
178
178
|
withHeading?: boolean;
|
|
179
179
|
/** Show execution output (default: true when results available) */
|
|
180
180
|
showOutput?: boolean;
|
|
181
|
+
/** Command prefix to prepend to example commands (e.g., "my-cli config get") */
|
|
182
|
+
commandPrefix?: string;
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
183
185
|
* Examples render context
|
|
@@ -293,11 +295,8 @@ interface GenerateDocResult {
|
|
|
293
295
|
success: boolean;
|
|
294
296
|
/** File processing results */
|
|
295
297
|
files: Array<{
|
|
296
|
-
/** File path */
|
|
297
|
-
|
|
298
|
-
/** Status of this file */
|
|
299
|
-
status: "match" | "created" | "updated" | "diff";
|
|
300
|
-
/** Diff content (only when status is "diff") */
|
|
298
|
+
/** File path */path: string; /** Status of this file */
|
|
299
|
+
status: "match" | "created" | "updated" | "diff"; /** Diff content (only when status is "diff") */
|
|
301
300
|
diff?: string | undefined;
|
|
302
301
|
}>;
|
|
303
302
|
/** Error message (when success is false) */
|
|
@@ -414,11 +413,8 @@ declare function createCommandRenderer(options?: DefaultRendererOptions): Render
|
|
|
414
413
|
* Default renderers presets
|
|
415
414
|
*/
|
|
416
415
|
declare const defaultRenderers: {
|
|
417
|
-
/** Standard command documentation */
|
|
418
|
-
|
|
419
|
-
/** Table style options (default) */
|
|
420
|
-
tableStyle: RenderFunction;
|
|
421
|
-
/** List style options */
|
|
416
|
+
/** Standard command documentation */command: (options?: DefaultRendererOptions) => RenderFunction; /** Table style options (default) */
|
|
417
|
+
tableStyle: RenderFunction; /** List style options */
|
|
422
418
|
listStyle: RenderFunction;
|
|
423
419
|
};
|
|
424
420
|
//#endregion
|
|
@@ -496,5 +492,91 @@ declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
|
|
|
496
492
|
*/
|
|
497
493
|
declare function initDocFile(config: Pick<GenerateDocConfig, "files"> | string, fileSystem?: DeleteFileFs): void;
|
|
498
494
|
//#endregion
|
|
499
|
-
|
|
495
|
+
//#region src/docs/render-args.d.ts
|
|
496
|
+
/**
|
|
497
|
+
* Args shape type (Record of string keys to Zod schemas)
|
|
498
|
+
* This matches the typical structure of `commonArgs`, `workspaceArgs`, etc.
|
|
499
|
+
*/
|
|
500
|
+
type ArgsShape = Record<string, z.ZodType>;
|
|
501
|
+
/**
|
|
502
|
+
* Options for rendering args table
|
|
503
|
+
*/
|
|
504
|
+
type ArgsTableOptions = {
|
|
505
|
+
/** Columns to include in the table (default: all columns) */columns?: ("option" | "alias" | "description" | "default" | "env")[];
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Render args definition as a markdown options table
|
|
509
|
+
*
|
|
510
|
+
* This function takes raw args definitions (like `commonArgs`) and
|
|
511
|
+
* renders them as a markdown table suitable for documentation.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* import { renderArgsTable } from "politty/docs";
|
|
515
|
+
* import { commonArgs, workspaceArgs } from "./args";
|
|
516
|
+
*
|
|
517
|
+
* const table = renderArgsTable({
|
|
518
|
+
* ...commonArgs,
|
|
519
|
+
* ...workspaceArgs,
|
|
520
|
+
* });
|
|
521
|
+
* // | Option | Alias | Description | Default |
|
|
522
|
+
* // |--------|-------|-------------|---------|
|
|
523
|
+
* // | `--env-file <ENV_FILE>` | `-e` | Path to environment file | - |
|
|
524
|
+
* // ...
|
|
525
|
+
*
|
|
526
|
+
* @param args - Args shape (Record of string keys to Zod schemas with arg() metadata)
|
|
527
|
+
* @param options - Rendering options
|
|
528
|
+
* @returns Rendered markdown table string
|
|
529
|
+
*/
|
|
530
|
+
declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/docs/render-index.d.ts
|
|
533
|
+
/**
|
|
534
|
+
* Configuration for a command category
|
|
535
|
+
*/
|
|
536
|
+
type CommandCategory = {
|
|
537
|
+
/** Category title (e.g., "Application Commands") */title: string; /** Category description */
|
|
538
|
+
description: string; /** Command paths to include (parent commands will auto-expand to leaf commands) */
|
|
539
|
+
commands: string[]; /** Path to documentation file for links (e.g., "./cli/application.md") */
|
|
540
|
+
docPath: string;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Options for rendering command index
|
|
544
|
+
*/
|
|
545
|
+
type CommandIndexOptions = {
|
|
546
|
+
/** Base heading level (default: 3, which renders as ###) */headingLevel?: 1 | 2 | 3 | 4 | 5 | 6; /** Only include leaf commands (commands without subcommands). Default: true */
|
|
547
|
+
leafOnly?: boolean;
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* Render command index from categories
|
|
551
|
+
*
|
|
552
|
+
* Generates a category-based index of commands with links to documentation.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* const categories: CommandCategory[] = [
|
|
556
|
+
* {
|
|
557
|
+
* title: "Application Commands",
|
|
558
|
+
* description: "Commands for managing applications.",
|
|
559
|
+
* commands: ["init", "generate", "apply"],
|
|
560
|
+
* docPath: "./cli/application.md",
|
|
561
|
+
* },
|
|
562
|
+
* ];
|
|
563
|
+
*
|
|
564
|
+
* const index = await renderCommandIndex(mainCommand, categories);
|
|
565
|
+
* // ### [Application Commands](./cli/application.md)
|
|
566
|
+
* //
|
|
567
|
+
* // Commands for managing applications.
|
|
568
|
+
* //
|
|
569
|
+
* // | Command | Description |
|
|
570
|
+
* // |---------|-------------|
|
|
571
|
+
* // | [init](./cli/application.md#init) | Initialize a project |
|
|
572
|
+
* // ...
|
|
573
|
+
*
|
|
574
|
+
* @param command - Root command to extract command information from
|
|
575
|
+
* @param categories - Category definitions for grouping commands
|
|
576
|
+
* @param options - Rendering options
|
|
577
|
+
* @returns Rendered markdown string
|
|
578
|
+
*/
|
|
579
|
+
declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
|
|
580
|
+
//#endregion
|
|
581
|
+
export { type ArgsShape, type ArgsTableOptions, type ArgumentsRenderContext, type ArgumentsRenderFunction, COMMAND_MARKER_PREFIX, type CommandCategory, type CommandIndexOptions, type CommandInfo, type DefaultRendererOptions, type DeleteFileFs, type ExampleCommandConfig, type ExampleConfig, type ExampleExecutionResult, type ExamplesRenderContext, type ExamplesRenderFunction, type ExamplesRenderOptions, type FileConfig, type FileMapping, type FormatterFunction, type GenerateDocConfig, type GenerateDocResult, type OptionsRenderContext, type OptionsRenderFunction, type RenderContentOptions, type RenderFunction, type SectionRenderFunction, type SimpleRenderContext, type SimpleRenderFunction, type SubCommandInfo, type SubcommandsRenderContext, type SubcommandsRenderFunction, type SubcommandsRenderOptions, UPDATE_GOLDEN_ENV, assertDocMatch, buildCommandInfo, collectAllCommands, commandEndMarker, commandStartMarker, compareWithExisting, createCommandRenderer, defaultRenderers, executeExamples, formatDiff, generateDoc, initDocFile, renderArgsTable, renderArgumentsList, renderArgumentsListFromArray, renderArgumentsTable, renderArgumentsTableFromArray, renderCommandIndex, renderExamplesDefault, renderOptionsList, renderOptionsListFromArray, renderOptionsTable, renderOptionsTableFromArray, renderSubcommandsTable, renderSubcommandsTableFromArray, renderUsage, resolveLazyCommand, writeFile };
|
|
500
582
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/executor/subcommand-router.ts","../../src/docs/types.ts","../../src/docs/default-renderers.ts","../../src/docs/doc-comparator.ts","../../src/docs/doc-generator.ts","../../src/docs/example-executor.ts","../../src/docs/golden-test.ts"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/executor/subcommand-router.ts","../../src/docs/types.ts","../../src/docs/default-renderers.ts","../../src/docs/doc-comparator.ts","../../src/docs/doc-generator.ts","../../src/docs/example-executor.ts","../../src/docs/golden-test.ts","../../src/docs/render-args.ts","../../src/docs/render-index.ts"],"mappings":";;;;;;;;;AAQA;;iBAAs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AAA,EACb,WAAA,cACC,OAAA,CAAQ,sBAAA;;;;;;iBC8lBW,WAAA,CAAY,MAAA,EAAQ,iBAAA,GAAoB,OAAA,CAAQ,iBAAA;;;;;iBAwQhD,cAAA,CAAe,MAAA,EAAQ,iBAAA,GAAoB,OAAA;;;;;;;;iBA6BjD,WAAA,CACd,MAAA,EAAQ,IAAA,CAAK,iBAAA,qBACb,UAAA,GAAa,YAAA;;;;;;;KC/4BH,SAAA,GAAY,MAAA,SAAe,CAAA,CAAE,OAAA;;;;KAK7B,gBAAA;EPJe,6DOMzB,OAAA;AAAA;;;;;;;;;;;;;;ANTF;;;;;;;;;;iBMgDgB,eAAA,CAAgB,IAAA,EAAM,SAAA,EAAW,OAAA,GAAU,gBAAA;;;;;;KCjC/C,eAAA;ERbU,oDQepB,KAAA;EAEA,WAAA,URhBiC;EQkBjC,QAAA,YRjBS;EQmBT,OAAA;AAAA;;;;KAMU,mBAAA;ER1BV,4DQ4BA,YAAA,0BR3BS;EQ6BT,QAAA;AAAA;;;;APjCF;;;;;;;;;;;;;;;;;;;;;;;;;;;iBO+JsB,kBAAA,CACpB,OAAA,EAAS,UAAA,EACT,UAAA,EAAY,eAAA,IACZ,OAAA,GAAU,mBAAA,GACT,OAAA"}
|
package/dist/docs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as ResolvedFieldMeta, p as Example, s as AnyCommand, t as ExtractedFields } from "../schema-extractor-
|
|
1
|
+
import { n as ResolvedFieldMeta, p as Example, s as AnyCommand, t as ExtractedFields } from "../schema-extractor-Cl_D04BX.js";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import * as fs from "node:fs";
|
|
3
4
|
|
|
4
5
|
//#region src/executor/subcommand-router.d.ts
|
|
5
|
-
|
|
6
6
|
/**
|
|
7
7
|
* Resolve a lazy-loaded command (sync or async)
|
|
8
8
|
*
|
|
@@ -178,6 +178,8 @@ interface ExamplesRenderOptions {
|
|
|
178
178
|
withHeading?: boolean;
|
|
179
179
|
/** Show execution output (default: true when results available) */
|
|
180
180
|
showOutput?: boolean;
|
|
181
|
+
/** Command prefix to prepend to example commands (e.g., "my-cli config get") */
|
|
182
|
+
commandPrefix?: string;
|
|
181
183
|
}
|
|
182
184
|
/**
|
|
183
185
|
* Examples render context
|
|
@@ -293,11 +295,8 @@ interface GenerateDocResult {
|
|
|
293
295
|
success: boolean;
|
|
294
296
|
/** File processing results */
|
|
295
297
|
files: Array<{
|
|
296
|
-
/** File path */
|
|
297
|
-
|
|
298
|
-
/** Status of this file */
|
|
299
|
-
status: "match" | "created" | "updated" | "diff";
|
|
300
|
-
/** Diff content (only when status is "diff") */
|
|
298
|
+
/** File path */path: string; /** Status of this file */
|
|
299
|
+
status: "match" | "created" | "updated" | "diff"; /** Diff content (only when status is "diff") */
|
|
301
300
|
diff?: string | undefined;
|
|
302
301
|
}>;
|
|
303
302
|
/** Error message (when success is false) */
|
|
@@ -414,11 +413,8 @@ declare function createCommandRenderer(options?: DefaultRendererOptions): Render
|
|
|
414
413
|
* Default renderers presets
|
|
415
414
|
*/
|
|
416
415
|
declare const defaultRenderers: {
|
|
417
|
-
/** Standard command documentation */
|
|
418
|
-
|
|
419
|
-
/** Table style options (default) */
|
|
420
|
-
tableStyle: RenderFunction;
|
|
421
|
-
/** List style options */
|
|
416
|
+
/** Standard command documentation */command: (options?: DefaultRendererOptions) => RenderFunction; /** Table style options (default) */
|
|
417
|
+
tableStyle: RenderFunction; /** List style options */
|
|
422
418
|
listStyle: RenderFunction;
|
|
423
419
|
};
|
|
424
420
|
//#endregion
|
|
@@ -496,5 +492,91 @@ declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
|
|
|
496
492
|
*/
|
|
497
493
|
declare function initDocFile(config: Pick<GenerateDocConfig, "files"> | string, fileSystem?: DeleteFileFs): void;
|
|
498
494
|
//#endregion
|
|
499
|
-
|
|
495
|
+
//#region src/docs/render-args.d.ts
|
|
496
|
+
/**
|
|
497
|
+
* Args shape type (Record of string keys to Zod schemas)
|
|
498
|
+
* This matches the typical structure of `commonArgs`, `workspaceArgs`, etc.
|
|
499
|
+
*/
|
|
500
|
+
type ArgsShape = Record<string, z.ZodType>;
|
|
501
|
+
/**
|
|
502
|
+
* Options for rendering args table
|
|
503
|
+
*/
|
|
504
|
+
type ArgsTableOptions = {
|
|
505
|
+
/** Columns to include in the table (default: all columns) */columns?: ("option" | "alias" | "description" | "default" | "env")[];
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Render args definition as a markdown options table
|
|
509
|
+
*
|
|
510
|
+
* This function takes raw args definitions (like `commonArgs`) and
|
|
511
|
+
* renders them as a markdown table suitable for documentation.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* import { renderArgsTable } from "politty/docs";
|
|
515
|
+
* import { commonArgs, workspaceArgs } from "./args";
|
|
516
|
+
*
|
|
517
|
+
* const table = renderArgsTable({
|
|
518
|
+
* ...commonArgs,
|
|
519
|
+
* ...workspaceArgs,
|
|
520
|
+
* });
|
|
521
|
+
* // | Option | Alias | Description | Default |
|
|
522
|
+
* // |--------|-------|-------------|---------|
|
|
523
|
+
* // | `--env-file <ENV_FILE>` | `-e` | Path to environment file | - |
|
|
524
|
+
* // ...
|
|
525
|
+
*
|
|
526
|
+
* @param args - Args shape (Record of string keys to Zod schemas with arg() metadata)
|
|
527
|
+
* @param options - Rendering options
|
|
528
|
+
* @returns Rendered markdown table string
|
|
529
|
+
*/
|
|
530
|
+
declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/docs/render-index.d.ts
|
|
533
|
+
/**
|
|
534
|
+
* Configuration for a command category
|
|
535
|
+
*/
|
|
536
|
+
type CommandCategory = {
|
|
537
|
+
/** Category title (e.g., "Application Commands") */title: string; /** Category description */
|
|
538
|
+
description: string; /** Command paths to include (parent commands will auto-expand to leaf commands) */
|
|
539
|
+
commands: string[]; /** Path to documentation file for links (e.g., "./cli/application.md") */
|
|
540
|
+
docPath: string;
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Options for rendering command index
|
|
544
|
+
*/
|
|
545
|
+
type CommandIndexOptions = {
|
|
546
|
+
/** Base heading level (default: 3, which renders as ###) */headingLevel?: 1 | 2 | 3 | 4 | 5 | 6; /** Only include leaf commands (commands without subcommands). Default: true */
|
|
547
|
+
leafOnly?: boolean;
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* Render command index from categories
|
|
551
|
+
*
|
|
552
|
+
* Generates a category-based index of commands with links to documentation.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* const categories: CommandCategory[] = [
|
|
556
|
+
* {
|
|
557
|
+
* title: "Application Commands",
|
|
558
|
+
* description: "Commands for managing applications.",
|
|
559
|
+
* commands: ["init", "generate", "apply"],
|
|
560
|
+
* docPath: "./cli/application.md",
|
|
561
|
+
* },
|
|
562
|
+
* ];
|
|
563
|
+
*
|
|
564
|
+
* const index = await renderCommandIndex(mainCommand, categories);
|
|
565
|
+
* // ### [Application Commands](./cli/application.md)
|
|
566
|
+
* //
|
|
567
|
+
* // Commands for managing applications.
|
|
568
|
+
* //
|
|
569
|
+
* // | Command | Description |
|
|
570
|
+
* // |---------|-------------|
|
|
571
|
+
* // | [init](./cli/application.md#init) | Initialize a project |
|
|
572
|
+
* // ...
|
|
573
|
+
*
|
|
574
|
+
* @param command - Root command to extract command information from
|
|
575
|
+
* @param categories - Category definitions for grouping commands
|
|
576
|
+
* @param options - Rendering options
|
|
577
|
+
* @returns Rendered markdown string
|
|
578
|
+
*/
|
|
579
|
+
declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
|
|
580
|
+
//#endregion
|
|
581
|
+
export { type ArgsShape, type ArgsTableOptions, type ArgumentsRenderContext, type ArgumentsRenderFunction, COMMAND_MARKER_PREFIX, type CommandCategory, type CommandIndexOptions, type CommandInfo, type DefaultRendererOptions, type DeleteFileFs, type ExampleCommandConfig, type ExampleConfig, type ExampleExecutionResult, type ExamplesRenderContext, type ExamplesRenderFunction, type ExamplesRenderOptions, type FileConfig, type FileMapping, type FormatterFunction, type GenerateDocConfig, type GenerateDocResult, type OptionsRenderContext, type OptionsRenderFunction, type RenderContentOptions, type RenderFunction, type SectionRenderFunction, type SimpleRenderContext, type SimpleRenderFunction, type SubCommandInfo, type SubcommandsRenderContext, type SubcommandsRenderFunction, type SubcommandsRenderOptions, UPDATE_GOLDEN_ENV, assertDocMatch, buildCommandInfo, collectAllCommands, commandEndMarker, commandStartMarker, compareWithExisting, createCommandRenderer, defaultRenderers, executeExamples, formatDiff, generateDoc, initDocFile, renderArgsTable, renderArgumentsList, renderArgumentsListFromArray, renderArgumentsTable, renderArgumentsTableFromArray, renderCommandIndex, renderExamplesDefault, renderOptionsList, renderOptionsListFromArray, renderOptionsTable, renderOptionsTableFromArray, renderSubcommandsTable, renderSubcommandsTableFromArray, renderUsage, resolveLazyCommand, writeFile };
|
|
500
582
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/docs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/executor/subcommand-router.ts","../../src/docs/types.ts","../../src/docs/default-renderers.ts","../../src/docs/doc-comparator.ts","../../src/docs/doc-generator.ts","../../src/docs/example-executor.ts","../../src/docs/golden-test.ts"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/executor/subcommand-router.ts","../../src/docs/types.ts","../../src/docs/default-renderers.ts","../../src/docs/doc-comparator.ts","../../src/docs/doc-generator.ts","../../src/docs/example-executor.ts","../../src/docs/golden-test.ts","../../src/docs/render-args.ts","../../src/docs/render-index.ts"],"mappings":";;;;;;;;;AAQA;;iBAAsB,kBAAA,CACpB,GAAA,EAAK,UAAA,UAAoB,OAAA,CAAQ,UAAA,KAChC,OAAA,CAAQ,UAAA;;;;;;UCJM,WAAA;EDEuB;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