-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add xtask to generate manpages #792
base: main
Are you sure you want to change the base?
Conversation
a8c7261
to
9cc75c5
Compare
I just realized the man pages don't/won't include an I think we can either do it in this PR or on a followup PR to reduce iterations |
9cc75c5
to
e4f9be7
Compare
This all looks fine to me but I think we should fix the EXAMPLES generation in this series and probably also add a CI job to generate the manpages. I assume this would be in this repo only as I guess the libraries and common CI code don't need to? |
e4f9be7
to
67ce622
Compare
The manpages now include an |
The following crates have manual pages built by default: | ||
|
||
- [`vhost-device-sound`](../vhost-device-sound), enabled by the default feature `vhost-device-sound`. | ||
- It can further be fine-tuned with the features `vhost-device-sound-pipewire` and `vhost-device-sound-alsa`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym here? can you add an example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that the generated CLI flags will only mention pipewire/alsa if the related features are enabled respectively. It's basically a way to select the vhost-device-sound {pipewire,alsa}
features.
Thank you for this tool. |
maybe we can exclude diff --git a/coverage_config_x86_64.json b/coverage_config_x86_64.json
index 79c169f..733dd59 100644
--- a/coverage_config_x86_64.json
+++ b/coverage_config_x86_64.json
@@ -1,5 +1,5 @@
{
"coverage_score": 86.60,
- "exclude_path": "",
+ "exclude_path": "xtask",
"crate_features": ""
} |
I was thinking the same, @epilys do you think it's something we can easily do? |
Currently, the main CLI struct type is defined in src/main.rs thus inaccessible when using the crate as a library. Move it to its own module under src/args.rs This will be useful for followup commits that will use src/args.rs directly to generate manual pages using clap_mangen Signed-off-by: Manos Pitsidianakis <[email protected]>
For information about the cargo xtask workflow pattern see: <https://github.com/matklad/cargo-xtask> This commit adds an xtask crate with only one task, "mangen", which generates a ROFF manual page under `target/dist/man` directory for the vhost-device-sound binary. The xtask crate can be configured using cargo features, to help packagers configure what manpages are generated. This generates a manpage in target/dist/man/vhost-device-sound.1 The rendered ROFF output looks like: vhost-device-sound(1) General Commands Manual vhost-device-sound(1) NAME vhost-device-sound - A virtio-sound device using the vhost-user protocol. SYNOPSIS vhost-device-sound <--socket> <--backend> [-h|--help] [-V|--version] DESCRIPTION A virtio-sound device using the vhost-user protocol. OPTIONS --socket=SOCKET vhost-user Unix domain socket path --backend=BACKEND audio backend to be used [possible values: null, pipewire, alsa] -h, --help Print help -V, --version Print version VERSION v0.2.0 REPORTING BUGS Report bugs to the project's issue tracker: https://github.com/rust-vmm/vhost-device vhost-device-sound 0.2.0 vhost-device-sound(1) Fixes rust-vmm#687 ("Add man page for vhost-device-sound") Resolves: rust-vmm#687 Signed-off-by: Manos Pitsidianakis <[email protected]>
Currently, the main CLI struct type is defined in src/main.rs thus inaccessible when using the crate as a library. Move it to its own module under src/args.rs This will be useful in the followup commit that will use src/args.rs directly to generate manual pages using clap_mangen from the xtask crate in this workspace. Signed-off-by: Manos Pitsidianakis <[email protected]>
Add vhost-device-scmi support for the mangen task in xtask binary. This generates a manpage in target/dist/man/vhost-device-scmi.1 The rendered ROFF output looks like: vhost-device-scmi(1) General Commands Manual vhost-device-scmi(1) NAME vhost-device-scmi - vhost-user SCMI backend device SYNOPSIS vhost-device-scmi <-s|--socket-path> [-d|--device] [--help-devices] [-h|--help] [-V|--version] DESCRIPTION vhost-user SCMI backend device OPTIONS -s, --socket-path=SOCKET_PATH vhost-user socket to use -d, --device=DEVICE Devices to expose --help-devices Print help on available devices -h, --help Print help -V, --version Print version VERSION v0.3.0 REPORTING BUGS Report bugs to the project's issue tracker: https://github.com/rust-vmm/vhost-device vhost-device-scmi 0.3.0 vhost-device-scmi(1) Fixes rust-vmm#697 ("Add man page for vhost-device-scmi") Resolves: rust-vmm#697 Signed-off-by: Manos Pitsidianakis <[email protected]>
Add documentation in a README.md file. Signed-off-by: Manos Pitsidianakis <[email protected]>
Add Packaging and distribution section that mentions the ability to generate manual pages using the xtask crate in this workspace. Signed-off-by: Manos Pitsidianakis <[email protected]>
Code blocks were in some kind of rSt format (?). Convert them to markdown. Signed-off-by: Manos Pitsidianakis <[email protected]>
Include "Examples" section from READMEs if they exist into the generated manual page. Signed-off-by: Manos Pitsidianakis <[email protected]>
I tried the same way I did it for scmi and sound but it looks like it needs more refactoring and is not as straightforward; the clap arg types depend on other config types such as |
67ce622
to
bbe6a4a
Compare
Yeah it should be easy. I will do it in a follow-up PR. |
For information about the cargo xtask workflow pattern see: https://github.com/matklad/cargo-xtask
This PR adds an
xtask
crate with only one task,mangen
, which generates a ROFF manual page undertarget/dist/man
directory for thevhost-device-sound
andvhost-device-scmi
binaries.The manual pages are placed in
target/dist/man/vhost-device-sound.1
andtarget/dist/man/vhost-device-scmi.1
.Future support for other crates in this repository is possible and provisioned for.
Fixes #687
Fixes #697
Demo: Rendered man pages as plain text
Generate the manpages:
Plain text rendered with:
man -l /path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-sound.1 | xclip
vhost-device-sound(1)
man -l /path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-scmi.1 | xclip
vhost-device-scmi(1)