feat: add sigil support for module attribute formatting#9
Merged
Conversation
Add support for formatting markdown content within ~S and ~s sigils used in module attributes like @moduledoc, @doc, @TypeDoc, etc. Supports all sigil delimiters and preserves original structure. Includes comprehensive test coverage.
- Fix parameter mismatch in process_sigil_doc_attribute function calls - Simplify sigil parameter passing with map structure - Improve delimiter handling in patch builder - Optimize string operations in test utilities
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for formatting markdown content in Elixir module attributes using the ~S and ~s sigil syntax, extending the existing markdown formatting capabilities to handle sigil-based documentation strings.
Key changes:
- Enhanced AST processing to recognize sigil patterns in module attributes
- Added sigil-specific patch building functionality to maintain sigil syntax
- Comprehensive test coverage for various sigil delimiters and markdown formatting scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/sigil_attribute_test.exs | Comprehensive test suite covering all sigil delimiters and complex markdown scenarios |
| lib/dprint_markdown_formatter/patch_builder.ex | Added sigil-specific replacement string building with delimiter preservation |
| lib/dprint_markdown_formatter/ast_processor.ex | Enhanced AST processing to detect and format sigil-based documentation attributes |
Comments suppressed due to low confidence (2)
test/sigil_attribute_test.exs:6
- [nitpick] The describe block title mentions '~S sigil support' but the PR title and description indicate support for both ~S and ~s sigils. Consider updating to '~S/~s sigil support in module attributes' for clarity.
describe "~S sigil support in module attributes" do
test/sigil_attribute_test.exs:453
- The expected output shows '
code blocks' with preserved spaces inside the inline code, but the input shows 'code blocks' as a code block. This appears to be testing incorrect behavior - code blocks should preserve their structure, not be converted to inline code.
This contains "quotes" inside the sigil. And `code blocks` too.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds comprehensive support for formatting markdown content within ~S and ~s sigils in module attributes with all delimiter types and proper formatting preservation.