coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Move the manpage generation away from the binary

Open sylvestre opened this issue 2 years ago • 10 comments

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.

sylvestre avatar Mar 05 '23 15:03 sylvestre

how so?

OHNONOTAMOTH avatar Mar 06 '23 18:03 OHNONOTAMOTH

Removing the generation from the binary makes the binary smaller, which is a priority for some people.

tertsdiepraam avatar Mar 06 '23 18:03 tertsdiepraam

I mean, how should we Remove the generation from the binary?

OHNONOTAMOTH avatar Mar 06 '23 18:03 OHNONOTAMOTH

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.

tertsdiepraam avatar Mar 06 '23 19:03 tertsdiepraam

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

OHNONOTAMOTH avatar Mar 07 '23 00:03 OHNONOTAMOTH

Yeah that sounds like a reasonable approach. Maybe the man folder should be inside of target?

tertsdiepraam avatar Mar 07 '23 08:03 tertsdiepraam

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

OHNONOTAMOTH avatar Mar 09 '23 03:03 OHNONOTAMOTH

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.

tertsdiepraam avatar Mar 09 '23 10:03 tertsdiepraam

Another reason why this would be a good idea: it would be easier to cross compile.

xbjfk avatar Oct 10 '24 09:10 xbjfk

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

Its-Just-Nans avatar May 08 '25 22:05 Its-Just-Nans

In other words, why are they not files as same as locales?

oech3 avatar Oct 14 '25 07:10 oech3