Skip to content

Plan 89: TOC generator directive and MDS035 auto-fix - #167

Merged
jeduden merged 5 commits into
mainfrom
claude/create-plan-branch-3PgFI
Apr 25, 2026
Merged

Plan 89: TOC generator directive and MDS035 auto-fix#167
jeduden merged 5 commits into
mainfrom
claude/create-plan-branch-3PgFI

Conversation

@jeduden

@jeduden jeduden commented Apr 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements plan 89: <?toc?>...<?/toc?> generated-section directive (MDS038) and MDS035 auto-fix
  • Plan 89 status is now ✅ (all tasks and acceptance criteria complete)

What was built

  • MDS038 (toc): new <?toc?> directive that generates a nested heading list linked to GitHub-style anchors; min-level/max-level params; stack-based depth tracking for non-contiguous levels; duplicate-heading disambiguation
  • MDS035 auto-fix: replaces [TOC], [[_TOC_]], [[toc]], ${toc} with <?toc?>\n<?/toc?> blocks; a second fix pass populates the heading list via MDS038; leaves [TOC] untouched when a link-ref definition is present
  • Shared helpers: Slugify and CollectTOCItems moved to internal/mdtext; integer/float YAML params coerced to strings in ValidateStringParams so min-level: 2 works unquoted
  • Multi-pass integration test: TestMultiPassFix_TOCDirective verifies [TOC] → populated <?toc?> block in one mdsmith fix run

See plan/89_toc-generator-directive.md for full design and acceptance criteria.

https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu

Copilot AI review requested due to automatic review settings April 23, 2026 04:33
@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.60%. Comparing base (d983848) to head (96c986e).
⚠️ Report is 39 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   88.03%   89.60%   +1.57%     
==========================================
  Files         110      112       +2     
  Lines       14106    12062    -2044     
==========================================
- Hits        12418    10808    -1610     
+ Misses       1228      796     -432     
+ Partials      460      458       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Marks plan 89 as in progress and updates the generated plans catalog accordingly.

Changes:

  • Update plan/89_toc-generator-directive.md front-matter status from 🔲 to 🔳.
  • Regenerate PLAN.md catalog so plan 89 shows as 🔳 in the plans table.

Reviewed changes

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

File Description
plan/89_toc-generator-directive.md Sets plan 89 status to “in progress” in front matter.
PLAN.md Updates the generated catalog row for plan 89 to reflect the new status.

@jeduden jeduden added dependencies Pull requests that update a dependency file queue Add to a PR to enqueue it labels Apr 24, 2026
claude added 2 commits April 24, 2026 16:54
Add a native <?toc?>...<?/toc?> generated-section directive (MDS038)
that emits a nested list of the document's headings linked to
GitHub-style anchors. Upgrade MDS035 to FixableRule so it replaces
[TOC], [[_TOC_]], [[toc]], and ${toc} tokens with the canonical
<?toc?>\n<?/toc?> block; a subsequent pass of the same fix run
populates the heading list via MDS038.

- Move Slugify and CollectTOCItems into internal/mdtext (shared)
- Update crossfilereferenceintegrity to call mdtext.Slugify
- Coerce integer/float YAML values to strings in ValidateStringParams
  so min-level: 2 works without quoting
- New internal/rules/toc/ package registers as MDS038 (category meta,
  enabled by default, fixable), with min-level/max-level params
- MDS035 Fix inserts blank lines around the replacement block;
  leaves [TOC] untouched when a link-ref definition is present
- MDS035 diagnostic message updated to name <?toc?> (MDS038)
- Integration test TestMultiPassFix_TOCDirective verifies end-to-end
  [TOC] → populated <?toc?> block in one mdsmith fix run
- Update MDS035 README, generated-section archetype doc, and
  docs/background/markdown-linters.md to reflect all changes

https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu
Cover lines introduced in this PR that were missing test coverage:
- mdtext: add Slugify and CollectTOCItems unit tests (including
  empty-slug skip branch)
- gensection/engine: add float64 integer-valued and fractional-valued
  coercion tests for ValidateStringParams
- toc/rule: add TestValidate_InvalidMaxLevel and
  TestGenerate_InvalidParams to cover the remaining parseLevels
  and Generate branches
- tocdirective/rule: add nil-file tests for Check and Fix to cover
  defensive nil guards

https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu
Copilot AI review requested due to automatic review settings April 24, 2026 17:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.

Comment thread plan/89_toc-generator-directive.md
Comment thread internal/rules/tocdirective/rule.go Outdated
Comment thread internal/mdtext/mdtext.go Outdated
Comment thread internal/rules/toc/rule.go Outdated
@jeduden
jeduden requested a review from Copilot April 24, 2026 17:32
@jeduden jeduden removed the queue Add to a PR to enqueue it label Apr 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread internal/rules/tocdirective/rule.go Outdated
Comment thread internal/rules/toc/rule.go
Comment thread plan/89_toc-generator-directive.md
Claude AI and others added 2 commits April 24, 2026 18:12
Fixed multiple issues identified in Copilot review:

1. MDS035 Fix now uses AST-based approach (same as Check) to avoid
   rewriting TOC tokens inside code blocks
2. Anchor disambiguation now guarantees unique anchors by tracking
   all used anchors, not just base slugs
3. TOC link text now escapes special characters (], [, \) that would
   break Markdown link syntax
4. Added tests for special characters in headings and code blocks
5. Refactored Fix method to reduce cognitive complexity (35 → <30)

All tests pass, linter clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Co-authored-by: jeduden <1117699+jeduden@users.noreply.github.com>
@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch labels Apr 25, 2026
@jeduden

jeduden commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden jeduden removed the queue Add to a PR to enqueue it label Apr 25, 2026
@jeduden

jeduden commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-167-1777079487. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 25, 2026
@jeduden
jeduden merged commit 1b27b3d into main Apr 25, 2026
12 checks passed
@jeduden

jeduden commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit 1b27b3d. CI run that validated the merge.

Next: Done — nothing more to do here.

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

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants