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

Add mdformat to pre-commit #1267

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

RobertRosca
Copy link
Contributor

#1183 suggests adding "prettier" markdown formatter to pre-commit/ci, not sure if that means just any formatter to make markdown prettier or specifically the formatter called prettier 😛

This PR:

  • Adds the ExecutableBooks Markdown formatter to pre-commit. I chose this instead of prettier as for the reasons mentioned in the 'Why not use prettier instead?' section of their readme
  • Adds in a separate pre-commit workflow to execute pre-commit. Personally I prefer having these linting checks in a different workflow to the CI one, as this way the CI will still execute even if there are formatting issues, but I don't have a strong preference
  • Makes required changes to existing markdown files (found by running pre-commit run --all)

Closes #1183

@codecov
Copy link

codecov bot commented Nov 5, 2022

Codecov Report

Base: 83.45% // Head: 83.45% // No change to project coverage 👍

Coverage data is based on head (e56b8bd) compared to base (aebcf6a).
Patch has no changes to coverable lines.

❗ Current head e56b8bd differs from pull request most recent head 08d01d0. Consider uploading reports for the commit 08d01d0 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1267   +/-   ##
=======================================
  Coverage   83.45%   83.45%           
=======================================
  Files          31       31           
  Lines        4224     4224           
  Branches      620      620           
=======================================
  Hits         3525     3525           
  Misses        523      523           
  Partials      176      176           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

Pure python and the other noted reasons are great reasons to use this. Thanks for sharing that this exists!

Lets just workout if we can remove the action or remove pre-commit CI - I think we can ...

.github/workflows/pre-commit.yml Outdated Show resolved Hide resolved
@cooperlees cooperlees added the skip news Skip CI check for news/changelog label Nov 5, 2022
@cooperlees
Copy link
Contributor

It seems mdformat also has MyST support. Should we look into this since we use that render our docs?

@cooperlees cooperlees added the enhancement New feature or request label Nov 5, 2022
@RobertRosca RobertRosca force-pushed the feat/pre-commit-md-formatting branch from e56b8bd to 08d01d0 Compare November 7, 2022 16:10
@RobertRosca
Copy link
Contributor Author

It seems mdformat also has MyST support. Should we look into this since we use that render our docs?

I added the myst formatter, ran it, and it made a few minor changes to escape curly braces. One of them was in the docs, changing a fence ::{warning} to ::\{warning}, which seemed a bit fishy. I built the docs and that showed some warnings:

writing output... [100%] storage_options                                                                                                                                                 
/home/roscar/work/github.com/RobertRosca/bandersnatch/docs/mirror_configuration.md:114: WARNING: Pygments lexer name '\\{warning}' is not known
/home/roscar/work/github.com/RobertRosca/bandersnatch/docs/mirror_configuration.md:165: WARNING: Pygments lexer name '\\{note}' is not known
generating indices... genindex py-modindex done

There are some issues (executablebooks/mdformat-myst#13) related to this, and it looks like the escaping is expected behaviour. So I'd recommend not adding this formatter in as it will would always attempt to reformat this fence syntax, causing issues with the docs.

Copy link
Contributor

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

Awesome then. Thanks for this and digging into everything.

@cooperlees cooperlees merged commit e5127cf into pypa:main Nov 7, 2022
@RobertRosca RobertRosca deleted the feat/pre-commit-md-formatting branch November 8, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request skip news Skip CI check for news/changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add prettier markdown formatting to CI
2 participants