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

Generate shell-completions and man pages in build.rs #93

Open
ducaale opened this issue Mar 7, 2021 · 1 comment
Open

Generate shell-completions and man pages in build.rs #93

ducaale opened this issue Mar 7, 2021 · 1 comment

Comments

@ducaale
Copy link
Owner

ducaale commented Mar 7, 2021

Although build.rs cannot import modules from xh, it is possible to use the include!() to paste the content of src/cli.rs into build.rs.

See https://kbknapp.dev/shell-completions/

@blyxxyz
Copy link
Collaborator

blyxxyz commented Mar 7, 2021

I considered doing it at build time, but I didn't like it.

build.rs generating files that are checked into source control is seemingly discouraged. cargo will refuse to upload if a build script changes the contents of src. You're supposed to put them in $OUT_DIR, which isn't ergonomic.

The man pages are generated with help2man, and I don't think we can expect everyone to have that installed.

OTOH ripgrep has build.rs generate completions and build a man page (with asciidoctor): https://github.com/BurntSushi/ripgrep/blob/3ca324fda75885bf3523762ed57811d80abb3b00/FAQ.md#does-ripgrep-have-a-man-page

It only generates the man page if it can find the tools. I didn't think of that.

But it has to do some work to find the files it generates: https://github.com/BurntSushi/ripgrep/blob/20534fad0404417487318dcc7d6fb5a91835a278/ci/cargo-out-dir

Not sure if this is a good idea, but it's worth another look.

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

No branches or pull requests

2 participants