@shell-shock/core 0.17.17 → 0.17.19

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.
@@ -3,8 +3,8 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
3
  let _alloy_js_core = require("@alloy-js/core");
4
4
  let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
5
5
  let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
6
- let _alloy_js_typescript = require("@alloy-js/typescript");
7
6
  let _stryke_string_format_list = require("@stryke/string-format/list");
7
+ let _alloy_js_typescript = require("@alloy-js/typescript");
8
8
 
9
9
  //#region src/components/command-validation-logic.tsx
10
10
  function __assignType(fn, args) {
@@ -2,8 +2,8 @@ import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
2
  import { For, Show, code } from "@alloy-js/core";
3
3
  import { camelCase } from "@stryke/string-format/camel-case";
4
4
  import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
5
- import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
6
5
  import { list } from "@stryke/string-format/list";
6
+ import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
7
7
 
8
8
  //#region src/components/command-validation-logic.tsx
9
9
  function __assignType(fn, args) {
@@ -13,6 +13,8 @@ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin
13
13
  let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
14
14
  let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
15
15
  let _stryke_path_join = require("@stryke/path/join");
16
+ let _stryke_string_format_list = require("@stryke/string-format/list");
17
+ let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
16
18
 
17
19
  //#region src/components/docs.tsx
18
20
  const __ΩRequired = [
@@ -29,36 +31,68 @@ function __assignType(fn, args) {
29
31
  fn.__type = args;
30
32
  return fn;
31
33
  }
32
- const __ΩCommandOptionsDocsProps = [
34
+ const __ΩCommandParametersDocsProps = [
33
35
  "CommandTree",
34
36
  "command",
35
37
  "The command to generate options documentation for.",
36
- "CommandOptionsDocsProps",
38
+ "CommandParametersDocsProps",
37
39
  "P\"w!4\"?#Mw$y"
38
40
  ];
39
41
  /**
42
+ * Generates the arguments markdown documentation for a command.
43
+ */
44
+ function CommandArgumentDocs(props) {
45
+ const { command } = props;
46
+ if (Object.keys(command.options).length === 0) return _alloy_js_core.code`This command does not have any arguments.`;
47
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
48
+ return require_reflect.sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
49
+ ret.push({
50
+ name: option.name.trim(),
51
+ description: option.description.trim(),
52
+ defaultValue: (0, _stryke_type_checks_is_undefined.isUndefined)(option.default) ? "" : JSON.stringify(option.default),
53
+ required: !option.required || option.default ? "" : "✔"
54
+ });
55
+ return ret;
56
+ }, [
57
+ "ret",
58
+ "option",
59
+ "",
60
+ "P\"2!\"2\"\"/#"
61
+ ]), []);
62
+ } });
63
+ }
64
+ CommandArgumentDocs.__type = [
65
+ () => __ΩCommandParametersDocsProps,
66
+ "props",
67
+ "CommandArgumentDocs",
68
+ "Generates the arguments markdown documentation for a command.",
69
+ "Pn!2\"\"/#?$"
70
+ ];
71
+ /**
40
72
  * Generates the options markdown documentation for a command.
41
73
  */
42
74
  function CommandOptionsDocs(props) {
43
75
  const { command } = props;
44
76
  if (Object.keys(command.options).length === 0) return _alloy_js_core.code`This command does not have any options.`;
45
77
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
46
- return require_reflect.sortOptions(Object.values(command.options)).map(__assignType((option) => {
47
- return {
78
+ return require_reflect.sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
79
+ ret.push({
48
80
  name: option.name.trim(),
49
81
  description: option.description.trim(),
50
- defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
82
+ defaultValue: (0, _stryke_type_checks_is_undefined.isUndefined)(option.default) ? "" : JSON.stringify(option.default),
51
83
  required: !option.required || option.default ? "" : "✔"
52
- };
84
+ });
85
+ return ret;
53
86
  }, [
87
+ "ret",
54
88
  "option",
55
89
  "",
56
- "P\"2!\"/\""
57
- ]));
90
+ "P\"2!\"2\"\"/#"
91
+ ]), []);
58
92
  } });
59
93
  }
60
94
  CommandOptionsDocs.__type = [
61
- () => __ΩCommandOptionsDocsProps,
95
+ () => __ΩCommandParametersDocsProps,
62
96
  "props",
63
97
  "CommandOptionsDocs",
64
98
  "Generates the options markdown documentation for a command.",
@@ -75,18 +109,31 @@ const __ΩCommandDocsUsageExampleProps = [
75
109
  "CommandTree",
76
110
  "command",
77
111
  "The command to generate the usage example for.",
112
+ "expand",
113
+ true,
114
+ "Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.",
78
115
  "CommandDocsUsageExampleProps",
79
- "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
116
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*)4+8>,?-Mw.y"
80
117
  ];
81
118
  /**
82
119
  * Generates the markdown documentation for a command.
83
120
  */
84
121
  function CommandDocsUsageExample(props) {
85
- const { packageManager = "npm", command } = props;
122
+ const { packageManager = "npm", command, expand = false } = props;
86
123
  const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
87
124
  return [
88
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
89
- _alloy_js_core.code`\`\`\`bash `,
125
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
126
+ when: expand,
127
+ fallback: _alloy_js_core.code`\`\`\`sh `,
128
+ get children() {
129
+ return [
130
+ _alloy_js_core.code`<details>
131
+ <summary>Using ${packageManager}:</summary>`,
132
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
133
+ _alloy_js_core.code`\`\`\`sh `
134
+ ];
135
+ }
136
+ }),
90
137
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
91
138
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_usage.Usage, {
92
139
  command,
@@ -96,8 +143,17 @@ function CommandDocsUsageExample(props) {
96
143
  packageManager
97
144
  }),
98
145
  (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
99
- _alloy_js_core.code`\`\`\``,
100
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
146
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
147
+ when: expand,
148
+ fallback: _alloy_js_core.code`\`\`\` `,
149
+ get children() {
150
+ return [
151
+ _alloy_js_core.code`\`\`\``,
152
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
153
+ _alloy_js_core.code`</details>`
154
+ ];
155
+ }
156
+ })
101
157
  ];
102
158
  }
103
159
  CommandDocsUsageExample.__type = [
@@ -132,18 +188,40 @@ function CommandDocs(props) {
132
188
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
133
189
  level: 1 + levelOffset,
134
190
  get children() {
135
- return command.title;
191
+ return `${command.title}${command.tags.includes("deprecated") ? " (Deprecated)" : command.tags.includes("beta") ? " (Beta)" : command.tags.includes("alpha") ? " (Alpha)" : command.tags.includes("experimental") ? " (Experimental)" : ""}`;
136
192
  }
137
193
  }),
138
194
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
139
195
  (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`${command.description}`),
196
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
197
+ get when() {
198
+ return command.alias && command.alias.length > 0;
199
+ },
200
+ get children() {
201
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
202
+ get when() {
203
+ return command.alias.length > 1;
204
+ },
205
+ get fallback() {
206
+ return _alloy_js_core.code`The \`${command.name}\` command can also be invoked using the alias \`${command.alias[0]}\`.`;
207
+ },
208
+ get children() {
209
+ return _alloy_js_core.code`The \`${command.name}\` command can also be invoked using the following aliases: ${(0, _stryke_string_format_list.list)(command.alias.map(__assignType((alias) => `\`${alias}\``, [
210
+ "alias",
211
+ "",
212
+ "P\"2!\"/\""
213
+ ])), { conjunction: "or" })}.`;
214
+ }
215
+ })];
216
+ }
217
+ }),
140
218
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
141
219
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
142
220
  level: 2 + levelOffset,
143
221
  children: "Usage"
144
222
  }),
145
223
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
146
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The ${command.name} command can be executed using the following syntax: `),
224
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The \`${command.name}\` command can be executed using the following syntax: `),
147
225
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
148
226
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
149
227
  get when() {
@@ -158,11 +236,14 @@ function CommandDocs(props) {
158
236
  get children() {
159
237
  return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
160
238
  each: usageExamples,
161
- hardline: true,
239
+ doubleHardline: true,
162
240
  get children() {
163
241
  return __assignType((packageManager) => (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocsUsageExample, {
164
242
  packageManager,
165
- command
243
+ command,
244
+ get expand() {
245
+ return usageExamples && usageExamples.length > 1;
246
+ }
166
247
  }), [
167
248
  "packageManager",
168
249
  "",
@@ -173,12 +254,31 @@ function CommandDocs(props) {
173
254
  }
174
255
  }),
175
256
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
257
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
258
+ get when() {
259
+ return command.args.length > 0;
260
+ },
261
+ get children() {
262
+ return [
263
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
264
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
265
+ level: 2 + levelOffset,
266
+ children: "Positional Arguments"
267
+ }),
268
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
269
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The following positional arguments are available for the \`${command.name}\` command:`),
270
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
271
+ (0, _alloy_js_core_jsx_runtime.createComponent)(CommandArgumentDocs, { command }),
272
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
273
+ ];
274
+ }
275
+ }),
176
276
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
177
277
  level: 2 + levelOffset,
178
278
  children: "Options"
179
279
  }),
180
280
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
181
- (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The following options are available for the ${command.name} command:`),
281
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The following options are available for the \`${command.name}\` command:`),
182
282
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
183
283
  (0, _alloy_js_core_jsx_runtime.createComponent)(CommandOptionsDocs, { command }),
184
284
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
@@ -254,6 +354,7 @@ CommandDocsFile.__type = [
254
354
  ];
255
355
 
256
356
  //#endregion
357
+ exports.CommandArgumentDocs = CommandArgumentDocs;
257
358
  exports.CommandDocs = CommandDocs;
258
359
  exports.CommandDocsFile = CommandDocsFile;
259
360
  exports.CommandDocsUsageExample = CommandDocsUsageExample;
@@ -261,5 +362,5 @@ exports.CommandOptionsDocs = CommandOptionsDocs;
261
362
  exports.__ΩCommandDocsFileProps = __ΩCommandDocsFileProps;
262
363
  exports.__ΩCommandDocsProps = __ΩCommandDocsProps;
263
364
  exports.__ΩCommandDocsUsageExampleProps = __ΩCommandDocsUsageExampleProps;
264
- exports.__ΩCommandOptionsDocsProps = __ΩCommandOptionsDocsProps;
365
+ exports.__ΩCommandParametersDocsProps = __ΩCommandParametersDocsProps;
265
366
  //# sourceMappingURL=docs.cjs.map
@@ -2,16 +2,20 @@ import { CommandTree } from "../types/command.cjs";
2
2
  import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
3
3
 
4
4
  //#region src/components/docs.d.ts
5
- interface CommandOptionsDocsProps {
5
+ interface CommandParametersDocsProps {
6
6
  /**
7
7
  * The command to generate options documentation for.
8
8
  */
9
9
  command: CommandTree;
10
10
  }
11
+ /**
12
+ * Generates the arguments markdown documentation for a command.
13
+ */
14
+ declare function CommandArgumentDocs(props: CommandParametersDocsProps): import("@alloy-js/core").Children;
11
15
  /**
12
16
  * Generates the options markdown documentation for a command.
13
17
  */
14
- declare function CommandOptionsDocs(props: CommandOptionsDocsProps): import("@alloy-js/core").Children;
18
+ declare function CommandOptionsDocs(props: CommandParametersDocsProps): import("@alloy-js/core").Children;
15
19
  interface CommandDocsUsageExampleProps {
16
20
  /**
17
21
  * The package manager to generate the usage example for.
@@ -26,6 +30,12 @@ interface CommandDocsUsageExampleProps {
26
30
  * The command to generate the usage example for.
27
31
  */
28
32
  command: CommandTree;
33
+ /**
34
+ * Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.
35
+ *
36
+ * @defaultValue false
37
+ */
38
+ expand?: boolean;
29
39
  }
30
40
  /**
31
41
  * Generates the markdown documentation for a command.
@@ -76,5 +86,5 @@ interface CommandDocsFileProps extends Partial<MarkdownFileProps> {
76
86
  */
77
87
  declare function CommandDocsFile(props: CommandDocsFileProps): import("@alloy-js/core").Children;
78
88
  //#endregion
79
- export { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps };
89
+ export { CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParametersDocsProps };
80
90
  //# sourceMappingURL=docs.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAmCiB,uBAAA;;AAAjB;;EAIE,OAAA,EAAS,WAAW;AAAA;AAAA;AAMtB;;AANsB,iBAMN,kBAAA,CAAmB,KAAA,EAAO,uBAAuB,4BAAA,QAAA;AAAA,UA4BhD,4BAAA;EA5ByB;;;;AAAuB;AA4BjE;;;EASE,cAAA;EAAA;;;EAKA,OAAA,EAAS,WAAW;AAAA;AAMtB;;;AAAA,iBAAgB,uBAAA,CAAwB,KAAA,EAAO,4BAA4B,4BAAA,QAAA;AAAA,UAsB1D,gBAAA;EAtBuB;;;AAAmC;AAsB3E;;;;EASE,WAAA;EAYgB;;;EAPhB,OAAA,EAAS,WAAA;EAAT;;;;;EAOA,aAAA,GAAgB,QAAA,CAAS,4BAAA;AAAA;AAM3B;;;AAAA,iBAAgB,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA;AAAA,UAwClC,oBAAA,SAA6B,OAAA,CAAQ,iBAAA;EAxC1B;;;AAAuB;AAwCnD;;;;EASE,WAAA;EAT4C;;;EAc5C,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,eAAA,CAAgB,KAAA,EAAO,oBAAoB,4BAAA,QAAA"}
1
+ {"version":3,"file":"docs.d.cts","names":[],"sources":["../../src/components/docs.tsx"],"mappings":";;;;UAqCiB,0BAAA;;AAAjB;;EAIE,OAAA,EAAS,WAAW;AAAA;AAAA;AAMtB;;AANsB,iBAMN,mBAAA,CAAoB,KAAA,EAAO,0BAA0B,4BAAA,QAAA;;;;iBAmCrD,kBAAA,CAAmB,KAAA,EAAO,0BAA0B,4BAAA,QAAA;AAAA,UAgCnD,4BAAA;EAnEoD;AAmCrE;;;;;;;EAyCE,cAAA;EAzCkE;AAgCpE;;EAcE,OAAA,EAAS,WAAW;EAAA;;;;;EAOpB,MAAA;AAAA;AAMF;;;AAAA,iBAAgB,uBAAA,CAAwB,KAAA,EAAO,4BAA4B,4BAAA,QAAA;AAAA,UA6B1D,gBAAA;EA7BuB;;;AAAmC;AA6B3E;;;;EASE,WAAA;EAYgB;;;EAPhB,OAAA,EAAS,WAAA;EAAT;;;;;EAOA,aAAA,GAAgB,QAAA,CAAS,4BAAA;AAAA;AAM3B;;;AAAA,iBAAgB,WAAA,CAAY,KAAA,EAAO,gBAAgB,4BAAA,QAAA;AAAA,UAyElC,oBAAA,SAA6B,OAAA,CAAQ,iBAAA;EAzE1B;;;AAAuB;AAyEnD;;;;EASE,WAAA;EAT4C;;;EAc5C,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,eAAA,CAAgB,KAAA,EAAO,oBAAoB,4BAAA,QAAA"}
@@ -2,16 +2,20 @@ import { CommandTree } from "../types/command.mjs";
2
2
  import { MarkdownFileProps } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
3
3
 
4
4
  //#region src/components/docs.d.ts
5
- interface CommandOptionsDocsProps {
5
+ interface CommandParametersDocsProps {
6
6
  /**
7
7
  * The command to generate options documentation for.
8
8
  */
9
9
  command: CommandTree;
10
10
  }
11
+ /**
12
+ * Generates the arguments markdown documentation for a command.
13
+ */
14
+ declare function CommandArgumentDocs(props: CommandParametersDocsProps): import("@alloy-js/core").Children;
11
15
  /**
12
16
  * Generates the options markdown documentation for a command.
13
17
  */
14
- declare function CommandOptionsDocs(props: CommandOptionsDocsProps): import("@alloy-js/core").Children;
18
+ declare function CommandOptionsDocs(props: CommandParametersDocsProps): import("@alloy-js/core").Children;
15
19
  interface CommandDocsUsageExampleProps {
16
20
  /**
17
21
  * The package manager to generate the usage example for.
@@ -26,6 +30,12 @@ interface CommandDocsUsageExampleProps {
26
30
  * The command to generate the usage example for.
27
31
  */
28
32
  command: CommandTree;
33
+ /**
34
+ * Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.
35
+ *
36
+ * @defaultValue false
37
+ */
38
+ expand?: boolean;
29
39
  }
30
40
  /**
31
41
  * Generates the markdown documentation for a command.
@@ -76,5 +86,5 @@ interface CommandDocsFileProps extends Partial<MarkdownFileProps> {
76
86
  */
77
87
  declare function CommandDocsFile(props: CommandDocsFileProps): import("@alloy-js/core").Children;
78
88
  //#endregion
79
- export { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps };
89
+ export { CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParametersDocsProps };
80
90
  //# sourceMappingURL=docs.d.mts.map
@@ -12,6 +12,8 @@ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
12
12
  import { MarkdownFile } from "@powerlines/plugin-alloy/markdown/components/markdown-file";
13
13
  import { MarkdownTable } from "@powerlines/plugin-alloy/markdown/components/markdown-table";
14
14
  import { joinPaths } from "@stryke/path/join";
15
+ import { list } from "@stryke/string-format/list";
16
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
15
17
 
16
18
  //#region src/components/docs.tsx
17
19
  const __ΩRequired = [
@@ -28,36 +30,68 @@ function __assignType(fn, args) {
28
30
  fn.__type = args;
29
31
  return fn;
30
32
  }
31
- const __ΩCommandOptionsDocsProps = [
33
+ const __ΩCommandParametersDocsProps = [
32
34
  "CommandTree",
33
35
  "command",
34
36
  "The command to generate options documentation for.",
35
- "CommandOptionsDocsProps",
37
+ "CommandParametersDocsProps",
36
38
  "P\"w!4\"?#Mw$y"
37
39
  ];
38
40
  /**
41
+ * Generates the arguments markdown documentation for a command.
42
+ */
43
+ function CommandArgumentDocs(props) {
44
+ const { command } = props;
45
+ if (Object.keys(command.options).length === 0) return code`This command does not have any arguments.`;
46
+ return createComponent(MarkdownTable, { get data() {
47
+ return sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
48
+ ret.push({
49
+ name: option.name.trim(),
50
+ description: option.description.trim(),
51
+ defaultValue: isUndefined(option.default) ? "" : JSON.stringify(option.default),
52
+ required: !option.required || option.default ? "" : "✔"
53
+ });
54
+ return ret;
55
+ }, [
56
+ "ret",
57
+ "option",
58
+ "",
59
+ "P\"2!\"2\"\"/#"
60
+ ]), []);
61
+ } });
62
+ }
63
+ CommandArgumentDocs.__type = [
64
+ () => __ΩCommandParametersDocsProps,
65
+ "props",
66
+ "CommandArgumentDocs",
67
+ "Generates the arguments markdown documentation for a command.",
68
+ "Pn!2\"\"/#?$"
69
+ ];
70
+ /**
39
71
  * Generates the options markdown documentation for a command.
40
72
  */
41
73
  function CommandOptionsDocs(props) {
42
74
  const { command } = props;
43
75
  if (Object.keys(command.options).length === 0) return code`This command does not have any options.`;
44
76
  return createComponent(MarkdownTable, { get data() {
45
- return sortOptions(Object.values(command.options)).map(__assignType((option) => {
46
- return {
77
+ return sortOptions(Object.values(command.options)).reduce(__assignType((ret, option) => {
78
+ ret.push({
47
79
  name: option.name.trim(),
48
80
  description: option.description.trim(),
49
- defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
81
+ defaultValue: isUndefined(option.default) ? "" : JSON.stringify(option.default),
50
82
  required: !option.required || option.default ? "" : "✔"
51
- };
83
+ });
84
+ return ret;
52
85
  }, [
86
+ "ret",
53
87
  "option",
54
88
  "",
55
- "P\"2!\"/\""
56
- ]));
89
+ "P\"2!\"2\"\"/#"
90
+ ]), []);
57
91
  } });
58
92
  }
59
93
  CommandOptionsDocs.__type = [
60
- () => __ΩCommandOptionsDocsProps,
94
+ () => __ΩCommandParametersDocsProps,
61
95
  "props",
62
96
  "CommandOptionsDocs",
63
97
  "Generates the options markdown documentation for a command.",
@@ -74,18 +108,31 @@ const __ΩCommandDocsUsageExampleProps = [
74
108
  "CommandTree",
75
109
  "command",
76
110
  "The command to generate the usage example for.",
111
+ "expand",
112
+ true,
113
+ "Whether to add expand/collapse details tags around the usage example. This is useful for hiding long usage examples by default.",
77
114
  "CommandDocsUsageExampleProps",
78
- "PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
115
+ "PP.!.\".#.$J4%8>&?'\"w(4)?*)4+8>,?-Mw.y"
79
116
  ];
80
117
  /**
81
118
  * Generates the markdown documentation for a command.
82
119
  */
83
120
  function CommandDocsUsageExample(props) {
84
- const { packageManager = "npm", command } = props;
121
+ const { packageManager = "npm", command, expand = false } = props;
85
122
  const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
86
123
  return [
87
- createIntrinsic("hbr", {}),
88
- code`\`\`\`bash `,
124
+ createComponent(Show, {
125
+ when: expand,
126
+ fallback: code`\`\`\`sh `,
127
+ get children() {
128
+ return [
129
+ code`<details>
130
+ <summary>Using ${packageManager}:</summary>`,
131
+ createComponent(Spacing, {}),
132
+ code`\`\`\`sh `
133
+ ];
134
+ }
135
+ }),
89
136
  createIntrinsic("hbr", {}),
90
137
  createComponent(Usage, {
91
138
  command,
@@ -95,8 +142,17 @@ function CommandDocsUsageExample(props) {
95
142
  packageManager
96
143
  }),
97
144
  createIntrinsic("hbr", {}),
98
- code`\`\`\``,
99
- createIntrinsic("hbr", {})
145
+ createComponent(Show, {
146
+ when: expand,
147
+ fallback: code`\`\`\` `,
148
+ get children() {
149
+ return [
150
+ code`\`\`\``,
151
+ createComponent(Spacing, {}),
152
+ code`</details>`
153
+ ];
154
+ }
155
+ })
100
156
  ];
101
157
  }
102
158
  CommandDocsUsageExample.__type = [
@@ -131,18 +187,40 @@ function CommandDocs(props) {
131
187
  createComponent(Heading, {
132
188
  level: 1 + levelOffset,
133
189
  get children() {
134
- return command.title;
190
+ return `${command.title}${command.tags.includes("deprecated") ? " (Deprecated)" : command.tags.includes("beta") ? " (Beta)" : command.tags.includes("alpha") ? " (Alpha)" : command.tags.includes("experimental") ? " (Experimental)" : ""}`;
135
191
  }
136
192
  }),
137
193
  createComponent(Spacing, {}),
138
194
  memo(() => code`${command.description}`),
195
+ createComponent(Show, {
196
+ get when() {
197
+ return command.alias && command.alias.length > 0;
198
+ },
199
+ get children() {
200
+ return [createComponent(Spacing, {}), createComponent(Show, {
201
+ get when() {
202
+ return command.alias.length > 1;
203
+ },
204
+ get fallback() {
205
+ return code`The \`${command.name}\` command can also be invoked using the alias \`${command.alias[0]}\`.`;
206
+ },
207
+ get children() {
208
+ return code`The \`${command.name}\` command can also be invoked using the following aliases: ${list(command.alias.map(__assignType((alias) => `\`${alias}\``, [
209
+ "alias",
210
+ "",
211
+ "P\"2!\"/\""
212
+ ])), { conjunction: "or" })}.`;
213
+ }
214
+ })];
215
+ }
216
+ }),
139
217
  createComponent(Spacing, {}),
140
218
  createComponent(Heading, {
141
219
  level: 2 + levelOffset,
142
220
  children: "Usage"
143
221
  }),
144
222
  createComponent(Spacing, {}),
145
- memo(() => code`The ${command.name} command can be executed using the following syntax: `),
223
+ memo(() => code`The \`${command.name}\` command can be executed using the following syntax: `),
146
224
  createComponent(Spacing, {}),
147
225
  createComponent(Show, {
148
226
  get when() {
@@ -157,11 +235,14 @@ function CommandDocs(props) {
157
235
  get children() {
158
236
  return createComponent(For, {
159
237
  each: usageExamples,
160
- hardline: true,
238
+ doubleHardline: true,
161
239
  get children() {
162
240
  return __assignType((packageManager) => createComponent(CommandDocsUsageExample, {
163
241
  packageManager,
164
- command
242
+ command,
243
+ get expand() {
244
+ return usageExamples && usageExamples.length > 1;
245
+ }
165
246
  }), [
166
247
  "packageManager",
167
248
  "",
@@ -172,12 +253,31 @@ function CommandDocs(props) {
172
253
  }
173
254
  }),
174
255
  createComponent(Spacing, {}),
256
+ createComponent(Show, {
257
+ get when() {
258
+ return command.args.length > 0;
259
+ },
260
+ get children() {
261
+ return [
262
+ createComponent(Spacing, {}),
263
+ createComponent(Heading, {
264
+ level: 2 + levelOffset,
265
+ children: "Positional Arguments"
266
+ }),
267
+ createComponent(Spacing, {}),
268
+ memo(() => code`The following positional arguments are available for the \`${command.name}\` command:`),
269
+ createComponent(Spacing, {}),
270
+ createComponent(CommandArgumentDocs, { command }),
271
+ createComponent(Spacing, {})
272
+ ];
273
+ }
274
+ }),
175
275
  createComponent(Heading, {
176
276
  level: 2 + levelOffset,
177
277
  children: "Options"
178
278
  }),
179
279
  createComponent(Spacing, {}),
180
- memo(() => code`The following options are available for the ${command.name} command:`),
280
+ memo(() => code`The following options are available for the \`${command.name}\` command:`),
181
281
  createComponent(Spacing, {}),
182
282
  createComponent(CommandOptionsDocs, { command }),
183
283
  createComponent(Spacing, {})
@@ -253,5 +353,5 @@ CommandDocsFile.__type = [
253
353
  ];
254
354
 
255
355
  //#endregion
256
- export { CommandDocs, CommandDocsFile, CommandDocsUsageExample, CommandOptionsDocs, __ΩCommandDocsFileProps, __ΩCommandDocsProps, __ΩCommandDocsUsageExampleProps, __ΩCommandOptionsDocsProps };
356
+ export { CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsUsageExample, CommandOptionsDocs, __ΩCommandDocsFileProps, __ΩCommandDocsProps, __ΩCommandDocsUsageExampleProps, __ΩCommandParametersDocsProps };
257
357
  //# sourceMappingURL=docs.mjs.map
@@ -12,6 +12,7 @@ exports.ArgsUtilities = require_components_state_builtin.ArgsUtilities;
12
12
  exports.ArgumentsParserLogic = require_components_options_parser_logic.ArgumentsParserLogic;
13
13
  exports.BooleanInputParserLogic = require_components_helpers.BooleanInputParserLogic;
14
14
  exports.ColorSupportUtilities = require_components_utils_builtin.ColorSupportUtilities;
15
+ exports.CommandArgumentDocs = require_components_docs.CommandArgumentDocs;
15
16
  exports.CommandDocs = require_components_docs.CommandDocs;
16
17
  exports.CommandDocsFile = require_components_docs.CommandDocsFile;
17
18
  exports.CommandDocsUsageExample = require_components_docs.CommandDocsUsageExample;
@@ -45,7 +46,7 @@ exports.__ΩBooleanInputParserLogicProps = require_components_helpers.__ΩBoolea
45
46
  exports.__ΩCommandDocsFileProps = require_components_docs.__ΩCommandDocsFileProps;
46
47
  exports.__ΩCommandDocsProps = require_components_docs.__ΩCommandDocsProps;
47
48
  exports.__ΩCommandDocsUsageExampleProps = require_components_docs.__ΩCommandDocsUsageExampleProps;
48
- exports.__ΩCommandOptionsDocsProps = require_components_docs.__ΩCommandOptionsDocsProps;
49
+ exports.__ΩCommandParametersDocsProps = require_components_docs.__ΩCommandParametersDocsProps;
49
50
  exports.__ΩCommandParserLogicProps = require_components_options_parser_logic.__ΩCommandParserLogicProps;
50
51
  exports.__ΩCommandValidationLogicProps = require_components_command_validation_logic.__ΩCommandValidationLogicProps;
51
52
  exports.__ΩDynamicSegmentsParserLogicProps = require_components_options_parser_logic.__ΩDynamicSegmentsParserLogicProps;
@@ -1,9 +1,9 @@
1
1
  import { CommandValidationLogic, CommandValidationLogicProps } from "./command-validation-logic.cjs";
2
- import { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps } from "./docs.cjs";
2
+ import { CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParametersDocsProps } from "./docs.cjs";
3
3
  import { ExecBuiltin, ExecBuiltinProps } from "./exec-builtin.cjs";
4
4
  import { BooleanInputParserLogic, BooleanInputParserLogicProps, CommandParameterType, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose } from "./helpers.cjs";
5
5
  import { ArgumentsParserLogic, ArgumentsParserLogicProps, CommandParserLogic, CommandParserLogicProps, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps } from "./options-parser-logic.cjs";
6
6
  import { ArgsUtilities, ContextUtilities, GlobalTypeDefinitions, StateBuiltin, StateBuiltinProps } from "./state-builtin.cjs";
7
7
  import { Usage, UsageProps } from "./usage.cjs";
8
8
  import { ColorSupportUtilities, EnvSupportUtilities, FindSuggestionsDeclaration, HyperlinkSupportUtilities, ResolveModuleFunctionDeclaration, TerminalSizeDeclaration, UtilsBuiltin, UtilsBuiltinProps } from "./utils-builtin.cjs";
9
- export { ArgsUtilities, ArgumentsParserLogic, ArgumentsParserLogicProps, BooleanInputParserLogic, BooleanInputParserLogicProps, ColorSupportUtilities, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps, CommandParameterType, CommandParserLogic, CommandParserLogicProps, CommandValidationLogic, CommandValidationLogicProps, ContextUtilities, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, EnvSupportUtilities, ExecBuiltin, ExecBuiltinProps, FindSuggestionsDeclaration, GlobalTypeDefinitions, HyperlinkSupportUtilities, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps, ResolveModuleFunctionDeclaration, StateBuiltin, StateBuiltinProps, TerminalSizeDeclaration, Usage, UsageProps, UtilsBuiltin, UtilsBuiltinProps };
9
+ export { ArgsUtilities, ArgumentsParserLogic, ArgumentsParserLogicProps, BooleanInputParserLogic, BooleanInputParserLogicProps, ColorSupportUtilities, CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParameterType, CommandParametersDocsProps, CommandParserLogic, CommandParserLogicProps, CommandValidationLogic, CommandValidationLogicProps, ContextUtilities, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, EnvSupportUtilities, ExecBuiltin, ExecBuiltinProps, FindSuggestionsDeclaration, GlobalTypeDefinitions, HyperlinkSupportUtilities, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps, ResolveModuleFunctionDeclaration, StateBuiltin, StateBuiltinProps, TerminalSizeDeclaration, Usage, UsageProps, UtilsBuiltin, UtilsBuiltinProps };
@@ -1,9 +1,9 @@
1
1
  import { CommandValidationLogic, CommandValidationLogicProps } from "./command-validation-logic.mjs";
2
- import { CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps } from "./docs.mjs";
2
+ import { CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParametersDocsProps } from "./docs.mjs";
3
3
  import { ExecBuiltin, ExecBuiltinProps } from "./exec-builtin.mjs";
4
4
  import { BooleanInputParserLogic, BooleanInputParserLogicProps, CommandParameterType, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose } from "./helpers.mjs";
5
5
  import { ArgumentsParserLogic, ArgumentsParserLogicProps, CommandParserLogic, CommandParserLogicProps, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps } from "./options-parser-logic.mjs";
6
6
  import { ArgsUtilities, ContextUtilities, GlobalTypeDefinitions, StateBuiltin, StateBuiltinProps } from "./state-builtin.mjs";
7
7
  import { Usage, UsageProps } from "./usage.mjs";
8
8
  import { ColorSupportUtilities, EnvSupportUtilities, FindSuggestionsDeclaration, HyperlinkSupportUtilities, ResolveModuleFunctionDeclaration, TerminalSizeDeclaration, UtilsBuiltin, UtilsBuiltinProps } from "./utils-builtin.mjs";
9
- export { ArgsUtilities, ArgumentsParserLogic, ArgumentsParserLogicProps, BooleanInputParserLogic, BooleanInputParserLogicProps, ColorSupportUtilities, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandOptionsDocsProps, CommandParameterType, CommandParserLogic, CommandParserLogicProps, CommandValidationLogic, CommandValidationLogicProps, ContextUtilities, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, EnvSupportUtilities, ExecBuiltin, ExecBuiltinProps, FindSuggestionsDeclaration, GlobalTypeDefinitions, HyperlinkSupportUtilities, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps, ResolveModuleFunctionDeclaration, StateBuiltin, StateBuiltinProps, TerminalSizeDeclaration, Usage, UsageProps, UtilsBuiltin, UtilsBuiltinProps };
9
+ export { ArgsUtilities, ArgumentsParserLogic, ArgumentsParserLogicProps, BooleanInputParserLogic, BooleanInputParserLogicProps, ColorSupportUtilities, CommandArgumentDocs, CommandDocs, CommandDocsFile, CommandDocsFileProps, CommandDocsProps, CommandDocsUsageExample, CommandDocsUsageExampleProps, CommandOptionsDocs, CommandParameterType, CommandParametersDocsProps, CommandParserLogic, CommandParserLogicProps, CommandValidationLogic, CommandValidationLogicProps, ContextUtilities, DynamicSegmentsParserLogic, DynamicSegmentsParserLogicProps, EnvSupportUtilities, ExecBuiltin, ExecBuiltinProps, FindSuggestionsDeclaration, GlobalTypeDefinitions, HyperlinkSupportUtilities, IsDebug, IsNotDebug, IsNotVerbose, IsVerbose, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserConditionProps, OptionsMemberParserLogic, OptionsMemberParserLogicProps, OptionsParserLogic, OptionsParserLogicProps, ResolveModuleFunctionDeclaration, StateBuiltin, StateBuiltinProps, TerminalSizeDeclaration, Usage, UsageProps, UtilsBuiltin, UtilsBuiltinProps };