-
Notifications
You must be signed in to change notification settings - Fork 9
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
Document full use-case (e.g., build.rs
script)
#33
Comments
After experimenting a bit, I think that the method I suggested above (with the Specifically, I think we should suggest that users have a file like this in // /src/bin/generate-docs.rs
use man::prelude::*;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let page = Manual::new("basic")
.about("A basic example")
.author(Author::new("Alice Person").email("alice@person.com"))
.author(Author::new("Bob Human").email("bob@human.com"))
.flag(
Flag::new()
.short("-d")
.long("--debug")
.help("Enable debug mode"),
)
.flag(
Flag::new()
.short("-v")
.long("--verbose")
.help("Enable verbose mode"),
)
.option(
Opt::new("output")
.short("-o")
.long("--output")
.help("The file path to write output to"),
)
.example(
Example::new()
.text("run basic in debug mode")
.command("basic -d")
.output("Debug Mode: basic will print errors to the console")
)
.custom(
Section::new("usage note")
.paragraph("This program will overwrite any file currently stored at the output path")
)
.render();
let mut file = File::create('./docs/MY_APP.1)
.expect("Should be able to open file in project directory");
file.write_all(page.as_bytes())
.expect("Should be able to write to file in project directory");
} And then have something like this in their makefile: .PHONY : install
install :
cargo build --release
cargo run --bin generate-docs
sudo install -m 0755 -v ./target/release/MY_APP /usr/local/bin/MY_APP
# man page
sudo cp ./docs/MY_APP.1 /usr/local/share/man/man1/MY_APP.1
# Other install commands (Zsh completions/etc.)
.PHONY : uninstall
uninstall :
sudo rm -f /usr/local/bin/MY_APP
sudo rm -f /usr/local/share/man/man1/MY_APP.1 Unless someone thinks this is a bad idea, I'll write it up up as a PR soon. |
@codesections the way I thought of using this is by auto-generating man pages from CLI options (e.g. as per clap-rs/clap_generate#1, example). I guess with fewer steps, and no makefile needed. There's certainly some open questions about packaging things up, but that also applies to other files such as autocomplete definitions. I think those fall within the scope of the rust-clique packaging issue. |
@yoshuawuyts Yeah, totally agreed that integrating with Clap is the long-term goal. My understanding, though, it that clap integration is blocked pending Clap v3.0.0. My thought was that we should have some documentation about how to actually go from "I've downloaded But if you don't think that's useful, I'm happy to close this issue. |
Where is Clap integration at now that v3 is out? BTW I'd be happy to provide docs for how to package a man page using autotools for Rust projects — an arrangement I think provides a lot that |
In clap-rs/clap#3174,. we are leaning towards calling roff-rs directly rather than going through |
In discussing #31, @yoshuawuyts mentioned that we might be calling
man
differently. That made me realize that we don't have any documentation about the typical way to callman
(e.g., at run time, in abuild.rs
script, or using an external tool. I propose adding something to the README that outlines callingman
from abuild.rs
file, saving the generated file to theOUT_DIR
and then (separately) installing the generated man page with make. I'm suggesting something like this be added to the README:Example
First, generate a man page and save it to disk as part of your compilation using a
build.rs
file.And then add a
makefile
to install the generated man pageend example
Two questions on this:
build.rs
+makefile
the procedure we want to recommend?The text was updated successfully, but these errors were encountered: