Skip to content

[Repo Assist] Add nested navigation categories and fix front-matter value parsing#1105

Open
github-actions[bot] wants to merge 8 commits intomainfrom
repo-assist/improve-frontmatter-nestedcat-2026-03-21-710ac1928ff78539
Open

[Repo Assist] Add nested navigation categories and fix front-matter value parsing#1105
github-actions[bot] wants to merge 8 commits intomainfrom
repo-assist/improve-frontmatter-nestedcat-2026-03-21-710ac1928ff78539

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Closes #927


Summary

Two improvements bundled together since both touch document front-matter handling:

1. Nested navigation categories (Task 3 — Issue Fix)

Documents can now declare a sub-category using / as a separator in the category front-matter field:

---
category: Reference/API
categoryindex: 2
index: 1
---
```

The sidebar renders this as a parent header with indented sub-headers beneath it:

```
Collections           ← .nav-header (parent)
  Arrays              ← .nav-sub-header (child)
    - Pattern Matching
  Lists               ← .nav-sub-header (child)
    - Destructuring with Cons
    - Pattern Matching
Reference             ← .nav-header (parent)
  - Getting Started   ← direct item under parent (no sub-category)
  API                 ← .nav-sub-header
    - Markdown
    - Literate

Backwards compatible: any category without / renders exactly as before. Parent category order in the sidebar is determined by the minimum CategoryIndex of any document within that parent group.

CSS: added .nav-sub-header style to fsdocs-default.css — indented, slightly smaller weight than the top-level header.

Templating path: when _menu_template.html / _menu-item_template.html are present, the nested structure is flattened to parent-level groups so existing custom templates continue to work without changes.

2. Fix front-matter value parsing with : in values (Task 5 — Coding Improvement)

FrontMatterFile.ParseFromLines previously split each line on : and took only the second segment, discarding any additional : characters in the value. For example:

title: F#: An Introduction   # was captured as "F#" — now correctly " F#: An Introduction"

The fix joins all parts after the first :, preserving the full value.

Changes

  • src/fsdocs-tool/BuildCommand.fs: GetNavigationEntries — added parseNestedCategory helper, hasNestedCategories detection, and a new elif hasNestedCategories rendering branch with parent/sub-group logic.
  • docs/content/fsdocs-default.css: Added .nav-sub-header CSS class (indented, normal weight, slight opacity reduction vs parent header).
  • src/FSharp.Formatting.Common/Templating.fs: FrontMatterFile.ParseFromLines — join remaining parts after splitting on :.
  • RELEASE_NOTES.md: Added entries under [Unreleased].

Test Status

  • ✅ Build succeeded (0 errors; 1 pre-existing warning FS0760)
  • ✅ All tests pass: 281 Markdown, 30 CodeFormat, 8 fsdocs-tool, 32 Literate, 88 ApiDocs
  • ℹ️ One pre-existing infrastructure crash in the test runner (reproducible on main without changes — not caused by this PR)

Design decisions

  • The / character was chosen as the separator (matching the Repo Assist proposal in Nesting Document Categories #927 and conventions from other static site generators such as Hugo and Docusaurus).
  • Depth is limited to one level (parent/child) for simplicity. Deeper nesting could be added later if needed.
  • Parent category ordering is determined automatically by the minimum CategoryIndex among its children, so no new front-matter key is required.

Generated by Repo Assist ·

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@d1d884596e62351dd652ae78465885dd32f0dd7d

- Support 'category: Parent/Child' syntax in document front matter.
  Documents using a slash separator are grouped under a parent nav
  header; a sub-header is rendered for each child group beneath it.
  Documents without a sub-category remain directly under the parent.
  Existing flat categories are unchanged (no '/' → identical output).
  Closes #927.

- Fix FrontMatterFile.ParseFromLines to preserve the full value when
  a front-matter field contains more than one colon (e.g.
  'title: F#: An Introduction'). Previously the text after the
  second colon was discarded.

Co-authored-by: Copilot <[email protected]>
@dsyme dsyme marked this pull request as ready for review March 25, 2026 15:40
@dsyme
Copy link
Contributor

dsyme commented Mar 25, 2026

/repo-assist adds unit and/or intergration tests for all this, including adding testing for relevant existing things that haven't been tested

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 25, 2026

Repo Assist completed successfully!

…ationEntries

- Add 8 unit tests for FrontMatterFile.ParseFromLines covering:
  - Standard YAML front-matter parsing
  - Preservation of colons in values (regression for PR #1105 fix)
  - Missing required fields return None
  - Non-numeric index returns None
  - .fsx-style front-matter ((**...*) delimiters)
  - Whitespace trimming
  - Empty input returns None

- Add 10 unit tests for GetNavigationEntries covering:
  - No-category path emits Documentation header
  - Flat categories emit nav-header (no nav-sub-header)
  - Nested categories (Parent/Child) emit nav-sub-header
  - Parent name not rendered as nav-sub-header
  - Parent ordering by minimum CategoryIndex
  - Mixed nested and flat categories
  - Active page marking
  - ignoreUncategorized filter
  - index.md exclusion from navigation

Co-authored-by: Copilot <[email protected]>
@github-actions
Copy link
Contributor Author

Commit pushed: 7db2701

Generated by Repo Assist

@github-actions
Copy link
Contributor Author

🤖 This is an automated update from Repo Assist.

Added 18 new unit tests to tests/FSharp.Literate.Tests/DocContentTests.fs covering the two changes in this PR:

FrontMatterFile.ParseFromLines (8 tests)

  • Standard YAML front-matter parsing
  • Colon preservation — regression test for the : in values fix (e.g. "F#: An Introduction")
  • Missing category, categoryindex, or index returns None
  • Non-numeric index returns None
  • .fsx-style front-matter ((**...*) delimiters)
  • Whitespace trimming, empty input

GetNavigationEntries — flat and nested categories (10 tests)

  • No-category path emits Documentation header
  • Flat categories emit nav-header but no nav-sub-header
  • Nested Parent/Child categories emit nav-sub-header
  • Parent name is rendered as nav-header, not nav-sub-header
  • Parent ordering by minimum CategoryIndex of children
  • Mixed nested/flat categories
  • Active page marking
  • ignoreUncategorized filter
  • index.md exclusion from navigation

All 138 tests pass (was 120 before; +18 new).

Generated by Repo Assist for issue #1105 ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4957663821dbb3260348084fa2f1659701950fef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nesting Document Categories

1 participant