Skip to content

Commit 1a67714

Browse files
committed
support docs gen for sub commands without ":"
1 parent cb2b4a8 commit 1a67714

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

site/scripts/docs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ const commandListSubCommandDisplay = function (commands) {
100100
let table = '| Subcommand | description |\n'
101101
table += '|:--------------------------- |:-----|\n'
102102
commands.forEach((cmd) => {
103-
const [commandBase] = cmd.name.split(':')
103+
let commandBase
104+
commandBase = cmd.name.split(':')[0]
105+
if (cmd.parent) {
106+
commandBase = cmd.parent
107+
}
104108
const baseUrl = `/commands/${commandBase}`
105109
const slug = cmd.name.replace(/:/g, '')
106110
table += `| [\`${cmd.name}\`](${baseUrl}#${slug}) | ${cmd.description.split('\n')[0]} |\n`

site/scripts/util/generate-command-data.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ const parseCommand = function (command) {
3535
}, {})
3636

3737
return {
38+
parent: command.parent?.name() !== "netlify" ? command.parent?.name() : undefined,
3839
name: command.name(),
3940
description: command.description(),
40-
commands: commands
41-
42-
.filter((cmd) => cmd.name().startsWith(`${command.name()}:`) && !cmd._hidden)
43-
.map((cmd) => parseCommand(cmd)),
41+
commands: [
42+
...command.commands.filter(cmd => !cmd._hidden).map(cmd => parseCommand(cmd)),
43+
...commands.filter((cmd) => cmd.name().startsWith(`${command.name()}:`) && !cmd._hidden).map(cmd => parseCommand(cmd))
44+
],
4445
examples: command.examples.length !== 0 && command.examples,
4546
args: args.length !== 0 && args,
4647
flags: Object.keys(flags).length !== 0 && flags,

0 commit comments

Comments
 (0)