-
Notifications
You must be signed in to change notification settings - Fork 1
Plan 89: TOC generator directive and MDS035 auto-fix #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
514a0ab
plan 89: mark TOC generator directive as in progress
claude 5997f0f
Implement plan 89: MDS038 toc directive and MDS035 auto-fix
claude 7afe91f
Add tests to cover new code for Codecov patch check
claude 9001c30
Address PR #167 production readiness issues
Claude 96c986e
ci: retrigger CI for PR #167
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package integration | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/jeduden/mdsmith/internal/config" | ||
| "github.com/jeduden/mdsmith/internal/fix" | ||
| "github.com/jeduden/mdsmith/internal/rule" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestMultiPassFix_TOCDirective verifies that a single fix run converts | ||
| // [TOC] into a populated <?toc?>...<?/toc?> block. MDS035 replaces [TOC] | ||
| // with the empty directive in pass 1; MDS038 fills the heading list in pass 2. | ||
| func TestMultiPassFix_TOCDirective(t *testing.T) { | ||
| src := "# Document\n\n[TOC]\n\n## Section One\n\n## Section Two\n" | ||
|
|
||
| dir := t.TempDir() | ||
| mdFile := filepath.Join(dir, "doc.md") | ||
| require.NoError(t, os.WriteFile(mdFile, []byte(src), 0o644)) | ||
|
|
||
| cfg := &config.Config{ | ||
| Rules: map[string]config.RuleCfg{ | ||
| "toc-directive": {Enabled: true}, | ||
| "toc": {Enabled: true}, | ||
| }, | ||
| } | ||
|
|
||
| fixer := &fix.Fixer{ | ||
| Config: cfg, | ||
| Rules: rule.All(), | ||
| } | ||
|
|
||
| result := fixer.Fix([]string{mdFile}) | ||
| require.Empty(t, result.Errors, "unexpected errors: %v", result.Errors) | ||
|
|
||
| got, err := os.ReadFile(mdFile) | ||
| require.NoError(t, err) | ||
|
|
||
| content := string(got) | ||
| assert.Contains(t, content, "<?toc?>", "toc directive start marker present") | ||
| assert.Contains(t, content, "<?/toc?>", "toc directive end marker present") | ||
| assert.Contains(t, content, "- [Section One](#section-one)", "heading link present") | ||
| assert.Contains(t, content, "- [Section Two](#section-two)", "heading link present") | ||
| assert.NotContains(t, content, "\n[TOC]\n", "original TOC token replaced") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.