Format results from pre-commit cmd to HTML file
Project description
Pre-Commit Formatter
Portuguese version here(Link only works on the project page).
This project is designed to run pre-commit hooks and format the results into an HTML file for easy viewing.
Summary
- How It Works
- Installation
- Usage
- Project Structure
- Templates
- Example
- License
- Contributing
- Code of Conduct
How It Works
- Run Pre-Commit Hooks: The
PreCommitToHTMLclass runs the pre-commit hooks using thepre-commit run --all-filescommand. - Parse Output: The output from the pre-commit hooks is parsed to extract relevant information such as file paths, line numbers, column numbers, and error messages.
- Generate HTML: The parsed information is then formatted into an HTML file using Jinja2 templates. The HTML file includes links to the relevant lines in the source code and references to the documentation for the errors.
Installation
To use this project, you need to have Python and pre-commit installed. You can install the required dependencies using pip:
poetry install
Usage
To run the pre-commit formatter, execute the following command:
python -m pre_commit_html
This will generate an HTML file named result_pre_commit.html in the project directory.
Project Structure
pre_commit_html/__main__.py: Contains the main function to run the pre-commit formatter.pre_commit_html/__init__.py: Contains thePreCommitToHTMLclass which handles running the pre-commit hooks and formatting the output.site/templates/: Contains the Jinja2 templates used to generate the HTML file.
Templates
The project uses Jinja2 templates to format the HTML output. The templates are located in the site/templates/ directory and include:
code_part.jinja: Template for formatting code parts.code_error.jinja: Template for formatting code errors.html_content.jinja: Template for the overall HTML content.
Example
Here is an example of how the HTML output might look:
<h3>File: <a href="./path/to/file.py:10:5">path/to/file.py:10:5</a></h3>
<p>
Error: <a href="https://docs.astral.sh/ruff/rules/#E123">E123</a> Some error
message
</p>
<pre>
| Some code part |
</pre>
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pre_commit_html-0.1.4.post1.tar.gz.
File metadata
- Download URL: pre_commit_html-0.1.4.post1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd27261fe38b680cdde43b2cfcf9e8cabb5ee2cf821b2bb05a32a0fcbe833ef
|
|
| MD5 |
fc35da1775f3874b40ff9a67dee7a9f0
|
|
| BLAKE2b-256 |
ef783e929c5db6796b3071e781860ced1eda4cf45a4cdddd37112e7a8c28efc5
|
Provenance
The following attestation bundles were made for pre_commit_html-0.1.4.post1.tar.gz:
Publisher:
python-publish.yml on Robotz213/pre_commit_html
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pre_commit_html-0.1.4.post1.tar.gz -
Subject digest:
8fd27261fe38b680cdde43b2cfcf9e8cabb5ee2cf821b2bb05a32a0fcbe833ef - Sigstore transparency entry: 173633167
- Sigstore integration time:
-
Permalink:
Robotz213/pre_commit_html@397f22d58144482b8145daf784f021755fc36a0c -
Branch / Tag:
refs/tags/v0.1.4.post1 - Owner: https://github.com/Robotz213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@397f22d58144482b8145daf784f021755fc36a0c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pre_commit_html-0.1.4.post1-py3-none-any.whl.
File metadata
- Download URL: pre_commit_html-0.1.4.post1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4c62f50b8b89866ecde877fb9eeae4825b923c32b37e017339c853e88c3461a
|
|
| MD5 |
e14967e02a316f5352370bb48bca3847
|
|
| BLAKE2b-256 |
a19d3c65541c590ff76efddcf38f653fbf649f1c45add9351487b0864a08ff4c
|
Provenance
The following attestation bundles were made for pre_commit_html-0.1.4.post1-py3-none-any.whl:
Publisher:
python-publish.yml on Robotz213/pre_commit_html
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pre_commit_html-0.1.4.post1-py3-none-any.whl -
Subject digest:
d4c62f50b8b89866ecde877fb9eeae4825b923c32b37e017339c853e88c3461a - Sigstore transparency entry: 173633169
- Sigstore integration time:
-
Permalink:
Robotz213/pre_commit_html@397f22d58144482b8145daf784f021755fc36a0c -
Branch / Tag:
refs/tags/v0.1.4.post1 - Owner: https://github.com/Robotz213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@397f22d58144482b8145daf784f021755fc36a0c -
Trigger Event:
release
-
Statement type: