Man pages won't have auto gen tag when option is disabled (#1104)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Man pages wont have auto gen tag when option is disabled - this addresses #741 * Add documentation for doc generation and a changelog
authored by John McBride · committed by GitHub · parent 41fd44e · Browse files · 5 files·+40 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+40 added−8 removed
- other:+40 added−8 removed
Provenance
- Commit
e392f32- Tree
144d307- Author
John McBride <jmcbride@pivotal.io>- Committer
GitHub <noreply@github.com>- Parent
41fd44e
5 files changed+40 added−8 removed
modified:doc/man_docs_test.go+2 added
99 unmodified lines100 output := buf.String()101 102 unexpected := translate("#HISTORY")103 checkStringOmits(t, output, unexpected)104+ unexpected = translate("Auto generated by spf13/cobra")105+ checkStringOmits(t, output, unexpected)106 }107 108 func TestGenManSeeAlso(t *testing.T) {109 rootCmd := &cobra.Command{Use: "root", Run: emptyRun}106 unmodified linesmodified:doc/man_docs.go+3 added-3 removed
103 unmodified lines104 func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {105 if header == nil {106 header = &GenManHeader{}107 }108- if err := fillHeader(header, cmd.CommandPath()); err != nil {108+ if err := fillHeader(header, cmd.CommandPath(), cmd.DisableAutoGenTag); err != nil {109 return err110 }111 112 b := genMan(cmd, header)113 _, err := w.Write(md2man.Render(b))114 return err115 }116 117-func fillHeader(header *GenManHeader, name string) error {117+func fillHeader(header *GenManHeader, name string, disableAutoGen bool) error {118 if header.Title == "" {119 header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))120 }121 if header.Section == "" {10 unmodified lines132 }133 header.Date = &now134 }135 header.date = (*header.Date).Format("Jan 2006")136- if header.Source == "" {136+ if header.Source == "" && !disableAutoGen {137 header.Source = "Auto generated by spf13/cobra"138 }139 return nil140 }107 unmodified linesadded:doc/README.md+12 added
123456789101112# Documentation generation
- [Man page docs](./man_docs.md)- [Markdown docs](./md_docs.md)- [Rest docs](./rest_docs.md)- [Yaml docs](./yaml_docs.md)
## Options### `DisableAutoGenTag`You may set `cmd.DisableAutoGenTag = true`to _entirely_ remove the auto generated string "Auto generated by spf13/cobra..."from any documentation source.added:CHANGELOG.md+22 added
12345678910111213141516171819202122# Cobra Changelog
## Pending* Fix man page doc generation - no auto generated tag when `cmd.DisableAutoGenTag = true` @jpmcb
## v1.0.0Announcing v1.0.0 of Cobra. 🎉**Notable Changes*** Fish completion (including support for Go custom completion) @marckhouzam* API (urgent): Rename BashCompDirectives to ShellCompDirectives @marckhouzam* Remove/replace SetOutput on Command - deprecated @jpmcb* add support for autolabel stale PR @xchapter7x* Add Labeler Actions @xchapter7x* Custom completions coded in Go (instead of Bash) @marckhouzam* Partial Revert of #922 @jharshman* Add Makefile to project @jharshman* Correct documentation for InOrStdin @desponda* Apply formatting to templates @jharshman* Revert change so help is printed on stdout again @marckhouzam* Update md2man to v2.0.0 @pdf* update viper to v1.4.0 @umarcor* Update cmd/root.go example in README.md @jharshmanmodified:README.md+1 added-5 removed
716 unmodified lines717 ```718 719 ## Generating documentation for your command720 721-Cobra can generate documentation based on subcommands, flags, etc. in the following formats:721+Cobra can generate documentation based on subcommands, flags, etc. Read more about it in the [docs generation documentation](doc/README.md).722 723-- [Markdown](doc/md_docs.md)724-- [ReStructured Text](doc/rest_docs.md)725-- [Man Page](doc/man_docs.md)726-723 ## Generating bash completions724 725 Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible. Read more about it in [Bash Completions](bash_completions.md).726 18 unmodified lines