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

https://github.com/jackdewinter/pymarkdown/issues/1280 #1281

Merged
merged 14 commits into from
Dec 8, 2024

Conversation

jackdewinter
Copy link
Owner

@jackdewinter jackdewinter commented Dec 8, 2024

#1280

Summary by Sourcery

Introduce a new feature to save and scan Markdown documents with specific extensions enabled, fix a bug related to task lists in rule Md018, and enhance the testing infrastructure with a new test case and batch script. Update the changelog and reorganize the Pipfile dependencies.

New Features:

  • Add capability to save all single Markdown documents in a specified directory and scan them one at a time with PyMarkdown and each of the extensions enabled.

Bug Fixes:

  • Fix issue with task lists creating an error in Md018, as reported in Issue 1267.

Enhancements:

  • Add a new test case to ensure rule Md018 handles task lists correctly.

Build:

  • Add a new batch script 'batch_tests.cmd' for running tests with specific settings.

Documentation:

  • Update changelog to include new feature and bug fix details.

Tests:

  • Add a new test case for Issue 1267 to verify handling of task lists in Markdown documents.

Chores:

  • Move the 'twine' package into the dev section of the Pipfile.

Copy link
Contributor

sourcery-ai bot commented Dec 8, 2024

Reviewer's Guide by Sourcery

This PR implements fixes for task list handling in Rule MD018 and adds functionality to capture test cases in a specified directory. The changes include adding task list token support, modifying test infrastructure, and updating dependencies.

Sequence diagram for test case directory capture

sequenceDiagram
    participant User
    participant Script
    participant FileSystem

    User->>Script: Run ptest.cmd with -d option
    Script->>FileSystem: Check if directory exists
    alt Directory exists
        Script->>FileSystem: Change to specified directory
        Script->>FileSystem: Erase .md files
    else Directory does not exist
        Script->>User: Display error message
    end
Loading

Updated class diagram for MarkdownToken

classDiagram
    class MarkdownToken {
        - _token_task_list: str
        - _token_front_matter: str
        - _token_block_quote: str
        - _token_unordered_list_start: str
        - _token_ordered_list_start: str
        - _token_new_list_item: str
        + is_task_list() bool
    }
    note for MarkdownToken "Added is_task_list property and reordered token constants"
Loading

File-Level Changes

Change Details Files
Added task list token support in Rule MD018
  • Added is_task_list property to MarkdownToken class
  • Updated token handling to recognize task list tokens
  • Added test case for task list handling
  • Reorganized token constants for better grouping
pymarkdown/tokens/markdown_token.py
pymarkdown/plugins/rule_md_018.py
test/rules/test_md018.py
Added functionality to capture test cases in a specified directory
  • Added -d option to ptest.cmd for specifying capture directory
  • Modified test infrastructure to save Markdown files when directory is specified
  • Added batch testing script for running tests with different extensions
ptest.cmd
test/pytest_execute.py
test/utils.py
batch_tests.cmd
Updated project dependencies and configuration
  • Moved twine package from packages to dev-packages
  • Enhanced run.cmd to properly handle return codes
  • Updated changelog with new features and fixes
Pipfile
run.cmd
newdocs/src/changelog.md

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @jackdewinter - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -1 +1,5 @@
pipenv run python main.py %1 %2 %3 %4 %5 %6 %7 %8 %9
set RETURN_CODE=%ERRORLEVEL%
echo !RETURN_CODE!
echo %RETURN_CODE%
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): The %RETURN_CODE% reference won't show the actual return code since it's not using delayed expansion

Use !RETURN_CODE! consistently since delayed expansion is needed for variables set within the script

)

set xx=
erase %XX_TEMPFILE%
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Temp file cleanup won't happen if script exits early due to an error

Consider implementing cleanup in an error handler block to ensure the temp file is always removed

) else (
pushd %OLDDIR%
cd
cd !PTEST_KEEP_DIRECTORY!
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Directory path handling doesn't properly handle paths containing spaces

Wrap !PTEST_KEEP_DIRECTORY! in quotes to handle paths containing spaces

Copy link

codecov bot commented Dec 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (72523ad) to head (b4c9127).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1281   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          191       191           
  Lines        21390     21393    +3     
  Branches      2751      2751           
=========================================
+ Hits         21390     21393    +3     

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

@jackdewinter jackdewinter merged commit 5245305 into main Dec 8, 2024
15 checks passed
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