Skip to main content

linuxutils_common/
man.rs

1//! Per-tool man page content shared with the man-page generator.
2//!
3//! `clap_mangen` produces NAME / SYNOPSIS / OPTIONS automatically from
4//! the clap derive. Anything richer — DESCRIPTION prose, EXAMPLES,
5//! NOTES, FILES, SEE ALSO — needs to be authored by hand and stitched
6//! into the rendered output by the generator.
7//!
8//! Each tool exposes a `pub const MAN: ManContent` describing what to
9//! splice in. Bodies are raw groff (`.SH`, `.TP`, `.B`, `.I`, etc.) so
10//! the generator can write them verbatim into the man page between the
11//! auto-generated sections.
12
13#[derive(Debug)]
14pub struct ManContent {
15    /// Replaces clap's auto-generated DESCRIPTION (which would otherwise
16    /// be the short `about` string from the derive). Plain text — the
17    /// generator wraps it in `.SH DESCRIPTION` itself.
18    pub description: Option<&'static str>,
19
20    /// Sections appended after OPTIONS, in the order given. Each entry
21    /// is `(uppercase title, raw groff body)`. Conventional ordering:
22    /// EXAMPLES, FILES, ENVIRONMENT, NOTES, BUGS, SEE ALSO.
23    pub extra_sections: &'static [(&'static str, &'static str)],
24}
25
26impl ManContent {
27    pub const fn empty() -> Self {
28        Self {
29            description: None,
30            extra_sections: &[],
31        }
32    }
33}