forked from TrueCloudLab/frostfs-node
[#578] gendoc: Allow to customize man pages
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
082370583f
commit
b02a1a34c1
4 changed files with 22 additions and 9 deletions
|
@ -45,7 +45,7 @@ func init() {
|
|||
rootCmd.AddCommand(storagecfg.RootCmd)
|
||||
|
||||
rootCmd.AddCommand(autocomplete.Command("frostfs-adm"))
|
||||
rootCmd.AddCommand(gendoc.Command(rootCmd))
|
||||
rootCmd.AddCommand(gendoc.Command(rootCmd, gendoc.Options{}))
|
||||
}
|
||||
|
||||
func Execute() error {
|
||||
|
|
|
@ -85,7 +85,7 @@ func init() {
|
|||
rootCmd.AddCommand(objectCli.Cmd)
|
||||
rootCmd.AddCommand(containerCli.Cmd)
|
||||
rootCmd.AddCommand(tree.Cmd)
|
||||
rootCmd.AddCommand(gendoc.Command(rootCmd))
|
||||
rootCmd.AddCommand(gendoc.Command(rootCmd, gendoc.Options{}))
|
||||
}
|
||||
|
||||
func entryPoint(cmd *cobra.Command, _ []string) {
|
||||
|
|
|
@ -38,7 +38,7 @@ func init() {
|
|||
blobovnicza.Root,
|
||||
meta.Root,
|
||||
writecache.Root,
|
||||
gendoc.Command(command),
|
||||
gendoc.Command(command, gendoc.Options{}),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,25 @@ const (
|
|||
extensionFlag = "extension"
|
||||
)
|
||||
|
||||
// Options for doc generation.
|
||||
type Options struct {
|
||||
// Parameters for man generation. By default use (1) section and `FrostFS` source.
|
||||
ManHeader *doc.GenManHeader
|
||||
}
|
||||
|
||||
func (o *Options) fillDefaults() {
|
||||
if o.ManHeader == nil {
|
||||
o.ManHeader = &doc.GenManHeader{
|
||||
Section: "1",
|
||||
Source: "FrostFS",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Command returns command which generates user documentation for the argument.
|
||||
func Command(rootCmd *cobra.Command) *cobra.Command {
|
||||
func Command(rootCmd *cobra.Command, opts Options) *cobra.Command {
|
||||
opts.fillDefaults()
|
||||
|
||||
gendocCmd := &cobra.Command{
|
||||
Use: "gendoc <dir>",
|
||||
Short: "Generate documentation for this command",
|
||||
|
@ -65,11 +82,7 @@ In this case there is a number of helper functions which can be used:
|
|||
case gendocMarkdown:
|
||||
return doc.GenMarkdownTree(rootCmd, args[0])
|
||||
case gendocMan:
|
||||
hdr := &doc.GenManHeader{
|
||||
Section: "1",
|
||||
Source: "FrostFS",
|
||||
}
|
||||
return doc.GenManTree(rootCmd, hdr, args[0])
|
||||
return doc.GenManTree(rootCmd, opts.ManHeader, args[0])
|
||||
default:
|
||||
return errors.New("type must be 'md' or 'man'")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue