Generate man pages from the Command description#23825
Conversation
|
@dnephin failures are real |
cd79a09 to
90982d3
Compare
|
@dnephin Do you know why we need go-md2man in main Dockerfile? |
|
LGTM |
|
hum, |
|
I was waiting for the spf13/cobra PR (which included some bug fixes for this) to get merged before tagging. I has been merged now, so I'll update the sha here. |
90982d3 to
8c9fa36
Compare
|
Fixed the tag. I'm using |
|
I think the representation of options with arguments in the synopsis is wrong. in order to describe both legal syntax variants Here is an example from the generated man pages: This means that $ docker run --net
flag needs an argument: --netThe wrong syntax is also used in most current static man pages, so I understand why the generated output picked up this syntax. This is a good moment to tidy this up. |
|
Please ignore my previous comment. |
8c9fa36 to
390221a
Compare
api/client/volume/inspect.go
Outdated
There was a problem hiding this comment.
https:// ?
There was a problem hiding this comment.
Fixed, this was just copied from the old markdown man page
390221a to
9f677e5
Compare
|
That's really awesome 👍 LGTM (cc @tianon @SvenDowideit who might be interested too). |
|
LGTM - we'll want to consume this into the cli docs eventually too |
|
I'm still a bit on the fence on this one. I'm happy with it being generated
|
api/client/volume/create.go
Outdated
There was a problem hiding this comment.
Should we stick to 80-chars for these strings as well, to be consistent with our markdown?
There was a problem hiding this comment.
I copied this from the markdown without reformatting it. So it is consistent with the old markdown at least :)
There was a problem hiding this comment.
We stick to 80 chars, perhaps this slipped through during review, but let's not inherit that mistake
|
I kinda like that but I'm wondering how to handle more complicated manpages, like There is also some manpages where we have an So I'm torn 😅. I like that but I feel we should see how to handle these more complex command manpages before doing anything. |
|
If we need additional text, we can add it to the description. It's not uncommon for man pages to have sections for things that require more explanation. If we really want a more verbose man page for some commands we can keep the The default should really be automatic generation from the source. If that's insufficient for some flags or commands we have the ability to extend the generated docs, but I think that is more the exception than the rule.
This is an excellent example. We can document that by adding the following section to the description: Putting this detail into a section in the description gives us more space to describe things.
cobra supports the example section as well. I use it in this PR for
Hopefully that covers it, but if not I'd be happy to provide more examples. |
9f677e5 to
5116bdc
Compare
5116bdc to
ee3f562
Compare
|
@thaJeztah any outstanding concerns on this? |
Use the generate.sh script instead of md2man directly. Update Dockerfile for generating man pages. Signed-off-by: Daniel Nephin <[email protected]>
… pages. Signed-off-by: Daniel Nephin <[email protected]>
Signed-off-by: Daniel Nephin <[email protected]>
ee3f562 to
47cca88
Compare
|
@dnephin I still have concerns, but perhaps the best way is to test/try it and see if it works well in our workflow. We can evaluate after a while. So "lgtm" |
|
@dnephin really appreciated though, please don't take it the wrong way 👍 |
|
Alright let's go for it then 😇 LGTM |
|
Not sure if we want to cherry-pick this. @tiborvass @thaJeztah Adding the label, but up to you! |
spf13/cobraincludes support for generating a man page. It makes use ofcpuguy83/go-md2manwhich we already use to generate the existing man pages from markdown.The cobra generated man page is very similar to the output of our current generation. There are a few small differences. If any of them are considered to be significant, we can update the generation code to output what we want.
Notable differences:
SYNOPSISstring only saysOPTIONSinstead of the full list of flagsdocker volume,docker network, etc) lists the child commands under "SEE ALSO" on a single line, instead of listing them out one-per-line in a "COMMANDS" sectionBy keeping the command description and examples in the code it should make it easier to keep the man pages up-to-date and accurate. It makes it easier to add new commands, as we can generate the man pages automatically without adding any new files. We can also use this
Long(description) text to generate the command reference used by the online docs.The existing markdown files have not been removed. They will override the generated files if one exists for the same command. If the design of this PR is accepted I can start moving the text for more of the commands into the code.
This PR makes the following changes:
man/Dockerfileto include all the new required dependenciesman/generate.shto generate all the man pagesvolumecommands, and move the description into theCommand.Longfield.Longdescription to the commands.cc @cpuguy83, @icecrime