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

Add xtask to generate manpages #792

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

epilys
Copy link
Member

@epilys epilys commented Dec 7, 2024

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 under target/dist/man directory for the vhost-device-sound and vhost-device-scmi binaries.

The manual pages are placed in target/dist/man/vhost-device-sound.1 and target/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:

$ cargo xtask mangen
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/xtask mangen`
Generated the following manual pages:
/path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-sound.1
/path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-scmi.1

Plain text rendered with:

man -l /path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-sound.1 | xclip
vhost-device-sound(1)
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)
man -l /path/to/rust-vmm/vhost-device/target/dist/man/vhost-device-scmi.1 | xclip
vhost-device-scmi(1)
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)

@epilys epilys self-assigned this Dec 7, 2024
@epilys epilys force-pushed the xtasks-manpage-gen branch 2 times, most recently from a8c7261 to 9cc75c5 Compare December 7, 2024 09:41
@epilys
Copy link
Member Author

epilys commented Dec 7, 2024

I just realized the man pages don't/won't include an EXAMPLES section, oops.

I think we can either do it in this PR or on a followup PR to reduce iterations

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]>
@epilys epilys force-pushed the xtasks-manpage-gen branch from 9cc75c5 to e4f9be7 Compare December 10, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add man page for vhost-device-scmi Add man page for vhost-device-sound
1 participant