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

Function main

app/cli/documentation/generate.go:50–75  ·  view source on GitHub ↗

go:generate go run ./generate.go ./

()

Source from the content-addressed store, hash-verified

48
49//go:generate go run ./generate.go ./
50func main() {
51 if len(os.Args) != 2 {
52 log.Fatal("Required argument: cli docs output directory")
53 }
54 out := os.Args[1]
55
56 command := cmd.NewRootCmd(zerolog.Nop())
57 command.Use = "chainloop [command]"
58 command.DisableAutoGenTag = true
59
60 var builder strings.Builder
61 for _, subCmd := range command.Commands() {
62 if !subCmd.Hidden && !isPluginCommand(subCmd) {
63 // Start depth at 0 for subcommands
64 generateCommandDocs(subCmd, &builder, 0)
65 }
66 }
67
68 formatted := processFinalDocument(builder.String())
69 withHeader := fmt.Sprintf("%s%s", fileHeader, formatted)
70
71 err := os.WriteFile(filepath.Join(out, "cli-reference.mdx"), []byte(withHeader), 0600)
72 if err != nil {
73 log.Fatal(err)
74 }
75}
76
77// generateCommandDocs recursively generates documentation for a command and its subcommands.
78func generateCommandDocs(cmd *cobra.Command, builder *strings.Builder, currentDepth int) {

Callers

nothing calls this directly

Calls 5

NewRootCmdFunction · 0.92
isPluginCommandFunction · 0.85
generateCommandDocsFunction · 0.85
processFinalDocumentFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected