Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-generate manpage, help docs, etc. #552

Closed
joshtriplett opened this issue Jun 30, 2016 · 81 comments · Fixed by #3174
Closed

Auto-generate manpage, help docs, etc. #552

joshtriplett opened this issue Jun 30, 2016 · 81 comments · Fixed by #3174
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-blocked Status: Blocked on something else such as an RFC or other implementation work.

Comments

@joshtriplett
Copy link
Contributor

joshtriplett commented Jun 30, 2016

Maintainer notes:


I'd love to have support to generate a manpage. This would use a mechanism and infrastructure similar to #376. Additional functions to override or augment portions of the generated manpage could come later, but I think with relatively few additions this could become an incredibly useful mechanism.

  • The manpage title should default to the bin_name value.
  • The section should default to 1.
  • The NAME section should default to bin_name \- about, where about is the string set by .about.
  • The SYNOPSIS section should contain the usage strings for the command and every subcommand.
  • The DESCRIPTION section would need some new paragraph-style information provided (also usable as a more structured .before_help).
  • The "OPTIONS" section should document the flags and args for the top-level command.
  • If the command has subcommands, a "SUBCOMMANDS" section should document each subcommand in a sub-section.
  • The AUTHORS section should contain the author information, if provided.
  • The SEE ALSO section would need some new mechanism to populate it.

I'd be happy to help with manpage markup, once I see the details of the mechanism used in #376.

@kbknapp
Copy link
Member

kbknapp commented Jun 30, 2016

I like this idea! I'll have a better idea about what all it would take once I finish #376 but I think it could be done. And if nothing else, it'll at least give a really good starting point that one could then tweak manually with little effort.

@joshtriplett
Copy link
Contributor Author

Absolutely. I'm also hoping that, similar to help2man (which doesn't handle most of what clap can do), this could support providing arbitrary additional documentation to integrate into the generated manpage. That would allow maintaining information in only one place (such as options and their documentation).

@kbknapp kbknapp added T: new feature E-hard Call for participation: Experience needed to fix: Hard / a lot labels Jun 30, 2016
@hgrecco
Copy link
Contributor

hgrecco commented Jul 3, 2016

I was thinking about the same thing recently and I think we can reuse much of the infrastructure done for the templated help. But I would also like to propose a different way to generate the man page (and access the completion). I am opening another issue for this.

@kbknapp kbknapp changed the title Auto-generate manpage Auto-generate manpage, help docs, etc. Nov 2, 2016
@kbknapp
Copy link
Member

kbknapp commented Nov 2, 2016

Addressing this issue soon. I'd like to get the ability to generate man pages, help docs, etc. For the help docs, I'd especially like to be able to generate based off a template exactly like App::template works. Except recursively going through subcommands. The template would allow doing things like markdown, etc.

Also, for help docs I'd like to choice to split the files or use a single document.

@kbknapp kbknapp added C: help pages gen and removed E-hard Call for participation: Experience needed to fix: Hard / a lot labels Nov 2, 2016
@matthiasbeyer
Copy link
Contributor

matthiasbeyer commented Jun 1, 2017

As far as I can see, this was moved to the 3.x release for clap? Either way, I'd like to pronounce interest in this feature. Not only for git-dit but also for imag.

@kbknapp
Copy link
Member

kbknapp commented Jun 16, 2017

@matthiasbeyer yes, this is a feature I want, but need to get 3.x out the door first because otherwise it'll just keep getting pushed off and pushed off.

@valpackett
Copy link

Since clap has plenty of information about the structure of commands and args and whatnot, it should be possible to build pages in the mdoc language, which is semantic (i.e. it has entities like "flags" and "commands" instead of just "bold text" etc.)

intgr referenced this issue in rust-cli/book Mar 22, 2021
* Adding a draft chapter about documentation with man

* Fixing some wordings and typos

* 🐀 and 💀 are not the same thing
JoelMon added a commit to JoelMon/scriptx that referenced this issue Jul 5, 2021
- Close #24 - Reworded cut to extract in the deb `control` file and other places.
- Instead of modifying a static man file, `make-deb` generates and compresses the man file. The man file created isn't perfect but it's better than having the man page to by out of sync with development. **NOTE:** With [Clap 3](clap-rs/clap#552) man pages generation should be possible.:w
- Replaced clap's description string with the `crate_description` macro. The `--help` application description will be the same as the one in `Cargo.toml`.
- Tweaked the wording in the `-v` option help string.
@pksunkara pksunkara removed the W: 3.x label Aug 13, 2021
@epage epage added C-enhancement Category: Raise on the bar on expectations S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed T: new feature labels Dec 8, 2021
@epage epage added A-help Area: documentation, including docs.rs, readme, examples, etc... and removed A-completion Area: completion generator labels Dec 13, 2021
@sondr3 sondr3 mentioned this issue Dec 14, 2021
4 tasks
epage pushed a commit that referenced this issue Jan 28, 2022
This is an initial implementation with plenty of room to grow, including
- Allowing pulling out a subset of the generated man page for greater customization
- Subcommand handling
- Extra sections
- Consolidate argument formatter after #2914

Fixes #552
@Dzordzu
Copy link

Dzordzu commented Apr 12, 2022

Is there any way to generate json schema from the command?

@epage
Copy link
Member

epage commented Apr 12, 2022

At this time, we do not. The issue for that is #918.

The clap-serde project could be a good place for this. See aobatact/clap-serde#11.

@tgross35
Copy link
Contributor

For anyone like me who stumbles across this long issue but can't find the correct answer: the official crate is clap_mangen (it's not mentioned anywhere on this thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations S-blocked Status: Blocked on something else such as an RFC or other implementation work.
Projects
None yet
Development

Successfully merging a pull request may close this issue.