Skip to content

Commit b86f513

Browse files
committed
docs/yaml: add TODO for conditionally skipping root command
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent c509ef7 commit b86f513

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

docs/yaml/yaml.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,23 @@ func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string
7373
return err
7474
}
7575
}
76-
if !cmd.HasParent() {
77-
return nil
78-
}
76+
77+
// TODO: conditionally skip the root command (for plugins)
78+
//
79+
// The "root" command used in the generator is just a "stub", and only has a
80+
// list of subcommands, but not (e.g.) global options/flags. We should fix
81+
// that, so that the YAML file for the docker "root" command contains the
82+
// global flags.
83+
//
84+
// If we're using this code to generate YAML docs for a plugin, the root-
85+
// command is even less useful; in that case, the root command represents
86+
// the "docker" command, and is a "dummy" with no flags, and only a single
87+
// subcommand (the plugin's top command). For plugins, we should skip the
88+
// root command altogether, to prevent generating a useless YAML file.
89+
// if !cmd.HasParent() {
90+
// return nil
91+
// }
92+
7993
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".yaml"
8094
filename := filepath.Join(dir, basename)
8195
f, err := os.Create(filename)

0 commit comments

Comments
 (0)