Move the manpage generation away from the binary
Since https://github.com/uutils/coreutils/pull/4459 we have now manpage generations
$ ./target/debug/coreutils manpage ls
we should do that a build time. Meaning that our binaries should not keep this capability.
how so?
Removing the generation from the binary makes the binary smaller, which is a priority for some people.
I mean, how should we Remove the generation from the binary?
Oh I see. It should probably be part of the uudoc binary. uudoc can be our one-stop shop for the documentation, manpages and maybe even shell-completion. Alternatively, it could be part of the build script somehow? Though I imagine that would be quite difficult. Feel free to check out how other projects do this with clap and propose other solutions.
so I assume I should just make the uudoc binary create another folder inside of the SRC folder called the man folder, generate the Roff files for every command and then save them into that folder
Yeah that sounds like a reasonable approach. Maybe the man folder should be inside of target?
I cloned the repo and added this code to the uudoc main function
let util_map = util_map();
for i in std::iter::once("coreutils")
.chain(util_map.keys().copied())
.map(|x| clap_mangen::Man::new(match x == "coreutils" {
true => gen_coreutils_app(&util_map),
false => util_map.get(x).unwrap().1()
})
) {
i.render(&mut io::stdout()).expect("Man page generation failed");
}
io::stdout().flush().unwrap();
(going to make it write to files later) it gives this error
error[E0283]: type annotations needed
--> src/bin/uudoc.rs:119:20
|
119 | let util_map = util_map();
| ^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `util_map`
|
= note: cannot satisfy `_: uucore::Args`
note: required by a bound in `util_map`
--> /home/mothy/coreutils/target/debug/build/coreutils-bbf9368098b96170/out/uutils_map.rs:3:16
|
3 | fn util_map<T: uucore::Args>() -> UtilityMap<T> {
| ^^^^^^^^^^^^ required by this bound in `util_map`
help: consider specifying the type argument in the function call
|
119 | let util_map = util_map::<T>();
| +++++
For more information about this error, try `rustc --explain E0283`.
error: could not compile `coreutils` due to previous error
excuse me if this is a dumb question but what type annotation should I use
There's a line in uudoc with this:
let utils = util_map::<Box<dyn Iterator<Item = OsString>>>();
It's a bit unfortunate that it's necessary, but this should solve it.
Another reason why this would be a good idea: it would be easier to cross compile.
Hey @sylvestre
Why is the coreutils binary is all utils + manpages + completions
Why about using uudoc to handle doc markdown (original) + manpages and completions ?
Linked with https://github.com/uutils/coreutils/pull/7841
In other words, why are they not files as same as locales?