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

MAINT - Update pre-commit hooks #45

Merged
merged 9 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ repos:

# python
- repo: https://github.com/psf/black
rev: 24.1.1
rev: 24.3.0
hooks:
- id: black
exclude: ^test/scripts/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.3.4
hooks:
- id: ruff

Expand All @@ -48,4 +48,11 @@ repos:
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [css, markdown]
types_or: [css, markdown, html]


- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.34.1
hooks:
- id: djlint-jinja
types_or: ["jinja"]
Carreau marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Welcome! And thanks for taking your time to contribute to this project 🤩
- [Creating your development environment 👩🏻‍💻 👨🏼‍💻](#creating-your-development-environment--)
- [Running the tests](#running-the-tests)
- [Rendering the HTML examples](#rendering-the-html-examples)
- [Linting and formatting](#linting-and-formatting)
- [Adding a new theme 🎨](#adding-a-new-theme-)
- [Where to add a new theme 👩🏼‍🎨](#where-to-add-a-new-theme-)
- [Customize your `style.py` file](#customize-your-stylepy-file)
Expand Down Expand Up @@ -85,6 +86,15 @@ hatch run dev:render_html
This will add the HTML files under `docs/` for each supported theme.
We recommend using your favorite browser to see the rich HTML output.

### Linting and formatting

We use several linters and formatters to ensure the code is consistent and clean.
You can run this with:

```bash
hatch run dev:lint
```

## Adding a new theme 🎨

### Where to add a new theme 👩🏼‍🎨
Expand Down
1 change: 1 addition & 0 deletions a11y_pygments/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging


logger = logging.getLogger()

logging.basicConfig(
Expand Down
1 change: 1 addition & 0 deletions a11y_pygments/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os

from pathlib import Path
from typing import Union

Expand Down
1 change: 1 addition & 0 deletions a11y_pygments/utils/wcag_contrast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html

import re

from typing import Tuple, Union


Expand Down
179 changes: 100 additions & 79 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,107 +1,128 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accessible Pygments Themes</title>
<head>
<meta charset="utf-8" />
<title>Accessible Pygments Themes</title>

<link rel="stylesheet" type="text/css" title="a11y dark" href="./index.css">
</head>
<body>
<link
rel="stylesheet"
type="text/css"
title="a11y dark"
href="./index.css"
/>
</head>
<body>
<div class="title">
<h1>Accessible Pygments Themes Demo 🎨</h1>
<h1>Accessible Pygments Themes Demo 🎨</h1>
</div>
<div class="selection">
<label>Choose a theme:</label>
<!-- themes -->
<select name="themes" id="themes">
<option>a11y-dark</option>
<option>a11y-light</option>
<option>a11y-high-contrast-dark</option>
<option>a11y-hight-contrast-light</option>
<option>pitaya-smoothie</option>
<option>github-light</option>
<option>github-dark</option>
<option>github-light-colorblind</option>
<option>github-dark-colorblind</option>
<option>github-light-high-contrast</option>
<option>github-dark-high-contrast</option>
<option>gotthard-light</option>
<option>gotthard-dark</option>
<option>blinds-light</option>
<option>blinds-dark</option>
<option>greative</option>
</select>
<label>Choose a theme:</label>
<!-- themes -->
<select name="themes" id="themes">
<option>a11y-dark</option>
<option>a11y-light</option>
<option>a11y-high-contrast-dark</option>
<option>a11y-hight-contrast-light</option>
<option>pitaya-smoothie</option>
<option>github-light</option>
<option>github-dark</option>
<option>github-light-colorblind</option>
<option>github-dark-colorblind</option>
<option>github-light-high-contrast</option>
<option>github-dark-high-contrast</option>
<option>gotthard-light</option>
<option>gotthard-dark</option>
<option>blinds-light</option>
<option>blinds-dark</option>
<option>greative</option>
</select>
</div>

<div class="cards">
<!-------------------------------- BASH -------------------------------->

<!-------------------------------- BASH -------------------------------->

<div class="card">
<div class="card-title">
<h2>Bash</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/bash.html" title="Bash syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>Bash</h2>
</div>
<div class="card-body">
<iframe
src="./_build/a11y-dark/bash.html"
title="Bash syntax highlighting example"
></iframe>
</div>
</div>

<!-------------------------------- JAVASCRIPT -------------------------->
<!-------------------------------- JAVASCRIPT -------------------------->

<div class="card">
<div class="card-title">
<h2>Javascript</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/js.html" title="JavaScript syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>Javascript</h2>
</div>
<div class="card-body">
<iframe
src="./_build/a11y-dark/js.html"
title="JavaScript syntax highlighting example"
></iframe>
</div>
</div>

<!-------------------------------- CSS --------------------------------->
<!-------------------------------- CSS --------------------------------->

<div class="card">
<div class="card-title">
<h2>CSS</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/css.html" title="CSS syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>CSS</h2>
</div>
<div class="card-body">
<iframe
src="./_build/a11y-dark/css.html"
title="CSS syntax highlighting example"
></iframe>
</div>
</div>

<!-------------------------------- HTML -------------------------------->
<!-------------------------------- HTML -------------------------------->

<div class="card">
<div class="card-title">
<h2>HTML</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/html.html" title="HTML syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>HTML</h2>
</div>
<div class="card-body">
<iframe
src="./_build/a11y-dark/html.html"
title="HTML syntax highlighting example"
></iframe>
</div>
</div>

<!-------------------------------- MARKDOWN ---------------------------->
<!-------------------------------- MARKDOWN ---------------------------->

<div class="card">
<div class="card-title">
<h2>Markdown</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/md.html" title="Markdown syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>Markdown</h2>
</div>
<div class="card-body">
<iframe
src="./_build/a11y-dark/md.html"
title="Markdown syntax highlighting example"
></iframe>
</div>
</div>

<!-------------------------------- PYTHON ------------------------------>
<!-------------------------------- PYTHON ------------------------------>

<div class="card">
<div class="card-title">
<h2>Python</h2>
</div>
<div class="card-body">
<iframe src="./_build/a11y-dark/py.html" title="Python syntax highlighting example"></iframe>
</div>
<div class="card">
<div class="card-title">
<h2>Python</h2>
</div>

<div class="card-body">
<iframe
src="./_build/a11y-dark/py.html"
title="Python syntax highlighting example"
></iframe>
</div>
</div>
</div>
<script src="./index.js"></script>
</body>
</body>
</html>
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ post-install-commands = ["playwright install"]
features = ["tests"]

[tool.hatch.envs.dev.scripts]
lint = "pre-commit run --all-files"
render_html = "python test/render_html.py"
create_css = "python test/run_css.py --save-dir docs/_build"
update_theme_docs = "python scripts/update_theme_docs.py"
Expand All @@ -104,6 +105,8 @@ tests = "python -m pytest test/test_*.py"
[tool.isort]
profile = "black"
skip_gitignore = true
lines_between_types = 1
lines_after_imports = 2

[tool.ruff]
fix = true
Expand All @@ -112,3 +115,9 @@ ignore = [
"E501",
# line too long | Black takes care of this
]

[tool.djlint]
# useful for jinja templates
preserve_leading_space=true
profile="jinja"
close_void_tags=true
2 changes: 2 additions & 0 deletions scripts/update_theme_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import string
import sys

from argparse import ArgumentParser
from importlib import import_module
from inspect import getdoc
Expand All @@ -21,6 +22,7 @@
hexstr_without_hash,
)


HERE = Path(__file__).parent
REPO = HERE.parent

Expand Down
2 changes: 2 additions & 0 deletions test/render_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import os

from pathlib import Path

from pygments import highlight as pygments_highlight
Expand All @@ -16,6 +17,7 @@

from a11y_pygments.utils.utils import get_themes_names


# List of available language examples
languages = {
"python": "py",
Expand Down
Loading
Loading