Commit Graph

50 Commits

Author SHA1 Message Date
dbf85f6104 Update gopkg.in/yaml.v2 to gopkg.in/yaml.v3 (#1766)
API v3 was released in 2019 [1]. Update from the v2 API, no changes to
the packages's use needed and no breaking changes expected.

[1] https://ubuntu.com/blog/api-v3-of-the-yaml-package-for-go-is-available
2022-08-13 16:18:46 -06:00
7790bf97fd fix: correct command path in see_also for YAML doc (#1771)
The `see_also` section for child commands would include only the name of
the commands. This adds the whole path, similar to how it's done for the
other documentation formats.
2022-08-13 17:31:45 -04:00
ffa8860dbe Change links from http:// to https:// (#1695) 2022-05-17 14:28:13 -04:00
25f5bb5f97 Prefer ReplaceAll instead of Replace(..., -1) (#1530) 2022-05-14 14:10:36 -06:00
2a5277810f go.mod: cpuguy83/go-md2man/v2 v2.0.1 (#1460)
full diff: https://github.com/cpuguy83/go-md2man/compare/v2.0.0...v2.0.1

- Fix handling multiple definition descriptions
- Fix inline markup causing table cells to split
- Remove escaping tilde character (prevents tildes (`~`) from disappearing).
- Do not escape dash, underscore, and ampersand (prevents ampersands (`&`) from disappearing).
- Ignore unknown HTML tags to prevent noisy warnings

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-05 11:08:25 -06:00
652c755d37 Use golangci-lint (#1044)
Use golangci-lint. Repair warnings and errors resulting from linting.
2021-02-07 17:08:50 -07:00
ff416ad438 Revert "Add the ability to specify a filePostpender in GenMarkdownTreeCustom (#1270)" (#1317)
This reverts commit 23a6174c7f.
2021-01-23 16:05:55 -07:00
23a6174c7f Add the ability to specify a filePostpender in GenMarkdownTreeCustom (#1270) 2021-01-20 20:33:16 -07:00
86f8bfd7fe fix manpage building with new go-md2man (#1255)
This addresses #1049 by changing the format of the generated
Markdown input.
2020-10-18 12:59:26 -06:00
02a0d2fbc9 doc: GenMarkdown skip Synopsis on empty long cmd (#1207)
This patch modifies the GenMarkdownCustom to skip writing a Synopsis
header with the `cmd.Short` duplicated both before and after the header.

Instead, it only writes the `### Synopsis` header and the paragraph when
a `cmd.Long` has some kind of content in it.

Adds `TestGenMdDocWithNoLongOrSynopsis` as the test case.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
2020-08-26 09:18:51 -06:00
a0b86e58f8 Correct a typo in doc/util.go (#1184) 2020-08-10 22:17:29 -06:00
ed7b60e298 YAML documentation contains "Usage" (#1037) 2020-06-15 16:51:03 -06:00
e392f3204d Man pages won't have auto gen tag when option is disabled (#1104)
* Man pages wont have  auto gen tag when option is disabled

- this addresses #741

* Add documentation for doc generation and a changelog
2020-04-29 11:15:55 -06:00
b04b5bfc50 substitute wrong word in md_docs (#998) 2019-12-02 08:04:30 -05:00
77e4d5aecc Update md2man to v2.0.0 (#977)
Fixes #805
2019-10-19 16:17:41 -06:00
fe5e611709 doc: obey SOURCE_DATE_EPOCH with manpage generation (#735)
Previously if a cobra user didn't specify an explicit .Date header, the
current time would be included in all of the generated man pages each
time they were built. This causes an issue for reproducible builds,
since each re-build of a package that includes the man pages will have
different times listed in the man pages.

To fix this, add support for SOURCE_DATE_EPOCH (which is a standardised
packaging environment variable, designed to be used specifically for
this purpose[1]).

[1]: https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2018-10-21 10:11:14 -04:00
ff0d02e855 fix typo in doc/man_docs.go (#732) 2018-08-20 13:45:24 -04:00
0ab5b6bcfc doc: hide hidden parent flags (#686)
* fixes #685
2018-04-24 12:15:12 -04:00
3a5f27b046 doc: Add a necessary blank line after SEE ALSO (#592)
Signed-off-by: Allen Sun <shlallen1990@gmail.com>
2017-12-04 11:43:02 +01:00
45a52e208c doc: Remove one additional blank line after Synopsis (#591)
Signed-off-by: Allen Sun <shlallen1990@gmail.com>
2017-12-04 10:21:50 +01:00
2da4a54c5c Improve tests in doc/ 2017-11-09 07:56:43 +01:00
419e0f8d51 doc: add ReST doc generation (#537) 2017-10-07 19:39:47 +02:00
ca57f0f5db doc: Ad help flag and cmd when generating docs 2017-05-20 19:28:06 +02:00
6bfe2ba1a2 doc: Add docs 2017-05-09 11:14:48 +02:00
6dd90846ba doc: Use w.Write instead of fmt in yaml_docs
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenYamlToFile-4         62488         61622         -1.39%

benchmark                        old allocs     new allocs     delta
BenchmarkGenYamlToFile-4         121            120            -0.83%

benchmark                        old bytes     new bytes     delta
BenchmarkGenYamlToFile-4         26706         26280         -1.60%
2017-04-26 21:30:17 +02:00
97af803f3b doc: Cleanup md_docs
Performance gain:
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenMarkdownToFile-4     23096         10295         -55.43%

benchmark                        old allocs     new allocs     delta
BenchmarkGenMarkdownToFile-4     47             48             +2.13%

benchmark                        old bytes     new bytes     delta
BenchmarkGenMarkdownToFile-4     1984          2832          +42.74%
2017-04-26 21:30:17 +02:00
de484eefb4 doc: Refactor man docs
Performance impact (very strange):
benchmark                        old ns/op     new ns/op     delta
BenchmarkGenManToFile-4          30037         29001         -3.45%

benchmark                        old allocs     new allocs     delta
BenchmarkGenManToFile-4          77             89             +15.58%

benchmark                        old bytes     new bytes     delta
BenchmarkGenManToFile-4          9075          9651          +6.35%
2017-04-26 21:30:17 +02:00
f95d58bdf3 Fix #401 (#402)
* doc: Add and edit docs

* doc: Add tests
2017-04-19 14:39:58 +02:00
6421115516 doc: Fix govet complaints (#408) 2017-04-01 15:45:39 -05:00
0960ff7fa9 Rename IsHelpCommand to IsAdditionalHelpTopicCommand (#398)
Fixes #393
2017-03-09 10:37:15 -05:00
35136c09d8 Added support for yaml ouptut in docs gen (#380)
Signed-off-by: French Ben <frenchben@docker.com>
2017-01-30 16:45:31 -05:00
1dd5ff2e11 Make SEE ALSO references and generated file names agree with each other. 2016-12-29 00:59:22 -07:00
6b74a60562 Update doc/man_docs.md (#363) 2016-11-15 09:16:05 -05:00
67feb8173c Add support for setting a function to handle flag parsing errors.
The default pflag error is to only print the bad flag. This enables an application
to include a usage message or other details about the error.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2016-10-10 10:56:48 -04:00
d1371ecdb4 gofmt, govet, run those in Travis, add 1.7 2016-08-23 13:30:43 -07:00
e291587027 Cretea a new GenManTree function that takes an options struct.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2016-06-21 14:47:14 -04:00
97206b3170 Use the correct man page section for the filename
Also make header mutation cleaner.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2016-06-21 14:30:54 -04:00
112c7dca3a Hide deprecated shorthand flags in man page generation. 2016-06-21 14:30:26 -04:00
29c0a1f42e Use the correct UseLine for the man page synposis.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2016-06-20 17:27:41 -04:00
719241171d Fixed typos in README and docstring 2016-06-07 11:50:48 +01:00
a0bd6c17b3 Fixing golint warnings
* Moving final return outside of if-else
* Removing type declarations that Go can infer from values
* Cleaning up some existing comments
* Changing snake_case variables to camelCase
2016-03-31 09:53:34 -04:00
57f473263e Add explicit doc.GenMan SEE ALSO test covering #229 2016-01-21 12:12:26 +11:00
cb8496d6b2 Ensure SEE ALSO list has no leading comma, fixing #229 2016-01-21 12:11:56 +11:00
356750645f Update doc generation examples. Fixes #227. 2016-01-17 11:29:42 +11:00
8e6aca4182 Use filepath.Join, not string math. Fixes #226. 2016-01-17 11:25:20 +11:00
5df1341f93 Treat write errors in man doc generation
Just like the last commit, but now for manpages.

genMan still works with a buffer and returns []byte instead of working
directly with an io.Writer. This is because, in turn, md2man takes byte
slices instead of readers and writers.

Wrapping genMan around a writer is unnecessary especially since it's not
an exported function, and also because we'd still need a buffer to get
the output bytes.
2016-01-06 12:25:27 +01:00
eb5040e69e Treat write errors in markdown doc generation
This code was already using io.Writer, but was completely ignoring write
errors.

The most worrying part is how GenMarkdownTreeCustom used an unnecessary
buffer to then dump all of its contents on a file, and instead of
returning an error on file creation/writing, it would just exit the
entire program.
2016-01-06 12:21:04 +01:00
ea06b29c10 Simplify GenMarkdownTreeCustom signature 2016-01-06 11:59:08 +01:00
5fa1003a36 Remove unused outs global var 2016-01-06 11:49:16 +01:00
b3f29e98e6 Issue #195: Move doc generation into separate pkg
* Move man_docs and md_docs into new doc pkg
* Replace *bytes.Buffer with io.Writer
* Replace c == cmd.helpCommand with c.IsHelpCommand()
* Remove redundant len(children) == 0 check in HasSeeAlso
* Duplicate test setup for doc generation
2015-12-24 09:01:59 -05:00