Skip to content

Commit ef1e4cb

Browse files
authored
Generate plugin banner for all plugin commands (nushell#1519)
* Option to run make_docs in clean Nushell * Move const out of global * Generate plugin banner for all plugin commands * Remove outdated dfr code * Fix period placement
1 parent 873c77b commit ef1e4cb

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

make_docs.nu

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,23 @@ $"($example.description)
273273
['', '## Subcommands:', '', $commands, ''] | str join (char newline)
274274
} else { '' }
275275

276-
let features = if $command.name =~ '^dfr' {
277-
$'::: warning(char nl)Dataframe commands were not shipped in the official binaries by default, you have to build it with `--features=dataframe` flag(char nl):::(char nl)(char nl)'
278-
} else { '' }
279-
280-
let plugins = if $command.name in ['from ini', 'from ics', 'from eml', 'from vcf'] {
281-
$"::: warning(char nl)Command `($command.name)` resides in [plugin]\(/book/plugins.html) [`nu_plugin_formats`]\(https://crates.io/crates/nu_plugin_formats). To use this command, you must install/compile and register nu_plugin_formats(char nl):::(char nl)(char nl)"
282-
} else if $command.name in ['query', 'query xml', 'query json', 'query web'] {
283-
$"::: warning(char nl)Command `($command.name)` resides in [plugin]\(/book/plugins.html) [`nu_plugin_query`]\(https://crates.io/crates/nu_plugin_query). To use this command, you must install/compile and register nu_plugin_query(char nl):::(char nl)(char nl)"
284-
} else { '' }
276+
let plugin_commands = (plugin list | flatten)
277+
let plugin_warning = if ($command.name in $plugin_commands.commands) {
278+
let plugin = ($plugin_commands | where commands == $command.name | first)
279+
[ $"::: warning This command requires a plugin"
280+
$"The `($command.name)` command resides in the `($plugin.name)` plugin."
281+
$"To use this command, you must install and register `($plugin.filename | path basename)`."
282+
"See the [Plugins]\(/book/plugins.html) chapter in the book for more information."
283+
":::"
284+
""
285+
""
286+
] | to text
287+
} else {
288+
''
289+
}
285290

286291
let doc = (
287-
($top + $plugins + $features + $signatures + $flags + $parameters + $in_out + $examples + $extra_usage + $sub_commands)
292+
($top + $plugin_warning + $signatures + $flags + $parameters + $in_out + $examples + $extra_usage + $sub_commands)
288293
| lines
289294
| each {|it| ($it | str trim -r) }
290295
| str join (char newline)

0 commit comments

Comments
 (0)