Skip to content

Fix formatDocPageAsMan() mislabeling untitled sections as OPTIONS#601

Merged
dahlia merged 1 commit intomainfrom
fix/issue-261-man-untitled-sections
Mar 18, 2026
Merged

Fix formatDocPageAsMan() mislabeling untitled sections as OPTIONS#601
dahlia merged 1 commit intomainfrom
fix/issue-261-man-untitled-sections

Conversation

@dahlia
Copy link
Copy Markdown
Owner

@dahlia dahlia commented Mar 18, 2026

Summary

formatDocPageAsMan() used section.title?.toUpperCase() ?? "OPTIONS" as the fallback heading for untitled sections, so sections containing only commands or only arguments were still labeled .SH OPTIONS. This patch adds an inferSectionTitle() helper in packages/man/src/man.ts that inspects entry kinds before choosing the fallback: untitled command-only sections now render as COMMANDS, untitled argument-only sections render as ARGUMENTS, and mixed or option-only sections keep the existing OPTIONS label.

For example, a parser with two subcommands and no explicit section title previously produced:

.SH OPTIONS
.TP
\fBbuild\fR
Build project.
.TP
\fBtest\fR
Run tests.

After this fix, the same parser produces:

.SH COMMANDS
.TP
\fBbuild\fR
Build project.
.TP
\fBtest\fR
Run tests.

Fixes #261

Test plan

  • Added tests in packages/man/src/man.test.ts for untitled command-only, argument-only, option-only, and mixed sections
  • Verified all existing man page tests still pass

`formatDocPageAsMan()` used `"OPTIONS"` as the fallback heading for
untitled sections regardless of entry kinds.  Now untitled sections
containing only commands render as `COMMANDS`, and untitled sections
containing only arguments render as `ARGUMENTS`.

Close #261

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@dahlia
Copy link
Copy Markdown
Owner Author

dahlia commented Mar 18, 2026

@codex review

@dahlia dahlia self-assigned this Mar 18, 2026
@dahlia dahlia added the bug Something isn't working label Mar 18, 2026
@dahlia dahlia added this to the Optique 1.0 milestone Mar 18, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.88%. Comparing base (63d2a50) to head (5e0c977).
⚠️ Report is 10 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/man/src/man.ts 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #601      +/-   ##
==========================================
+ Coverage   94.87%   94.88%   +0.01%     
==========================================
  Files          38       38              
  Lines       17160    17233      +73     
  Branches     4518     4528      +10     
==========================================
+ Hits        16280    16352      +72     
- Misses        868      869       +1     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1d1383b7-3379-46ac-ba3c-2adf2e59b605

📥 Commits

Reviewing files that changed from the base of the PR and between 8404ed9 and 5e0c977.

📒 Files selected for processing (3)
  • CHANGES.md
  • packages/man/src/man.test.ts
  • packages/man/src/man.ts

Walkthrough

This pull request fixes a bug in formatDocPageAsMan() where untitled sections in man page documentation were always labeled as "OPTIONS" regardless of their entry kinds. The fix introduces an inferSectionTitle() utility function that inspects entry kinds to infer appropriate section headings: "COMMANDS" for command-only sections, "ARGUMENTS" for argument-only sections, and "OPTIONS" as a fallback. The formatter now uses this function for untitled sections. Corresponding tests are added to validate the new behavior, and changelog entries document the fix for issues #261 and #601.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: addressing the mislabeling of untitled sections in formatDocPageAsMan().
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the problem, solution, example outputs, and test plan.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #261: inferring section titles based on entry kinds for untitled sections and using appropriate headings (COMMANDS for command-only, ARGUMENTS for argument-only, OPTIONS otherwise).
Out of Scope Changes check ✅ Passed All changes are directly related to fixing issue #261: the inferSectionTitle() utility, updated formatDocPageAsMan() logic, and comprehensive tests for heading inference.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-261-man-untitled-sections
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dahlia dahlia merged commit 86edc75 into main Mar 18, 2026
7 of 8 checks passed
@dahlia dahlia deleted the fix/issue-261-man-untitled-sections branch March 18, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The formatDocPageAsMan() formatter labels untitled command sections as OPTIONS

1 participant