MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / generateCommandDocs

Function generateCommandDocs

app/cli/documentation/generate.go:78–93  ·  view source on GitHub ↗

generateCommandDocs recursively generates documentation for a command and its subcommands.

(cmd *cobra.Command, builder *strings.Builder, currentDepth int)

Source from the content-addressed store, hash-verified

76
77// generateCommandDocs recursively generates documentation for a command and its subcommands.
78func generateCommandDocs(cmd *cobra.Command, builder *strings.Builder, currentDepth int) {
79 var cmdBuffer strings.Builder
80 // Generate base documentation
81 if err := doc.GenMarkdown(cmd, &cmdBuffer); err != nil {
82 log.Fatal(fmt.Errorf("failed to generate documentation: %w", err))
83 }
84 processed := processCommand(cmdBuffer.String(), currentDepth)
85 builder.WriteString(processed)
86
87 // Recursively process subcommands with increased depth
88 for _, subCmd := range cmd.Commands() {
89 if !subCmd.Hidden && !isPluginCommand(subCmd) {
90 generateCommandDocs(subCmd, builder, currentDepth+1)
91 }
92 }
93}
94
95// processCommand processes the command documentation, filtering out unnecessary sections and formatting headers.
96func processCommand(content string, depth int) string {

Callers 1

mainFunction · 0.85

Calls 3

processCommandFunction · 0.85
isPluginCommandFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected