Skip to content

Commit

Permalink
mark feature-gated commands more clearly (nushell#1183)
Browse files Browse the repository at this point in the history
* warning at the top

* add the feature of a command to its frontmatter

* add feature column to the command table
  • Loading branch information
amtoine authored Jan 7, 2024
1 parent 87b89a6 commit 302f01f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ To see all commands from inside Nushell, run [`help commands`](/commands/docs/he
<th>Command</th>
<th>Categories</th>
<th>Description</th>
<th>Feature</th>
</tr>
<tr v-for="command in commands">
<td><a :href="command.path">{{ command.title }}</a></td>
<td style="white-space: pre-wrap;">{{ command.frontmatter.categories }}</td>
<td style="white-space: pre-wrap;">{{ command.frontmatter.usage }}</td>
<td style="white-space: pre-wrap;">{{ command.frontmatter.feature }}</td>
</tr>
</table>
17 changes: 13 additions & 4 deletions make_docs.nu
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def command-frontmatter [commands_group, command_name] {
| str join (char newline)
)

let feature = if $command_name =~ '^dfr' {
"dataframe"
} else if $command_name in $extra_cmds {
"extra"
} else {
"default"
}

# This is going in the frontmatter as a multiline YAML string, so indentation matters
$"---
title: ($command_name)
Expand All @@ -91,6 +99,7 @@ version: ($nu_version)
($category_matter)
usage: |
($indented_usage)
feature: ($feature)
---"
}

Expand Down Expand Up @@ -237,18 +246,18 @@ $"($example.description)
['', '## Subcommands:', '', $commands, ''] | str join (char newline)
} else { '' }

let tips = if $command.name =~ '^dfr' {
$'(char nl)**Tips:** Dataframe commands were not shipped in the official binaries by default, you have to build it with `--features=dataframe` flag(char nl)'
let features = if $command.name =~ '^dfr' {
$'(char nl)::: 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)'
} else if $command.name in $extra_cmds {
$'(char nl)**Tips:** Command `($command.name)` was not included in the official binaries by default, you have to build it with `--features=extra` flag(char nl)'
$'(char nl)::: warning(char nl) Command `($command.name)` was not included in the official binaries by default, you have to build it with `--features=extra` flag(char nl):::(char nl)'
} else { '' }

let plugins = if $command.name in ['from ini', 'from ics', 'from eml', 'from vcf'] {
$"(char nl)::: 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)"
} else { '' }

let doc = (
($top + $plugins + $signatures + $flags + $parameters + $in_out + $examples + $extra_usage + $sub_commands + $tips)
($top + $plugins + $features + $signatures + $flags + $parameters + $in_out + $examples + $extra_usage + $sub_commands)
| lines
| each {|it| ($it | str trim -r) }
| str join (char newline)
Expand Down

0 comments on commit 302f01f

Please sign in to comment.