Skip to content

Generate man page as markdown#462

Merged
ducaale merged 12 commits into
masterfrom
manpage-as-markdown
May 8, 2026
Merged

Generate man page as markdown#462
ducaale merged 12 commits into
masterfrom
manpage-as-markdown

Conversation

@ducaale
Copy link
Copy Markdown
Owner

@ducaale ducaale commented May 1, 2026

Since github doesn't support rendering roff files, we will use --generate markdown to generate xh.1.md which is then linked to from README.md. The markdown format is inspired by https://github.com/rtomayko/ronn/blob/master/man/ronn.1.ronn

I have also updated --generate man to output definitions using roff controls. This should improve how they are rendered in online man pages like https://man.archlinux.org/man/extra/xh/xh.1.en (See --pretty, --generate, etc)

Resolves #446

@ducaale
Copy link
Copy Markdown
Owner Author

ducaale commented May 8, 2026

This produces HTML that renders similar to https://man.archlinux.org/man/extra/xh/xh.1.en

mandoc -T html -O style=https://man.archlinux.org/static/archmanweb/man_page.css doc/xh.1

@ducaale ducaale requested a review from blyxxyz May 8, 2026 19:18
@blyxxyz
Copy link
Copy Markdown
Collaborator

blyxxyz commented May 8, 2026

With the new man format there are a few options that mandoc doesn't seem to hyperlink (compared to the old output where only -4/-6 aren't hyperlinked). I can't spot a pattern.

image

Overall the output does look a bit better.

Comment thread doc/xh.1.md
Comment on lines +75 to +77
- `-j`, `--json`: (default) Serialize data items from the command line as a JSON object.

Overrides both --form and --multipart.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to backtick --form and --multipart here (and so on for other option mentions and for examples). But that also applies to the existing man page formatting so it's very separable from this PR.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I would also like to format examples similar to https://man.archlinux.org/man/curl.1.en

Comment thread src/generation.rs Outdated
Comment thread src/cli.rs Outdated
Comment thread src/generation.rs
}

#[derive(Debug, PartialEq)]
enum ParsedHelp<'a> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the abstract format and the tests that showcase it, very clean.

ducaale and others added 2 commits May 8, 2026 22:03
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
@ducaale
Copy link
Copy Markdown
Owner Author

ducaale commented May 8, 2026

With the new man format there are a few options that mandoc doesn't seem to hyperlink

Interesting. It looks like the letters H/B/h/b/m are hyperlinked inside -p, --print=FORMAT so mandoc is not able to hyperlink any options that use those as short option.

@ducaale ducaale merged commit b928cf0 into master May 8, 2026
10 checks passed
@ducaale ducaale deleted the manpage-as-markdown branch May 8, 2026 21:31
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

Successfully merging this pull request may close these issues.

Combine README and man page

2 participants