Skip to content

Commit 03de1ab

Browse files
authored
Merge pull request #12 from django-components/jo-monorepo
2 parents f8c31bc + 1738db4 commit 03de1ab

File tree

15 files changed

+87
-47
lines changed

15 files changed

+87
-47
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release notes
22

3+
## v1.1.0
4+
5+
- Renamed package from `djc-core-html-parser` to `djc-core`
6+
- Refactored project into a monorepo
7+
38
## v1.0.3
49

510
- Update to Python 3.14

Cargo.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
[package]
2-
name = "djc_core_html_parser"
3-
version = "1.0.3"
4-
edition = "2021"
1+
[workspace]
2+
members = [
3+
"crates/djc-core",
4+
"crates/djc-html-transformer",
5+
]
6+
resolver = "2"
57

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
[lib]
8-
name = "djc_core_html_parser"
9-
crate-type = ["cdylib"]
10-
11-
[dependencies]
8+
[workspace.dependencies]
129
pyo3 = { version = "0.27.0", features = ["extension-module"] }
1310
quick-xml = "0.38.3"
1411

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
# djc-core-html-parser
1+
# djc-core
22

3-
[![PyPI - Version](https://img.shields.io/pypi/v/djc-core-html-parser)](https://pypi.org/project/djc-core-html-parser/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/djc-core-html-parser)](https://pypi.org/project/djc-core-html-parser/) [![PyPI - License](https://img.shields.io/pypi/l/djc-core-html-parser)](https://github.com/django-components/djc-core-html-parser/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/djc-core-html-parser)](https://pypistats.org/packages/djc-core-html-parser) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/django-components/djc-core-html-parser/tests.yml)](https://github.com/django-components/djc-core-html-parser/actions/workflows/tests.yml)
3+
[![PyPI - Version](https://img.shields.io/pypi/v/djc-core)](https://pypi.org/project/djc-core/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/djc-core)](https://pypi.org/project/djc-core/) [![PyPI - License](https://img.shields.io/pypi/l/djc-core)](https://github.com/django-components/djc-core/blob/master/LICENSE/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/djc-core)](https://pypistats.org/packages/djc-core) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/django-components/djc-core/tests.yml)](https://github.com/django-components/djc-core/actions/workflows/tests.yml)
44

5-
HTML parser used by [django-components](https://github.com/django-components/django-components). Written in Rust, exposed as a Python package with [maturin](https://www.maturin.rs/).
6-
7-
This implementation was found to be 40-50x faster than our Python implementation, taking ~90ms to parse 5 MB of HTML.
5+
Rust-based parsers and toolings used by [django-components](https://github.com/django-components/django-components). Exposed as a Python package with [maturin](https://www.maturin.rs/).
86

97
## Installation
108

119
```sh
12-
pip install djc-core-html-parser
10+
pip install djc-core
1311
```
1412

15-
## Usage
13+
## Packages
14+
15+
### HTML transfomer
16+
17+
Transform HTML in a single pass. This is a simple implementation.
18+
19+
This implementation was found to be 40-50x faster than our Python implementation, taking ~90ms to parse 5 MB of HTML.
20+
21+
**Usage**
1622

1723
```python
18-
from djc_core_html_parser import set_html_attributes
24+
from djc_core import set_html_attributes
1925

2026
html = '<div><p>Hello</p></div>'
2127
result, _ = set_html_attributes(
@@ -39,7 +45,7 @@ Then, during the HTML transformation, we check each element for this attribute.
3945
2. Record the attributes that were added to the element, using the value of the watched attribute as the key.
4046

4147
```python
42-
from djc_core_html_parser import set_html_attributes
48+
from djc_core import set_html_attributes
4349

4450
html = """
4551
<div data-watch-id="123">
@@ -117,4 +123,4 @@ To publish a new version of the package, you need to:
117123

118124
1. Bump the version in `pyproject.toml` and `Cargo.toml`
119125
2. Open a PR and merge it to `main`.
120-
3. Create a new tag on the `main` branch with the new version number (e.g. `v1.0.0`), or create a new release in the GitHub UI.
126+
3. Create a new tag on the `main` branch with the new version number (e.g. `1.0.0`), or create a new release in the GitHub UI.

crates/djc-core/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "djc-core"
3+
version = "1.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
[lib]
8+
name = "djc_core"
9+
crate-type = ["cdylib"]
10+
11+
[dependencies]
12+
djc-html-transformer = { path = "../djc-html-transformer" }
13+
pyo3 = { workspace = true }
14+
quick-xml = { workspace = true }

crates/djc-core/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use djc_html_transformer::set_html_attributes;
2+
use pyo3::prelude::*;
3+
4+
/// A Python module implemented in Rust for high-performance transformations.
5+
#[pymodule]
6+
fn djc_core(m: &Bound<'_, PyModule>) -> PyResult<()> {
7+
m.add_function(wrap_pyfunction!(set_html_attributes, m)?)?;
8+
Ok(())
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "djc-html-transformer"
3+
version = "1.0.3"
4+
edition = "2021"
5+
6+
[dependencies]
7+
pyo3 = { workspace = true }
8+
quick-xml = { workspace = true }
File renamed without changes.

djc_core_html_parser/__init__.py renamed to djc_core/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# This file is what maturin auto-generates. But it seems maturin omits it when we have a __init__.pyi file.
33
# So we have to manually include it here.
44

5-
from .djc_core_html_parser import *
5+
from .djc_core import *
66

7-
__doc__ = djc_core_html_parser.__doc__
8-
if hasattr(djc_core_html_parser, "__all__"):
9-
__all__ = djc_core_html_parser.__all__
7+
__doc__ = djc_core.__doc__
8+
if hasattr(djc_core, "__all__"):
9+
__all__ = djc_core.__all__
File renamed without changes.

0 commit comments

Comments
 (0)