Skip to content

Commit 8024b90

Browse files
committed
Document project-specific command root generation function
The function that creates the Cobra CLI command root is declared by each project, and so might have any name. The "docsgen" program that generates the command line reference content for the website calls this function, so it will be necessary for the appropriate function to be added to the program when it is added to a project. Previously, there was no documentation of this project-specific component of the "template", which could result in confusion when it was applied to a project that happens to have a different function name from the `cli.NewCommand()` used by the "template" docsgen code.
1 parent c45bb9e commit 8024b90

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

workflow-templates/assets/cobra/docsgen/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func main() {
3131

3232
os.MkdirAll(os.Args[1], 0755) // Create the output folder if it doesn't already exist
3333

34+
// TODO: Replace `cli.NewCommand()` with the project's Cobra CLI package function for command root
3435
cli := cli.NewCommand()
3536
cli.DisableAutoGenTag = true // Disable addition of auto-generated date stamp
3637
err := doc.GenMarkdownTree(cli, os.Args[1])

workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ If there are any additional documentation generation tasks, add them to the `doc
4545
#### `docsgen`
4646

4747
- [`go.mod`](assets/cobra/docsgen/go.mod) - replace `MODULE_NAME` with the project's module name.
48-
- [`main.go`](assets/cobra/docsgen/main.go) - replace `CLI_PACKAGE_NAME` with the project's Cobra CLI package name
48+
- [`main.go`](assets/cobra/docsgen/main.go)
49+
- replace `CLI_PACKAGE_NAME` with the project's Cobra CLI package name
50+
- replace `cli.NewCommand()` with the project's Cobra CLI package function for [command root](https://github.com/spf13/cobra/blob/master/user_guide.md#create-rootcmd) generation
4951

5052
Run the following command from the `docsgen/` folder:
5153

0 commit comments

Comments
 (0)