Treat childless file: subdir/index.md as a single-page folder#3471
Treat childless file: subdir/index.md as a single-page folder#3471cotti wants to merge 1 commit into
Conversation
A childless `file: subdir/index.md` entry resolved to a bare leaf that competed with its siblings for the parent's index slot and was silently dropped from the navigation, forcing authors to use a `folder:` workaround. Treat it as sugar for a folder with an index file so the full path works as expected. Entries that declare children keep their virtual-file semantics. Fixes #764 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reached
More reviews will be available in 31 minutes and 16 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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches✨ Simplify code
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. Comment |
Mpdreamz
left a comment
There was a problem hiding this comment.
Thanks for the fix — the implementation is correct and the test coverage is solid. A few things to address before merging:
Comment verbosity
The four-line comment block in TableOfContentsYamlConverters.cs re-narrates the bug history. That belongs in the commit/PR description, not the source. Trim to one line:
// Sugar: "file: subdir/index.md" without children → single-page folder to avoid silent nav drop.
if (children.Count == 0 && fileOnly.EndsWith("/index.md", StringComparison.Ordinal))Docs framing
The PR description calls folder: + file: index.md "the unintuitive workaround" but that has always been the preferred canonical form. The docs section should reflect this — e.g.:
"This is shorthand for the explicit
folder:+file:form, which remains the preferred approach for folders that also have additional children."
Missing docs: behavior under folder: + children:
The test FolderWithChildlessIndexFileChildrenKeepsEveryEntry shows the sugar works inside a parent folder's children: list too, but the docs don't mention it. This is the primary real-world use case (e.g. 100+ single-page integrations under a reference/ folder):
toc:
- folder: reference
file: index.md
children:
- file: 1password/index.md # → becomes its own FolderRef
- file: activemq/index.md # → becomes its own FolderRefEach entry becomes its own subsection; none "steals" the parent's index. Worth a short mention in the docs since it's the main usage pattern.
toc: version scope
The version: key goes through a separate converter branch. Please confirm whether file: subdir/index.md under a versioned toc entry is also covered (or explicitly out of scope). If it still silently drops there, that's worth a follow-up issue at minimum.
Minor: test class docstring
The class-level <summary> block in DeepLinkedIndexFileTests.cs is multi-paragraph. Project convention is no multi-paragraph docstrings — either drop it or fold to one line.
Why
Closes #764. Authors expect to add single-page subdirectories to the TOC with the natural full path:
Instead, every such childless
file: subdir/index.mdentry was silently dropped from the navigation, with no error. The only workaround was the unintuitivefolder:+file: index.mdform (or renaming files toreference/1password.md).What
A childless
file:entry pointing at a subdirectoryindex.mdpreviously resolved to a bare leaf that competed with its siblings for the parent's index slot — losing that race meant it never appeared in the tree (and in nested cases its path got doubled).The YAML converter now treats such an entry as sugar for
folder: subdirwith a singlefile: index.mdchild, so it becomes its own single-page subsection and the full-path form works as documented. Entries that declare explicitchildrenare untouched and keep their existing virtual-file (deep-linking) semantics, so the change is backward compatible.Covered by new regression tests in
DeepLinkedIndexFileTests.cs(conversion, backward-compat for bareindex.mdand entries with children, rendering as a plain link, multiple siblings under a parent folder, and no path-doubling under a virtual-file parent). Navigation behavior is documented under "Deep-linkedindex.mdfiles" in the navigation config docs.Made with Cursor