Skip to content

Commit 42e41c5

Browse files
authored
Merge pull request #1 from django-components/jo-feat-html-parser
2 parents 413dd86 + 1499d58 commit 42e41c5

20 files changed

+1740
-0
lines changed

.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: ["EmilStenstrom"]
2+

.github/workflows/publish.yml

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# This file is autogenerated by maturin v1.8.1
2+
# To update, run
3+
#
4+
# maturin generate-ci github
5+
#
6+
name: Publish to PyPI
7+
8+
on:
9+
push:
10+
tags:
11+
- '*'
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
linux:
21+
runs-on: ${{ matrix.platform.runner }}
22+
strategy:
23+
matrix:
24+
platform:
25+
- runner: ubuntu-22.04
26+
target: x86_64
27+
- runner: ubuntu-22.04
28+
target: x86
29+
- runner: ubuntu-22.04
30+
target: aarch64
31+
- runner: ubuntu-22.04
32+
target: armv7
33+
- runner: ubuntu-22.04
34+
target: s390x
35+
- runner: ubuntu-22.04
36+
target: ppc64le
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: 3.x
42+
- name: Build wheels
43+
uses: PyO3/maturin-action@v1
44+
with:
45+
target: ${{ matrix.platform.target }}
46+
args: --release --out dist --find-interpreter
47+
sccache: 'true'
48+
manylinux: auto
49+
- name: Upload wheels
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: wheels-linux-${{ matrix.platform.target }}
53+
path: dist
54+
55+
musllinux:
56+
runs-on: ${{ matrix.platform.runner }}
57+
strategy:
58+
matrix:
59+
platform:
60+
- runner: ubuntu-22.04
61+
target: x86_64
62+
- runner: ubuntu-22.04
63+
target: x86
64+
- runner: ubuntu-22.04
65+
target: aarch64
66+
- runner: ubuntu-22.04
67+
target: armv7
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: actions/setup-python@v5
71+
with:
72+
python-version: 3.x
73+
- name: Build wheels
74+
uses: PyO3/maturin-action@v1
75+
with:
76+
target: ${{ matrix.platform.target }}
77+
args: --release --out dist --find-interpreter
78+
sccache: 'true'
79+
manylinux: musllinux_1_2
80+
- name: Upload wheels
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: wheels-musllinux-${{ matrix.platform.target }}
84+
path: dist
85+
86+
windows:
87+
runs-on: ${{ matrix.platform.runner }}
88+
strategy:
89+
matrix:
90+
platform:
91+
- runner: windows-latest
92+
target: x64
93+
- runner: windows-latest
94+
target: x86
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: actions/setup-python@v5
98+
with:
99+
python-version: 3.x
100+
architecture: ${{ matrix.platform.target }}
101+
- name: Build wheels
102+
uses: PyO3/maturin-action@v1
103+
with:
104+
target: ${{ matrix.platform.target }}
105+
args: --release --out dist --find-interpreter
106+
sccache: 'true'
107+
- name: Upload wheels
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-windows-${{ matrix.platform.target }}
111+
path: dist
112+
113+
macos:
114+
runs-on: ${{ matrix.platform.runner }}
115+
strategy:
116+
matrix:
117+
platform:
118+
- runner: macos-13
119+
target: x86_64
120+
- runner: macos-14
121+
target: aarch64
122+
steps:
123+
- uses: actions/checkout@v4
124+
- uses: actions/setup-python@v5
125+
with:
126+
python-version: 3.x
127+
- name: Build wheels
128+
uses: PyO3/maturin-action@v1
129+
with:
130+
target: ${{ matrix.platform.target }}
131+
args: --release --out dist --find-interpreter
132+
sccache: 'true'
133+
- name: Upload wheels
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: wheels-macos-${{ matrix.platform.target }}
137+
path: dist
138+
139+
sdist:
140+
runs-on: ubuntu-latest
141+
steps:
142+
- uses: actions/checkout@v4
143+
- name: Build sdist
144+
uses: PyO3/maturin-action@v1
145+
with:
146+
command: sdist
147+
args: --out dist
148+
- name: Upload sdist
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: wheels-sdist
152+
path: dist
153+
154+
release:
155+
name: Release
156+
runs-on: ubuntu-latest
157+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
158+
needs: [linux, musllinux, windows, macos, sdist]
159+
permissions:
160+
# Use to sign the release artifacts
161+
id-token: write
162+
# Used to upload release artifacts
163+
contents: write
164+
# Used to generate artifact attestation
165+
attestations: write
166+
steps:
167+
- uses: actions/download-artifact@v4
168+
- name: Generate artifact attestation
169+
uses: actions/attest-build-provenance@v1
170+
with:
171+
subject-path: 'wheels-*/*'
172+
- name: Publish to PyPI
173+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
174+
uses: PyO3/maturin-action@v1
175+
env:
176+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
177+
with:
178+
command: upload
179+
args: --non-interactive --skip-existing wheels-*/*

.github/workflows/tests.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'dev'
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
17+
os: [ubuntu-20.04, windows-latest]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
# First check Rust tests
23+
- name: Install Rust toolchain
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
toolchain: stable
27+
components: rustfmt, clippy
28+
29+
- name: Cache Rust dependencies
30+
uses: Swatinem/rust-cache@v2
31+
32+
- name: Run Rust tests
33+
run: cargo test
34+
35+
# After Rust tests pass, run Python tests next
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
cache: "pip"
41+
42+
- name: Install Python dependencies
43+
run: |
44+
# NOTE: maturin requires a virtual environment to be active
45+
python -m venv .venv
46+
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
47+
python -m pip install --upgrade pip
48+
python -m pip install -r requirements-ci.txt
49+
50+
- name: Build Python package
51+
run: |
52+
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
53+
maturin develop
54+
55+
- name: Run Python tests
56+
run: |
57+
${{ runner.os == 'Windows' && '.venv\Scripts\activate' || 'source .venv/bin/activate' }}
58+
pytest

.gitignore

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/target
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
.pytest_cache/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
env/
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
include/
30+
man/
31+
venv/
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*,cover
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
*.sqlite3
60+
61+
# Sphinx documentation
62+
docs/_build/
63+
64+
# PyBuilder
65+
target/
66+
67+
# VSCode
68+
.vscode
69+
70+
# Poetry
71+
# lock file is not needed for development
72+
# as project supports variety of Django versions
73+
poetry.lock
74+
75+
# PyCharm
76+
.idea/
77+
78+
# Python environment
79+
.venv/
80+
.DS_Store
81+
.python-version
82+
site
83+
.direnv/
84+
.envrc
85+
86+
# JS, NPM Dependency directories
87+
node_modules/
88+
jspm_packages/
89+
90+
# Mr Developer
91+
.mr.developer.cfg
92+
.project
93+
.pydevproject
94+
95+
# Rope
96+
.ropeproject

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Release notes
2+
3+
## v1.0.0
4+
5+
Initial release.
6+
7+
#### Feat
8+
9+
- Parser can be configured to add attributes to the HTML elements.
10+
- Parser optionally captures what attributes were set on HTML elements
11+
identified by a specific attribute.

0 commit comments

Comments
 (0)