Skip to content

feat: man page#378

Merged
KSXGitHub merged 45 commits intomasterfrom
claude/add-man-page-generation-BKX0M
Mar 28, 2026
Merged

feat: man page#378
KSXGitHub merged 45 commits intomasterfrom
claude/add-man-page-generation-BKX0M

Conversation

@KSXGitHub
Copy link
Copy Markdown
Owner

@KSXGitHub KSXGitHub commented Mar 27, 2026

This PR adds support for generating and distributing Unix man pages for the pdu command. The man page is automatically generated from the CLI argument definitions using a clap's introspection APIs.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF

Add a `pdu-man-page` binary that generates a roff-formatted man page from
the clap command definition. The generated `exports/pdu.1` file is kept in
sync via a `sync_man_page` test, following the same pattern as completions
and help text. Update generate-completions.sh, deploy CI, test matrix, and
PKGBUILD templates to include the man page.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class Unix man page support for pdu by generating a deterministic exports/pdu.1 from the clap CLI definition, validating it in CI, and distributing it in release artifacts and packaging templates.

Changes:

  • Introduces a pdu-man-page generator binary (feature-gated) and wires it into generate-completions.sh.
  • Adds a sync test to ensure exports/pdu.1 stays up to date with CLI definitions; expands local/CI test runs to cover the new feature.
  • Updates release workflow and AUR PKGBUILD templates to ship/install the man page.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli/man_page.rs New binary to render the man page via clap_mangen.
exports/pdu.1 Checked-in generated man page content.
tests/sync_man_page.rs New sync test to enforce regeneration when CLI changes.
generate-completions.sh Regenerates the man page alongside other exported docs.
run.sh Enables the new feature when running generator binaries.
Cargo.toml Adds cli-man feature, clap_mangen dependency, and pdu-man-page bin target.
Cargo.lock Locks new transitive deps (clap_mangen, roff).
test.sh Adds a --features cli-man test pass.
.github/workflows/deploy.yaml Uploads pdu.1 as a release asset.
template/parallel-disk-usage/PKGBUILD Installs exports/pdu.1 into /usr/share/man/man1/.
template/parallel-disk-usage-bin/PKGBUILD Installs the versioned man page file into /usr/share/man/man1/.

Comment thread run.sh Outdated
Comment thread exports/pdu.1 Outdated
Comment thread tests/sync_man_page.rs
Comment thread .github/workflows/deploy.yaml
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 27, 2026

Performance Regression Reports

commit: 03b2f54

There are no regressions.

…nction

Move man page rendering into a shared `src/man_page.rs` module (gated on
`cli-man` feature) so both the binary and sync test use the same logic.
Replace the `.SH EXTRA` section header with `.SH EXAMPLES` in the
generated output.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Comment thread exports/pdu.1 Outdated
Comment thread exports/pdu.1 Outdated
claude and others added 4 commits March 28, 2026 01:50
Remove the redundant "Examples:" subheading and strip unnecessary
4-space indentation from the examples content in the generated man page.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Drop the clap_mangen dependency and write a custom man page renderer
that produces proper roff output. This fixes several formatting issues:
- DESCRIPTION section now uses .PP for paragraph breaks (copyright and
  sponsor lines no longer merge)
- EXAMPLES section uses .TP for description/command pairs with .nf/.fi
  for literal command rendering
- Boolean flags no longer show redundant "Possible values: true, false"
- Visible aliases are included in option headers

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
The man page module only needs clap (provided by the cli feature), so
there is no need for a separate cli-man feature. This matches how
pdu-usage-md requires only cli.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
@KSXGitHub KSXGitHub force-pushed the claude/add-man-page-generation-BKX0M branch from 8899187 to bdd1451 Compare March 28, 2026 03:08
claude and others added 17 commits March 28, 2026 05:04
Replace the simple stdout-only binary with a proper CLI that supports:
- `pdu-man-page generate roff 1` — render roff source to stdout
- `pdu-man-page generate man 1` — render man page via man(1) to stdout
- `pdu-man-page check roff 1` — verify exports/pdu.1 is up-to-date
- `pdu-man-page check man 1` — verify exports/pdu.1.man is up-to-date

The sync test now spawns the binary with `check` (like sync_ai_instructions),
and the `man` test is gated behind a `man-test` feature since it requires
man(1) to be installed.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
The man(1) output varies across systems (different groff versions, line
breaking, etc.), so the man sync test cannot reliably pass in CI. Make
it always #[ignore] instead of gating on a man-test feature, and remove
the man-test feature entirely. The pdu.1.man file is a reference file
derived from pdu.1 (which IS sync-checked), so CI enforcement is not
needed.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Remove unnecessary deref in string comparison and use descriptive name
for `example_command` variable in `render_examples_section`.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Re-enable the `man` test with a `which` check that panics with a
diagnostic message and `TEST_SKIP` hint when `man` is not installed,
following the same pattern as `fs_errors` and `cross_device_excludes_mount`.

Add `man-db` to CI's external test dependency installation step and
document it in CONTRIBUTING.md alongside the existing FUSE dependencies.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Replace `man` with `groff -man -T utf8` for rendering the man page
reference file. This produces consistent output across systems by
bypassing system-specific man(1) wrappers and configuration.

Also normalize the rendered output to strip trailing whitespace per
line and ensure exactly one trailing newline.

Update CI to install groff-base, sync test to check for groff, and
CONTRIBUTING.md to document the dependency.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
CI only installs groff-base on Linux, so the man test must be skipped
on macOS and Windows via cfg_attr ignore.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
The generate subcommand now writes to exports/ files directly instead
of printing to stdout, so the shell script no longer needs redirections.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Add `-K utf8` to handle UTF-8 input correctly (fixes mojibake in
non-ASCII characters like © and Vietnamese names) and `-P -c` to
disable SGR escape sequences in the output.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Grotty (groff's terminal output driver) uses char+backspace+char
sequences for bold and _+backspace+char for underline. Strip these
overstrike sequences in the binary rather than relying on external
tools like col(1) or groff's -P -c flag.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Use GROFF_NO_SGR=1 to prevent SGR (ANSI escape) output, and -P -c/-b/-u
to suppress backspace overstrikes for bold/underline. Keep strip_formatting
as a safety net for any remaining escape sequences.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Use `groff -Tutf8 -P-cbou -man` which produces clean plain-text output
without ANSI escapes or backspace overstrikes.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/man_page.rs
Comment thread src/man_page.rs
Apply roff_escape to default values so hyphens render consistently
(e.g. block-size becomes block\-size). Also fix .TH header to place
the version string in the source field instead of the date field per
man(7) convention.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Comment thread exports/pdu.1 Outdated
claude added 2 commits March 28, 2026 19:15
Revert the .TH change that added an empty "" date field. The simpler
form `.TH pdu 1 "pdu 0.21.1"` is the conventional approach used by
clap_mangen and other tools.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Append `...` to positional arguments that accept multiple values
(e.g. `[FILES]...`), matching the `--help` output. Applies to both
the SYNOPSIS and OPTIONS sections.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/man_page.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/man_page.rs
Skip hidden args (e.g. --deduplicate-hardlinks on non-Unix) when
building the conflict map so the man page doesn't reference options
that are not listed on the current platform.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/man_page.rs
Previously, need_paragraph was only cleared inside the
`need_paragraph && !first` branch, so leading empty lines would leave
it set and cause a spurious .PP before the second non-empty line.

https://claude.ai/code/session_01CrXuWDMVQsiUBoy6ceACsF
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@KSXGitHub KSXGitHub marked this pull request as ready for review March 28, 2026 23:07
@KSXGitHub KSXGitHub merged commit 1dea8ec into master Mar 28, 2026
17 checks passed
@KSXGitHub KSXGitHub changed the title feat: manpages feat: man page Mar 28, 2026
@KSXGitHub KSXGitHub deleted the claude/add-man-page-generation-BKX0M branch March 28, 2026 23:08
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.

4 participants