#manpage #man #roff #troff

roffman

Crate to generate ROFF files used for manual pages

4 releases (breaking)

0.4.0 Nov 8, 2021
0.3.0 Aug 23, 2021
0.2.0 Aug 21, 2021
0.1.0 Aug 19, 2021

#8 in #man

Download history 1/week @ 2024-09-17 7/week @ 2024-09-24 4/week @ 2024-10-01

62 downloads per month
Used in mdbook-man

MIT license

51KB
1K SLoC

roffman

Build Status Docs

A crate to generate roff man pages.

Usage

Add the following to the Cargo.toml:

[dependencies]
roffman = "0.4"

Example

use roffman::{Roff, RoffNode, RoffNode, Roffable, SectionNumber, SynopsisOpt};

fn main() {
    let roff = Roff::new("roffman", SectionNumber::Miscellaneous)
    .date("August 2021")
    .section(
       "BASIC USAGE",
       [
           RoffNode::paragraph([
               "This is how you create a basic paragraph using roffman.",
           ]),
           RoffNode::indented_paragraph(
               [
                   "This line should be slightly indented to the ".roff(),
                   "right.".roff().bold(),
               ],
               Some(4),
               Some("optional-title")
           ),
           RoffNode::synopsis(
                    "roffman-command",
                    [
                    "This is the description of this command. It will be displayed right next to".roff(), " it".roff().italic()
]                     ,
                    [
                    SynopsisOpt::new("--opt").description(["some simple opt"]),
                    SynopsisOpt::new("--opt-with-arg").argument("ARG").description(["opt with an argument"]),
                    SynopsisOpt::new("--bold")
           ]),
           RoffNode::paragraph(["Example:".roff().bold()]),
           RoffNode::example([
               r#"
impl Roffable for u8 {
    fn roff(&self) -> RoffText {
        self.to_string().roff()
    }
}"#,
            ]),
           RoffNode::url("GitHub", "https://github.com/vv9k/roffman"),
           RoffNode::text("\nvv9k"),
           RoffNode::trademark_sign(),
            
        ],
    );

    let rendered = roff.to_string().unwrap();
    println!("{}", rendered);

}

Output:

.TH roffman 7 "August 2021"
.SH "BASIC USAGE"
.P
This is how you create a basic paragraph using roffman.
.IP optional\-title 4
This line should be slightly indented to the \fBright.\fR
.SY roffman\-command
This is the description of this command. It will be displayed right next to\fI it\fR

.OP \-\-opt
some simple opt

.OP \-\-opt\-with\-arg ARG
opt with an argument

.OP \-\-bold

.YS
.P
\fBExample:\fR
.EX

impl Roffable for u8 {
    fn roff(&self) \-> RoffText {
        self.to_string().roff()
    }
}
.EE
.UR https://github.com/vv9k/roffman
GitHub
.UE

vv9k\*(Tm

which will look something like this:

roffman(7)                                         Miscellaneous Information Manual                                  roffman(7)

BASIC USAGE
       This is how you create a basic paragraph using roffman.

           This line should be slightly indented to the right.

       roffman-command This is the description of this command. It will be displayed right next to it

                       [--opt] some simple opt

                       [--opt-with-arg ARG] opt with an argument

                       [--bold]

       Example:

       impl Roffable for u8 {
           fn roff(&self) -> RoffText {
               self.to_string().roff()
           }
       }
       GitHub ⟨https://github.com/vv9k/roffman⟩

       vv9k™

                                                              August 2021                                             roffman(7)

License

MIT

No runtime deps