Skip to content

feat(tests): generate folding-ranges doc from snapshot fixtures - #535

Merged
16bit-ykiko merged 12 commits into
mainfrom
feat/feature-docs-pilot
Jul 22, 2026
Merged

16bit-ykiko merged 12 commits into
mainfrom
feat/feature-docs-pilot

Conversation

@16bit-ykiko

@16bit-ykiko 16bit-ykiko commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

Why

Feature docs are hand-maintained support checklists with no mechanical connection to tests: nothing verifies that a checked item actually works, and nothing flags when behavior changes. This PR pilots the inversion for folding ranges: snapshot fixtures become the single source of truth and the doc checklist is generated from them.

Design

Each fixture under tests/data/folding_range/<section>/ carries a doc header that is a plain markdown document behind ///:

/// # Preprocessor conditional folding (`#if` / `#ifdef` ...)
///
/// - status: partial
/// - issues: clangd#1661, clangd#2059
///
/// Branch regions delimited by `#else` fold today; a bare
/// `#if ... #endif` block without an `#else` does not fold yet.

<example code — doubles as the doc example>
  • The h1 title marks the file as a doc item (files without it are supplementary tests, excluded from docs); stripped of the /// prefix the whole header renders as-is in any markdown viewer.
  • Grouping comes from one-level section subdirectories (fold_kinds/, refinements/); generated doc regions are keyed by the directory name, while human headings and prose stay hand-written.
  • status semantics: supported → [x], compiled, snapshot proves the behavior; partial → [ ] with a (partial) marker, compiled, snapshot records the current partial behavior so improvements surface as diffs; unsupported → skipped by the snapshot glob, snapshot pinned to UNSUPPORTED, implementing the capability later surfaces as a diff prompting the status flip.
  • tests/tools/feature_docs.py renders headers into marker-delimited regions of docs/en/features/folding-ranges.md (update) and fails on drift (check, now part of pixi run unit-test). The C++ side reads only the status key via a shared ten-line helper — there is no grammar to drift between the two parsers.

Notable corrections found by review

  • Two preprocessor fixtures initially marked unsupported actually fold #else-delimited branches today; they are now partial with snapshots recording the true current behavior (bare #if...#endif still does not fold — clangd#1661). The partial tier exists because of this finding.
  • All supported items' snapshots were verified to demonstrate their claimed capability.

Migration

The 14 checklist items of the old hand-written doc are preserved (titles, statuses, examples, issue links, client-support notes). Legacy inline test cases are untouched and migrate in follow-up per-feature PRs.

Tests

  • Unit: 1052 passed on both RelWithDebInfo and Debug, including the doc-sync check
  • Integration: 300 passed; Smoke: 3/3
  • format → check round-trip verified stable

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds fixture-driven folding-range documentation generation and checking, expands C++ folding-range fixtures with snapshot records, and updates the snapshot harness to recognize unsupported cases. Unit-test execution now also validates generated feature documentation.

Changes

Folding range documentation and test coverage

Layer / File(s) Summary
Fixture-driven feature documentation
tests/tools/feature_docs.py, docs/en/features/folding-ranges.md
Parses fixture metadata, renders generated checklist sections, validates documentation markers, and updates folding-range documentation examples.
Folding-range fixture corpus
tests/data/folding_range/*.cpp
Adds fixtures for block, list, preprocessor, region, comment, template, access-specifier, and refinement folding cases.
Folding-range snapshot expectations
tests/snapshots/folding_range/snapshot/*.snap.yml
Adds expected ranges, collapsed text, metadata, and unsupported statuses for the new fixtures.
Snapshot status and documentation checks
tests/unit/feature/folding_range_tests.cpp, pixi.toml
Recognizes unsupported fixtures before compilation and runs feature documentation validation after unit tests.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • clice-io/clice#442: Extends the folding-range snapshot and test infrastructure used by this change.
  • clice-io/clice#534: Also modifies the folding-range snapshot harness and fixture processing flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: generating folding-ranges docs from snapshot fixtures.
Description check ✅ Passed The description is directly related to the PR and accurately describes the doc generation workflow and fixture-driven tests.
✨ 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 feat/feature-docs-pilot

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eb393f7dc

ℹ️ 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".

Comment thread tests/unit/feature/folding_range_tests.cpp Outdated
Comment thread tests/data/folding_range/inactive_preprocessor_branch.cpp Outdated
Comment thread tests/data/folding_range/comment_folding.cpp Outdated
Comment thread tests/data/folding_range/fold_from_declaration_line.cpp Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: faece4ea5d

ℹ️ 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".

Comment thread tests/unit/feature/folding_range_tests.cpp Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9e5037f43

ℹ️ 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".

Comment thread tests/unit/feature/folding_range_tests.cpp Outdated
Comment thread tests/data/folding_range/fold_kinds/include_region.cpp
Comment thread tests/tools/feature_docs.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9765c48a3f

ℹ️ 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".

Comment thread tests/tools/feature_docs.py Outdated
Comment thread tests/unit/feature/folding_range_tests.cpp Outdated
Comment thread tests/tools/feature_docs.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9db322593f

ℹ️ 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".

Comment thread tests/unit/feature/folding_range_tests.cpp Outdated
Comment thread tests/tools/feature_docs.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aaf34a315

ℹ️ 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".

Comment thread tests/tools/feature_docs.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42b947b73a

ℹ️ 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".

Comment thread tests/tools/feature_docs.py Outdated
Comment thread tests/unit/feature/folding_range_tests.cpp
Comment thread tests/tools/feature_docs.py
The /// spec header tripped AnnotatedSource::from's @key[...] assertion
in Debug builds (@section etc. parsed as range annotations), and would
pollute folding output once comment folding exists. Stripping it before
add_main fixes both and aligns snapshot positions with the doc examples.

Also per review: give fold_from_declaration_line a real compilable body,
and correct the inactive_preprocessor_branch description (only the
condition-to-#else region folds today).
A plain /// doc comment atop a supplementary fixture (no @key lines)
now stays in the compiled input, matching parse_fixture's rule.
Doxygen tags after prose in a supplementary fixture's doc comment no
longer count as spec keys, and a bare @status with no value is now
rejected instead of silently rendering as unchecked.
Stop the C++ header scan at the first non-/// line (a blank separator
followed by /// body comments previously hit an LLVM drop_front assert),
and reject duplicate and empty required keys in feature_docs.py.
Spec-key detection now requires a word char after @, matching
parse_fixture's @(\w+) grammar; generated code fences grow past any
backtick run in the example so it cannot close the fence early.
Drop the @-prefixed spec header and the fence experiment: frontmatter
is now the leading run of '/// key: value' lines, terminated by a bare
/// separator. The block is an ordinary comment to the compiler, so no
stripping and no annotation-parser interaction; the C++ side only does
a status lookup via the shared test/fixture.h helper. A typo in the
first key is reported instead of silently demoting the file to a
supplementary fixture.
The check guarded against the old ASCII $ sigil colliding with real
fixture content. The redesigned grammar reserves only §/⟦/⟧, which
cannot occur naturally, and cursor-based features will later place
these annotations in doc fixtures deliberately.
The fixture doc header is now a plain markdown document: an h1 title
line (which doubles as the doc-item marker), a '- key: value' metadata
list (status/issues/order) and a markdown description. The section key
is gone — grouping comes from one-level section subdirectories
(fold_kinds/, refinements/), and doc region markers use the directory
name. Stripped of the /// prefix the whole header renders as-is in any
markdown viewer.
@16bit-ykiko
16bit-ykiko force-pushed the feat/feature-docs-pilot branch from 6f7b649 to 4e803ce Compare July 21, 2026 16:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e803ce8b1

ℹ️ 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".

Comment thread tests/unit/test/fixture.h Outdated
@16bit-ykiko
16bit-ykiko merged commit bb6d11d into main Jul 22, 2026
30 checks passed
@16bit-ykiko
16bit-ykiko deleted the feat/feature-docs-pilot branch August 8, 2026 13:42
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.

1 participant