Skip to main content

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

  1. Run Pre-Commit Hooks: The PreCommitToHTML class runs the pre-commit hooks using the pre-commit run --all-files command.
  2. 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.
  3. 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 the PreCommitToHTML class 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pre_commit_html-0.1.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pre_commit_html-0.1.4-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pre_commit_html-0.1.4.tar.gz.

File metadata

  • Download URL: pre_commit_html-0.1.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pre_commit_html-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9656a7ebf30d02c3f5a879e89f8b412d05502293b36fbe5cd1d3c47c2a24ac0c
MD5 3fac684703ff79f3be3cc058d004a6f2
BLAKE2b-256 b202051e15216120488193d5f0e16db7f4faade45918010defafec12cbe97b2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pre_commit_html-0.1.4.tar.gz:

Publisher: python-publish.yml on Robotz213/pre_commit_html

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pre_commit_html-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pre_commit_html-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dfff37f8980614061888efeee0a15810267e9f491d595063b0a23ae1827d0fbc
MD5 baee18c4a180f297309ff9063fd54529
BLAKE2b-256 981b8e1d47b18477808ecc36e4fce883b9a97a46f52003b611d06c00e3103dc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pre_commit_html-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on Robotz213/pre_commit_html

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page