Skip to content
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

Issue 1334 #1335

Merged
merged 12 commits into from
Feb 2, 2025
Merged

Issue 1334 #1335

merged 12 commits into from
Feb 2, 2025

Conversation

jackdewinter
Copy link
Owner

@jackdewinter jackdewinter commented Feb 2, 2025

#1334

Summary by Sourcery

Fix a bug in MD031 that caused an assert error during the fix stage when a fenced code block was inside a block quote inside a list inside a block quote. Add a "code_spans" configuration option to MD044 to complement the existing "code_blocks" option.

Bug Fixes:

  • Fix assert error in MD031 fix mode when a fenced code block is inside nested block quotes and lists.

Enhancements:

  • Add a "code_spans" option to MD044 to control whether inline code spans are checked.

Tests:

  • Update test cases for MD031 and MD044.

Copy link
Contributor

sourcery-ai bot commented Feb 2, 2025

Reviewer's Guide by Sourcery

This pull request addresses two issues. The first is a bug in the fix mode of rule MD031, which was not correctly handling a specific edge case involving nested block quotes, lists, and fenced code blocks. The second is an enhancement to rule MD044, adding a configuration option to disable checking for proper names within inline code spans.

Sequence diagram for MD031 fix mode special case handling

sequenceDiagram
    participant F as fix_spacing_special_case
    participant T as TokenStack
    participant C as ContainerAdjustments
    F->>T: get_container_stack_size()
    F->>T: get_container_stack_item(index)
    loop through stack
        F->>T: Check for list start token
        alt found list start
            F->>C: Add pending adjustment
            F->>F: Create new end token
        end
    end
    F->>F: Create replacement tokens
    F->>F: Register replace request
Loading

Class diagram for MD044 rule changes

classDiagram
    class RuleMd044 {
        -proper_name_list: List[str]
        -check_in_code_blocks: bool
        -check_in_code_spans: bool
        -is_in_code_block: bool
        -names: str
        -replacement_items: List[FoundReplacement]
        +initialize_from_config()
        +query_config()
        -handle_inline_code_span()
    }
    note for RuleMd044 "Added check_in_code_spans config
to control proper name checking
in inline code spans"
Loading

Class diagram for MD031 rule fix mode changes

classDiagram
    class RuleMd031 {
        -fix_count: int
        -last_token: MarkdownToken
        -container_adjustments: List
        -leading_space_index_tracker: TokenStack
        -fix_spacing_special_case()
    }
    note for RuleMd031 "Enhanced special case handling
for nested block quotes and lists"
Loading

File-Level Changes

Change Details Files
Fixed an edge case in rule MD031's fix mode where nested block quotes, lists, and fenced code blocks were not being handled correctly.
  • Modified the __fix_spacing_special_case method in rule_md_031.py to correctly handle the edge case.
  • Added a new test case to test_md031.py to reproduce the issue.
  • Updated test files to reflect the fix.
pymarkdown/plugins/rule_md_031.py
test/rules/test_md031.py
test/test_markdown_extra.py
test/nested_three/test_markdown_nested_three_block_unordered_block.py
Added a new configuration option to rule MD044 to disable checking for proper names within inline code spans.
  • Added a new code_spans configuration option to rule_md_044.py.
  • Added a new test case to test_md044.py to verify the new functionality.
  • Updated the changelog and documentation to reflect the new option.
test/rules/test_md044.py
pymarkdown/plugins/rule_md_044.py
newdocs/src/changelog.md
newdocs/src/plugins/rule_md044.md
Modified the clean.sh script to prevent errors when a file is deleted.
  • Added a check to ensure that the file exists before attempting to process it.
clean.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (277100c) to head (0648360).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1335   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          191       191           
  Lines        21607     21618   +11     
  Branches      3994      3996    +2     
=========================================
+ Hits         21607     21618   +11     

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

@jackdewinter jackdewinter merged commit d5e56a7 into main Feb 2, 2025
27 checks passed
@jackdewinter jackdewinter deleted the issue-1288 branch February 2, 2025 23:08
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