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 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe PR adds documentation for deep-linked Sequence Diagram(s)sequenceDiagram
participant TocEntry as docset.yml TOC entry
participant Converter as TocItemYamlConverter.ReadYaml
participant Navigation as navigation rendering
participant Collector as error collector
TocEntry->>Converter: file: reference/.../index.md
alt childless deep-linked index.md
Converter-->>Navigation: FolderRef with FolderIndexFileRef
else bare root index.md
Converter-->>Navigation: IndexFileRef
else deep-linked entry with children
Converter-->>Navigation: FileRef with children
end
Navigation-->>Collector: zero errors
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
83724b0 to
778baaa
Compare
|
Thanks for the review @Mpdreamz — addressed in 778baaa (also rebased onto latest
On |
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>
Condense the converter comment to one line, reframe the navigation docs to present folder: + file: as the preferred canonical form, document the shorthand under a parent folder's children: list (the main use case), and fold the test class docstring to a single line per project convention. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
778baaa to
a657395
Compare
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