Skip to content

Commit 6b6f2aa

Browse files
raoulkent132ikl
andauthored
feature(make_docs.nu): adjust the input/output section generation (#1930)
* docs(closure.md): Add simple examples of using closures * feature(make_docs.nu): adjust the input/output section generation now uses the data directly from help {command} to ensure that the table is fully populated by all input/output combinations. * Update make_docs.nu Co-authored-by: 132ikl <[email protected]> --------- Co-authored-by: 132ikl <[email protected]>
1 parent 5b122da commit 6b6f2aa

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

make_docs.nu

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
def plugin-paths [ nu_path?: path ] {
32
const PLUGINS = [
43
nu_plugin_inc,
@@ -243,10 +242,21 @@ $"## Notes
243242
# FIXME: Parentheses are required here to mutate $input_output, otherwise it won't work, maybe a bug?
244243
$input_output = ($input_output | append [[input output]; [$input $output]])
245244
}
246-
let in_out = if ($input_output | length) > 0 {
247-
let markdown = ($input_output | sort-by input | to md --pretty | str replace -a '<' '\<' | str replace -a '>' '\>')
248-
['', '## Input/output types:', '', $markdown, ''] | str join (char newline)
249-
} else { '' }
245+
# Input/output types: use help commands
246+
let input_output_table = (
247+
help commands
248+
| where name == $command.name
249+
| get input_output
250+
| first
251+
| to md --pretty
252+
| str replace -a '<' '&lt;'
253+
| str replace -a '>' '&gt;'
254+
)
255+
let in_out = if ($input_output_table | is-empty) {
256+
''
257+
} else {
258+
['', '## Input/output types:', '', $input_output_table, ''] | str join (char newline)
259+
}
250260

251261
let examples = if ($command.examples | length) > 0 {
252262
let example_top = $"## Examples(char newline)(char newline)"

0 commit comments

Comments
 (0)