Comments (5)
After experimenting a bit, I think that the method I suggested above (with the build.rs
file) isn't a great approach and isn't really using build.rs
the way it is intended to be used. It also runs into cross-platform difficulties due to the non-portable nature of the find
command. After discussing the issue with @epage a bit, I now think that the best strategy is to use a separate binary and invoke it with cargo run --bin NAME
.
Specifically, I think we should suggest that users have a file like this in src/bin/
(basically the build.rs
script from above):
// /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("[email protected]"))
.author(Author::new("Bob Human").email("[email protected]"))
.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.
from man.
@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.
from man.
@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 man
and written my man page using it" to "I've successfully installed the man page so that a user can type man MY_APP
and see the man page." Right now, that isn't clear at all (at least not to me), so I was wondering if some documentation would be helpful for the time between now and whenever we can integrate more fully with clap.
But if you don't think that's useful, I'm happy to close this issue.
from man.
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 cargo
can't provide but I realize it's a bit unorthodox.
from man.
In clap-rs/clap#3174,. we are leaning towards calling roff-rs directly rather than going through man
.
from man.
Related Issues (17)
- Which sections should a man page have? HOT 3
- Have method for file path HOT 3
- Have "source" section
- Add DESCRIPTION section
- API design HOT 2
- The README example does not compile HOT 1
- Support for custom sections? HOT 3
- Improve `exit status` section HOT 5
- Add version/date API HOT 1
- Add examples API HOT 1
- Format example in README to show bold HOT 1
- Options with no "="
- update to roff 0.2? HOT 1
- Accept more types of positional arguments
- Design: how should we display subcommands? HOT 1
- Move clap v3 -> man glue code to clap_generate HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from man.