Skip to content

feat(guides): add sections option for grouped Redoc sidebar layout#3771

Merged
PierreBrisorgueil merged 3 commits into
masterfrom
feat/promote-guides-sections
Jun 1, 2026
Merged

feat(guides): add sections option for grouped Redoc sidebar layout#3771
PierreBrisorgueil merged 3 commits into
masterfrom
feat/promote-guides-sections

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor

Summary

Promote-up from trawl_node (production-validated): mergeGuidesIntoSpec gains an optional { sections } option for grouped Redoc sidebar layout.

  • Adds prefixFromPath(filePath) helper (exported) — extracts the numeric ordering prefix from a guide filename (e.g. 07-scheduling.md → 7, underscore or dash separator, radix-10 safe)
  • Extends mergeGuidesIntoSpec(spec, guides, options?) with a { sections } third argument — array of { title, prefixMin, prefixMax } objects that group guides under H1 section dividers with each guide rendered as H2
  • Flat mode unchanged (no sections passed) — fully backward-compatible; existing callers are unaffected
  • Orphan guides (no matching prefix range) are appended after section markdown as H2 — never silently dropped

Why generic

Every devkit downstream with a structured doc tree (18+ guides) gets Redoc sidebar grouping for free. When sections is not passed, behavior is byte-identical to the current devkit.

Test coverage

15 unit tests in lib/helpers/tests/guides.sections.unit.tests.js:

  • Flat mode backward-compat (2 tests)
  • Sectioned H1/H2 grouping (1 test)
  • Section order preserved (1 test)
  • Orphan not dropped + appended after sections (2 tests)
  • Empty-section omitted from output (1 test)
  • Empty guides / falsy spec guards (2 tests)
  • prefixFromPath direct: dash separator, underscore separator, no-prefix, pure-digit, octal-safe (radix 10 on 08-/09-), empty input (6 tests)

References

Test plan

  • 15 unit tests pass (NODE_ENV=test npm run test:unit -- guides.sections)
  • ESLint clean on both modified files
  • DeepSeek Phase 0 gate: OK (0 critical, 0 high; 1 medium addressed by adding direct prefixFromPath coverage in the follow-up commit)
  • Push-verify SHA: 1127e36f54ed47ef43a2f3f04d84b2cebba48dfc

Promote-up from trawl_node: mergeGuidesIntoSpec gains an optional
{ sections } argument that groups guides under H1 section dividers
(each guide rendered as H2) using filename numeric prefix ranges.
Adds prefixFromPath helper (exported). Flat mode unchanged when
sections is absent (backward-compatible).

Closes #3767
…ertion

Addresses DeepSeek Phase 0 medium finding: prefixFromPath is a new
public export but had only indirect coverage. Adds 6 direct tests
(dash separator, underscore separator, no-prefix, pure-digit, octal
radix-10 correctness, empty input). Also adds orphan-position assertion
(orphan appended after section markdown, per JSDoc spec).
Copilot AI review requested due to automatic review settings June 1, 2026 19:30
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Warning

Review limit reached

@PierreBrisorgueil, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 18 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b89d19e9-68e4-468d-857c-fb02de89ec26

📥 Commits

Reviewing files that changed from the base of the PR and between 5604011 and 2d39623.

📒 Files selected for processing (2)
  • lib/helpers/guides.js
  • lib/helpers/tests/guides.sections.unit.tests.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/promote-guides-sections

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.18%. Comparing base (7ed5291) to head (2d39623).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3771       +/-   ##
===========================================
+ Coverage   59.43%   90.18%   +30.74%     
===========================================
  Files         151      151               
  Lines        4970     5000       +30     
  Branches     1577     1588       +11     
===========================================
+ Hits         2954     4509     +1555     
+ Misses       1491      386     -1105     
+ Partials      525      105      -420     
Flag Coverage Δ
integration 59.26% <7.69%> (-0.18%) ⬇️
unit 69.20% <96.15%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ed5291...2d39623. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

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

This PR extends the Redoc guide-merging helper to support an optional “sectioned” sidebar layout by grouping guides under H1 section dividers (with each guide as an H2) based on numeric filename prefixes, while keeping the existing flat (backward-compatible) behavior unchanged when sections is not provided.

Changes:

  • Add prefixFromPath(filePath) (exported) to extract a numeric ordering prefix from guide filenames.
  • Extend mergeGuidesIntoSpec(spec, guides, options?) to support { sections } grouping with orphan guides appended at the end.
  • Add unit tests covering flat mode compatibility, section grouping behavior, orphan handling, and prefixFromPath edge cases.

Reviewed changes

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

File Description
lib/helpers/guides.js Adds prefixFromPath and sectioned grouping logic to mergeGuidesIntoSpec while preserving flat mode behavior.
lib/helpers/tests/guides.sections.unit.tests.js Introduces unit coverage for the new { sections } mode and prefixFromPath parsing behavior.

Comment thread lib/helpers/guides.js Outdated
Comment thread lib/helpers/guides.js Outdated
Comment thread lib/helpers/guides.js Outdated
Address Copilot review threads:
- options null-safety: `(options != null ? options : {})` prevents
  TypeError when null is passed explicitly as third arg
- JSDoc: `path?` optional in guides entries (only needed for sections mode)
- JSDoc: @returns reflects actual passthrough of falsy/non-object spec
- Test: null options falls back to flat mode without throwing
@PierreBrisorgueil PierreBrisorgueil merged commit b56d3b6 into master Jun 1, 2026
8 checks passed
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.

feat(guides): add sections option for Redoc sidebar grouping

2 participants