docxium 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docxium-0.1.0/.github/workflows/CI.yml +79 -0
- docxium-0.1.0/.github/workflows/docs.yml +49 -0
- docxium-0.1.0/.github/workflows/release.yml +57 -0
- docxium-0.1.0/.gitignore +32 -0
- docxium-0.1.0/Cargo.lock +148 -0
- docxium-0.1.0/Cargo.toml +19 -0
- docxium-0.1.0/LICENSE +21 -0
- docxium-0.1.0/PKG-INFO +153 -0
- docxium-0.1.0/README.md +142 -0
- docxium-0.1.0/docs/_static/benchmarks-dark.svg +109 -0
- docxium-0.1.0/docs/_static/benchmarks-light.svg +109 -0
- docxium-0.1.0/docs/_static/img/comment-parts.png +0 -0
- docxium-0.1.0/docs/_static/img/example-docx-01.png +0 -0
- docxium-0.1.0/docs/_static/img/hdrftr-01.png +0 -0
- docxium-0.1.0/docs/_static/img/hdrftr-02.png +0 -0
- docxium-0.1.0/docs/attribution.rst +9 -0
- docxium-0.1.0/docs/benchmarks.rst +170 -0
- docxium-0.1.0/docs/conf.py +39 -0
- docxium-0.1.0/docs/index.rst +34 -0
- docxium-0.1.0/docs/installation.rst +43 -0
- docxium-0.1.0/docs/python-docx/LICENSE +20 -0
- docxium-0.1.0/docs/python-docx/NOTICE +11 -0
- docxium-0.1.0/docs/python-docx/api/comments.rst +27 -0
- docxium-0.1.0/docs/python-docx/api/dml.rst +16 -0
- docxium-0.1.0/docs/python-docx/api/document.rst +117 -0
- docxium-0.1.0/docs/python-docx/api/enum/MsoColorType.rst +23 -0
- docxium-0.1.0/docs/python-docx/api/enum/MsoThemeColorIndex.rst +71 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdAlignParagraph.rst +45 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdBuiltinStyle.rst +415 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdCellVerticalAlignment.rst +32 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdColorIndex.rst +62 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdLineSpacing.rst +36 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdOrientation.rst +23 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdRowAlignment.rst +24 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdRowHeightRule.rst +26 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdSectionStart.rst +32 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdStyleType.rst +29 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdTabAlignment.rst +38 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdTabLeader.rst +26 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdTableDirection.rst +24 -0
- docxium-0.1.0/docs/python-docx/api/enum/WdUnderline.rst +69 -0
- docxium-0.1.0/docs/python-docx/api/enum/index.rst +26 -0
- docxium-0.1.0/docs/python-docx/api/section.rst +41 -0
- docxium-0.1.0/docs/python-docx/api/settings.rst +13 -0
- docxium-0.1.0/docs/python-docx/api/shape.rst +31 -0
- docxium-0.1.0/docs/python-docx/api/shared.rst +59 -0
- docxium-0.1.0/docs/python-docx/api/style.rst +97 -0
- docxium-0.1.0/docs/python-docx/api/table.rst +55 -0
- docxium-0.1.0/docs/python-docx/api/text.rst +63 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/comments.rst +419 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/coreprops.rst +199 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/header.rst +291 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/numbering.rst +55 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/sections.rst +311 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/settings.rst +196 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/shapes/index.rst +68 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/shapes/picture.rst +252 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/shapes/shapes-inline-size.rst +101 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/shapes/shapes-inline.rst +197 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/character-style.rst +161 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/index.rst +330 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/latent-styles.rst +266 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/paragraph-style.rst +142 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/style.rst +501 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/styles/styles.rst +222 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/table/cell-merge.rst +572 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/table/index.rst +212 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/table/table-cell.rst +216 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/table/table-props.rst +251 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/table/table-row.rst +133 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/breaks.rst +269 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/font-color.rst +288 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/font-highlight-color.rst +177 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/font.rst +403 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/hyperlink.rst +383 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/index.rst +16 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/paragraph-format.rst +473 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/run-content.rst +77 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/tab-stops.rst +256 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/features/text/underline.rst +155 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/index.rst +36 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/schema/ct_body.rst +165 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/schema/ct_document.rst +109 -0
- docxium-0.1.0/docs/python-docx/dev/analysis/schema/ct_p.rst +133 -0
- docxium-0.1.0/docs/python-docx/index.rst +113 -0
- docxium-0.1.0/docs/python-docx/substitutions.inc +133 -0
- docxium-0.1.0/docs/python-docx/user/api-concepts.rst +31 -0
- docxium-0.1.0/docs/python-docx/user/comments.rst +168 -0
- docxium-0.1.0/docs/python-docx/user/documents.rst +94 -0
- docxium-0.1.0/docs/python-docx/user/hdrftr.rst +166 -0
- docxium-0.1.0/docs/python-docx/user/install.rst +38 -0
- docxium-0.1.0/docs/python-docx/user/quickstart.rst +328 -0
- docxium-0.1.0/docs/python-docx/user/sections.rst +121 -0
- docxium-0.1.0/docs/python-docx/user/shapes.rst +27 -0
- docxium-0.1.0/docs/python-docx/user/styles-understanding.rst +382 -0
- docxium-0.1.0/docs/python-docx/user/styles-using.rst +391 -0
- docxium-0.1.0/docs/python-docx/user/tables.rst +202 -0
- docxium-0.1.0/docs/python-docx/user/text.rst +389 -0
- docxium-0.1.0/docs/reference.rst +14 -0
- docxium-0.1.0/docs/requirements.txt +2 -0
- docxium-0.1.0/docs/usage.rst +81 -0
- docxium-0.1.0/pyproject.toml +18 -0
- docxium-0.1.0/python/docxium/__init__.py +32 -0
- docxium-0.1.0/python/docxium/_alias.py +51 -0
- docxium-0.1.0/python/docxium/_batch.py +173 -0
- docxium-0.1.0/python/docxium/py.typed +0 -0
- docxium-0.1.0/src/lib.rs +437 -0
- docxium-0.1.0/tests/test_docxium.py +530 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Builds the wheels and the sdist and tests every wheel on the oldest and a recent Python.
|
|
2
|
+
# release.yml calls this workflow and publishes the artifacts.
|
|
3
|
+
#
|
|
4
|
+
# Every wheel is built and tested on a runner of its own architecture. Linux arm64 has no
|
|
5
|
+
# "latest" runner label, so a versioned one is used.
|
|
6
|
+
|
|
7
|
+
name: CI
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches:
|
|
12
|
+
- main
|
|
13
|
+
- master
|
|
14
|
+
pull_request:
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
workflow_call:
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
wheels:
|
|
23
|
+
name: wheel (${{ matrix.name }})
|
|
24
|
+
runs-on: ${{ matrix.runner }}
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
include:
|
|
29
|
+
- name: linux-x86_64
|
|
30
|
+
runner: ubuntu-latest
|
|
31
|
+
- name: linux-aarch64
|
|
32
|
+
runner: ubuntu-24.04-arm
|
|
33
|
+
- name: windows-x64
|
|
34
|
+
runner: windows-latest
|
|
35
|
+
- name: macos-aarch64
|
|
36
|
+
runner: macos-latest
|
|
37
|
+
- name: macos-x86_64
|
|
38
|
+
runner: macos-15-intel
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v7
|
|
41
|
+
- uses: actions/setup-python@v7
|
|
42
|
+
with:
|
|
43
|
+
python-version: "3.x"
|
|
44
|
+
- name: Build the wheel
|
|
45
|
+
uses: PyO3/maturin-action@v1
|
|
46
|
+
with:
|
|
47
|
+
args: --release --out dist
|
|
48
|
+
manylinux: auto
|
|
49
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
50
|
+
- name: Upload the wheel
|
|
51
|
+
uses: actions/upload-artifact@v7
|
|
52
|
+
with:
|
|
53
|
+
name: wheels-${{ matrix.name }}
|
|
54
|
+
path: dist
|
|
55
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
56
|
+
- name: Test the wheel
|
|
57
|
+
shell: bash
|
|
58
|
+
run: |
|
|
59
|
+
set -e
|
|
60
|
+
for version in 3.9 3.14; do
|
|
61
|
+
uv venv --python "$version" ".venv-$version"
|
|
62
|
+
uv pip install --python ".venv-$version" dist/*.whl
|
|
63
|
+
uv run --no-project --python ".venv-$version" python -m unittest discover tests
|
|
64
|
+
done
|
|
65
|
+
|
|
66
|
+
sdist:
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v7
|
|
70
|
+
- name: Build the sdist
|
|
71
|
+
uses: PyO3/maturin-action@v1
|
|
72
|
+
with:
|
|
73
|
+
command: sdist
|
|
74
|
+
args: --out dist
|
|
75
|
+
- name: Upload the sdist
|
|
76
|
+
uses: actions/upload-artifact@v7
|
|
77
|
+
with:
|
|
78
|
+
name: wheels-sdist
|
|
79
|
+
path: dist
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- master
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pages
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7
|
|
22
|
+
- uses: actions/setup-python@v7
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.13"
|
|
25
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
26
|
+
- name: Install docxium and the documentation tools
|
|
27
|
+
run: |
|
|
28
|
+
pip install maturin
|
|
29
|
+
pip install .
|
|
30
|
+
pip install -r docs/requirements.txt
|
|
31
|
+
- name: Build the documentation
|
|
32
|
+
run: sphinx-build -b html docs docs/_build/html
|
|
33
|
+
- uses: actions/configure-pages@v6
|
|
34
|
+
- uses: actions/upload-pages-artifact@v5
|
|
35
|
+
with:
|
|
36
|
+
path: docs/_build/html
|
|
37
|
+
|
|
38
|
+
deploy:
|
|
39
|
+
needs: build
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
permissions:
|
|
42
|
+
pages: write
|
|
43
|
+
id-token: write
|
|
44
|
+
environment:
|
|
45
|
+
name: github-pages
|
|
46
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
47
|
+
steps:
|
|
48
|
+
- id: deployment
|
|
49
|
+
uses: actions/deploy-pages@v5
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Publishes to PyPI with Trusted Publishing (OIDC); no API token is stored in the repository.
|
|
2
|
+
#
|
|
3
|
+
# PyPI setup: add a trusted publisher for the project "docxium" with
|
|
4
|
+
# owner: cmostw, repository: docxium, workflow: release.yml, environment: pypi.
|
|
5
|
+
#
|
|
6
|
+
# Trigger: push a tag named v<version>, for example v0.1.0.
|
|
7
|
+
|
|
8
|
+
name: Release
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
tags:
|
|
13
|
+
- 'v*'
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
uses: ./.github/workflows/CI.yml
|
|
21
|
+
|
|
22
|
+
publish:
|
|
23
|
+
name: Publish to PyPI
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment:
|
|
27
|
+
name: pypi
|
|
28
|
+
url: https://pypi.org/p/docxium
|
|
29
|
+
permissions:
|
|
30
|
+
# OIDC token for PyPI and for the attestation
|
|
31
|
+
id-token: write
|
|
32
|
+
attestations: write
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v7
|
|
35
|
+
- name: Check that the tag matches the package version
|
|
36
|
+
run: |
|
|
37
|
+
python3 - <<'PY'
|
|
38
|
+
import os
|
|
39
|
+
import tomllib
|
|
40
|
+
|
|
41
|
+
tag = os.environ["GITHUB_REF_NAME"].removeprefix("v")
|
|
42
|
+
versions = {
|
|
43
|
+
"pyproject.toml": tomllib.load(open("pyproject.toml", "rb"))["project"]["version"],
|
|
44
|
+
"Cargo.toml": tomllib.load(open("Cargo.toml", "rb"))["package"]["version"],
|
|
45
|
+
}
|
|
46
|
+
mismatched = {name: v for name, v in versions.items() if v != tag}
|
|
47
|
+
if mismatched:
|
|
48
|
+
raise SystemExit(f"tag {tag} does not match {mismatched}")
|
|
49
|
+
PY
|
|
50
|
+
- uses: actions/download-artifact@v8
|
|
51
|
+
- name: Generate artifact attestation
|
|
52
|
+
uses: actions/attest@v4
|
|
53
|
+
with:
|
|
54
|
+
subject-path: 'wheels-*/*'
|
|
55
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
56
|
+
- name: Publish to PyPI
|
|
57
|
+
run: uv publish --trusted-publishing always 'wheels-*/*'
|
docxium-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python / uv
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*.egg-info/
|
|
6
|
+
|
|
7
|
+
# Python build artifacts
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
docs/_build/
|
|
11
|
+
|
|
12
|
+
# Compiled extension and debug symbols produced by maturin
|
|
13
|
+
*.so
|
|
14
|
+
*.pdb
|
|
15
|
+
|
|
16
|
+
# Rust
|
|
17
|
+
target/
|
|
18
|
+
|
|
19
|
+
# Test / lint / type-check caches
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.ruff_cache/
|
|
22
|
+
.mypy_cache/
|
|
23
|
+
.coverage
|
|
24
|
+
htmlcov/
|
|
25
|
+
|
|
26
|
+
# IDE / editor
|
|
27
|
+
.vscode/
|
|
28
|
+
.idea/
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
docxium-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "docxium"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"pyo3",
|
|
10
|
+
"quick-xml",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[[package]]
|
|
14
|
+
name = "heck"
|
|
15
|
+
version = "0.5.0"
|
|
16
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
17
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
18
|
+
|
|
19
|
+
[[package]]
|
|
20
|
+
name = "libc"
|
|
21
|
+
version = "0.2.190"
|
|
22
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
23
|
+
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
|
24
|
+
|
|
25
|
+
[[package]]
|
|
26
|
+
name = "memchr"
|
|
27
|
+
version = "2.8.3"
|
|
28
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
29
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
30
|
+
|
|
31
|
+
[[package]]
|
|
32
|
+
name = "once_cell"
|
|
33
|
+
version = "1.21.4"
|
|
34
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
35
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
36
|
+
|
|
37
|
+
[[package]]
|
|
38
|
+
name = "portable-atomic"
|
|
39
|
+
version = "1.15.0"
|
|
40
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
41
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
42
|
+
|
|
43
|
+
[[package]]
|
|
44
|
+
name = "proc-macro2"
|
|
45
|
+
version = "1.0.107"
|
|
46
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
47
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
48
|
+
dependencies = [
|
|
49
|
+
"unicode-ident",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "pyo3"
|
|
54
|
+
version = "0.29.3"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
|
|
57
|
+
dependencies = [
|
|
58
|
+
"libc",
|
|
59
|
+
"once_cell",
|
|
60
|
+
"portable-atomic",
|
|
61
|
+
"pyo3-build-config",
|
|
62
|
+
"pyo3-ffi",
|
|
63
|
+
"pyo3-macros",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "pyo3-build-config"
|
|
68
|
+
version = "0.29.3"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
|
|
71
|
+
dependencies = [
|
|
72
|
+
"target-lexicon",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "pyo3-ffi"
|
|
77
|
+
version = "0.29.3"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
|
|
80
|
+
dependencies = [
|
|
81
|
+
"libc",
|
|
82
|
+
"pyo3-build-config",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "pyo3-macros"
|
|
87
|
+
version = "0.29.3"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"proc-macro2",
|
|
92
|
+
"pyo3-macros-backend",
|
|
93
|
+
"quote",
|
|
94
|
+
"syn",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[[package]]
|
|
98
|
+
name = "pyo3-macros-backend"
|
|
99
|
+
version = "0.29.3"
|
|
100
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
101
|
+
checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
|
|
102
|
+
dependencies = [
|
|
103
|
+
"heck",
|
|
104
|
+
"proc-macro2",
|
|
105
|
+
"quote",
|
|
106
|
+
"syn",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "quick-xml"
|
|
111
|
+
version = "0.42.0"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"memchr",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "quote"
|
|
120
|
+
version = "1.0.47"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"proc-macro2",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "syn"
|
|
129
|
+
version = "2.0.119"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
132
|
+
dependencies = [
|
|
133
|
+
"proc-macro2",
|
|
134
|
+
"quote",
|
|
135
|
+
"unicode-ident",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "target-lexicon"
|
|
140
|
+
version = "0.13.5"
|
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
142
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
143
|
+
|
|
144
|
+
[[package]]
|
|
145
|
+
name = "unicode-ident"
|
|
146
|
+
version = "1.0.26"
|
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
148
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
docxium-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "docxium"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
description = "Batch operations for python-docx implemented in Rust"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[lib]
|
|
10
|
+
name = "_core"
|
|
11
|
+
crate-type = ["cdylib"]
|
|
12
|
+
|
|
13
|
+
[dependencies]
|
|
14
|
+
pyo3 = { version = "0.29.3", features = ["abi3-py39"] }
|
|
15
|
+
quick-xml = "0.42.0"
|
|
16
|
+
|
|
17
|
+
[profile.release]
|
|
18
|
+
lto = true
|
|
19
|
+
codegen-units = 1
|
docxium-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CMOS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
docxium-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: docxium
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Requires-Dist: python-docx>=1.2,<2
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Summary: python-docx extended with batch operations implemented in Rust
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
10
|
+
|
|
11
|
+
<a id="readme-top"></a>
|
|
12
|
+
|
|
13
|
+
<!-- PROJECT HEADER -->
|
|
14
|
+
<br />
|
|
15
|
+
<div align="center">
|
|
16
|
+
<h3 align="center">docxium</h3>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
python-docx extended with batch operations implemented in Rust.
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
[![MIT License][license-shield]][license-url] [![Rust][Rust-badge]][Rust-url] [![Python][Python-badge]][Python-url]
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<a href="https://cmostw.github.io/docxium/"><strong>Documentation »</strong></a>
|
|
26
|
+
·
|
|
27
|
+
<a href="#benchmarks">Benchmarks</a>
|
|
28
|
+
·
|
|
29
|
+
<a href="https://github.com/cmostw/docxium/issues/new?labels=bug">Report Bug</a>
|
|
30
|
+
·
|
|
31
|
+
<a href="https://github.com/cmostw/docxium/issues/new?labels=enhancement">Request Feature</a>
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<!-- TABLE OF CONTENTS -->
|
|
36
|
+
<details>
|
|
37
|
+
<summary>Table of Contents</summary>
|
|
38
|
+
<ol>
|
|
39
|
+
<li><a href="#about-the-project">About The Project</a></li>
|
|
40
|
+
<li><a href="#usage">Usage</a></li>
|
|
41
|
+
<li><a href="#benchmarks">Benchmarks</a></li>
|
|
42
|
+
<li><a href="#license">License</a></li>
|
|
43
|
+
</ol>
|
|
44
|
+
</details>
|
|
45
|
+
|
|
46
|
+
<!-- ABOUT THE PROJECT -->
|
|
47
|
+
## About The Project
|
|
48
|
+
|
|
49
|
+
[python-docx](https://github.com/python-openxml/python-docx) adds content to a document one call
|
|
50
|
+
at a time. With 50,000 paragraphs of three runs each, building the document takes 39.5 s and
|
|
51
|
+
reading all paragraph text back takes 3.5 s (see [Benchmarks](#benchmarks)).
|
|
52
|
+
|
|
53
|
+
docxium keeps python-docx as the document model and adds batch methods. A batch method receives a
|
|
54
|
+
whole list of paragraphs or table rows in one call. Rust generates the WordprocessingML for the
|
|
55
|
+
list, and python-docx's own parser inserts it into the document, so the result is an ordinary
|
|
56
|
+
python-docx `Document`.
|
|
57
|
+
|
|
58
|
+
* `import docxium as docx` exposes the batch methods. Names and submodules that docxium does not
|
|
59
|
+
define (`docxium.shared`, `docxium.enum.text`, ...) are forwarded to python-docx.
|
|
60
|
+
* Methods that python-docx already provides are python-docx's and are not changed.
|
|
61
|
+
* Opening and saving are performed by python-docx and are not changed.
|
|
62
|
+
|
|
63
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
64
|
+
|
|
65
|
+
<!-- USAGE EXAMPLES -->
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
Everything python-docx provides is used as python-docx documents it. Only the additions below
|
|
69
|
+
are specific to docxium. They are available on the document returned by `docxium.Document()`,
|
|
70
|
+
or on an existing `docx.Document` after `docxium.accelerate(doc)`.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import docxium as docx
|
|
74
|
+
|
|
75
|
+
doc = docx.Document()
|
|
76
|
+
doc.add_headings(["Introduction", "Methods"], level=1, alignment="center")
|
|
77
|
+
doc.add_paragraphs(
|
|
78
|
+
[
|
|
79
|
+
"plain",
|
|
80
|
+
["mixed ", ("bold", True, None), ("red", {"size": 18, "color": "FF0000"})],
|
|
81
|
+
],
|
|
82
|
+
alignment="justify",
|
|
83
|
+
)
|
|
84
|
+
doc.add_table_from_rows(rows, header=True, col_widths=[docx.shared.Inches(1)] * 3)
|
|
85
|
+
texts = doc.extract_paragraph_texts()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| method | behavior |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `add_paragraphs(paragraphs, style=None, alignment=None)` | Appends one paragraph per item. `style` is a style name or object; `alignment` is a `WD_ALIGN_PARAGRAPH` member or its name; both apply to every item. Equivalent to `add_paragraph` and `add_run` calls. |
|
|
91
|
+
| `add_headings(texts, level=1, alignment=None)` | Same as `add_paragraphs` with the `Title` style for level 0 and `Heading N` for levels 1-9, as `add_heading` selects. |
|
|
92
|
+
| `add_table_from_rows(rows, style=None, *, header=False, col_widths=None)` | Appends a table and returns it. Cells that are not `str` are converted with `str()`. `header=True` writes the first row in bold. `col_widths` holds one width per column (a `docx.shared.Length` or an EMU integer); without it the text width is divided evenly, as `add_table` does. |
|
|
93
|
+
| `extract_paragraph_texts()` | Returns the text of every paragraph in document order, including paragraphs inside tables. `Document.paragraphs` lists body-level paragraphs only. |
|
|
94
|
+
|
|
95
|
+
A paragraph is a `str` or an iterable of runs. A run is a `str`, `(text, bold, italic)`, or
|
|
96
|
+
`(text, {...})` where the dict may contain:
|
|
97
|
+
|
|
98
|
+
| key | value |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `bold`, `italic`, `underline`, `strike`, `all_caps`, `small_caps` | bool |
|
|
101
|
+
| `superscript`, `subscript` | bool (not both) |
|
|
102
|
+
| `size` | points, e.g. `10.5` |
|
|
103
|
+
| `color` | `"RRGGBB"` (a leading `#` is accepted) |
|
|
104
|
+
| `font` | font name |
|
|
105
|
+
| `highlight` | color name (`"yellow"`, `"darkBlue"`, `"dark_blue"`) or a `WD_COLOR_INDEX` member |
|
|
106
|
+
|
|
107
|
+
Invalid input raises `TypeError` or `ValueError`.
|
|
108
|
+
|
|
109
|
+
The written XML equals python-docx's for the equivalent calls, with one difference: an empty table
|
|
110
|
+
cell is written as `<w:p/>`, while python-docx writes `<w:p><w:r/></w:p>`.
|
|
111
|
+
|
|
112
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
113
|
+
|
|
114
|
+
<!-- BENCHMARKS -->
|
|
115
|
+
## Benchmarks
|
|
116
|
+
|
|
117
|
+
Speed-up is the python-docx time divided by the docxium time. Each workload runs on one thread;
|
|
118
|
+
the value reported is the median of 7 rounds.
|
|
119
|
+
|
|
120
|
+
* **Workloads:** paragraphs of three runs each (one plain, one bold, one italic), and tables of
|
|
121
|
+
five columns.
|
|
122
|
+
* **Build** creates the document from in-memory data, including the time to prepare that data.
|
|
123
|
+
* **Extract text** reads the text of all paragraphs.
|
|
124
|
+
* **Total** is build + save + open + extract.
|
|
125
|
+
|
|
126
|
+
<p align="center">
|
|
127
|
+
<picture>
|
|
128
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/_static/benchmarks-dark.svg">
|
|
129
|
+
<img alt="Bar charts of the docxium speed-up over python-docx for build, text extraction and total, with the measured times beside each bar." src="docs/_static/benchmarks-light.svg" width="880">
|
|
130
|
+
</picture>
|
|
131
|
+
</p>
|
|
132
|
+
|
|
133
|
+
Save and open are performed by python-docx in both cases; their ratios lie between 0.93× and
|
|
134
|
+
1.05×. Timings for every phase are listed in [docs/benchmarks.rst](docs/benchmarks.rst).
|
|
135
|
+
|
|
136
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
137
|
+
|
|
138
|
+
<!-- LICENSE -->
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
Distributed under the MIT License. See [`LICENSE`](LICENSE) for more information. docxium
|
|
142
|
+
depends on python-docx, which is also MIT licensed.
|
|
143
|
+
|
|
144
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
145
|
+
|
|
146
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
|
147
|
+
[license-shield]: https://img.shields.io/github/license/cmostw/docxium.svg?style=for-the-badge
|
|
148
|
+
[license-url]: https://github.com/cmostw/docxium/blob/master/LICENSE
|
|
149
|
+
[Rust-badge]: https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white
|
|
150
|
+
[Rust-url]: https://www.rust-lang.org/
|
|
151
|
+
[Python-badge]: https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white
|
|
152
|
+
[Python-url]: https://www.python.org/
|
|
153
|
+
|