Development¶
Set up¶
Dependency groups: test (pytest, pytest-cov), lint (ruff, ty) and ocr (docling).
Tests and checks¶
test.sh creates .venv with the test and lint groups if needed, installs the package in editable mode, and runs, in order:
pytest, with a coverage floor of 80% (--cov-fail-under=80).ruff check src tests.ty check src.
The tests build synthetic books in temporary folders and use a stub embedder, so they need no GGUF model, no converter and no chat server. The two OCR tests in tests/test_convert.py need docling importable; install the ocr group to run them.
Run a single file while working:
Comparison scripts¶
scripts/ holds the scripts used for the measurements in Embedding models:
uv run scripts/compare_lakoff.py BOOK 0 1.05 jina,gemma,granite # per-language yield, agreement, multi-way units
uv run scripts/compare_models.py BOOK 2000 # jina vs gemma on a slice, with sample disagreements
scripts/bake_pdf.py timed the PDF converters for the bake-off that chose markit.
Code layout¶
| module | role |
|---|---|
cli.py |
The Cli class that Fire turns into commands. |
config.py |
Dataclasses for paraltext.toml and the config file search. |
pipeline.py |
Book, the four stages and run_all. |
convert.py |
PDF, EPUB and DjVu to markdown. |
ocr.py |
docling OCR, run as a child process. |
normalize.py |
Chunking and the chat-completion client. |
segment.py |
Markdown clean-up and sentence splitting. |
embed.py |
Adapter to the uubed embedding engine. |
cache.py |
diskcache stores for normalized chunks and vectors. |
align.py |
Centring, margin mining, overlap resolution, order filter, gap filling. |
tmx.py |
TMX writer. |
Versions¶
The version comes from Git tags through hatch-vcs. A build writes src/vexy_paraltext/_version.py, which is ignored by Git. Without it, vexy_paraltext.__version__ is 0.0.0.dev0.
Build¶
./build.sh # documentation and package
./build.sh docs # documentation only: src_docs/md -> docs/
./build.sh package # package only: dist/*.whl and dist/*.tar.gz, checked with twine
The package build uses uv build --no-sources, so local editable source paths never leak into release metadata.
Documentation¶
ProperDocs builds src_docs/md/ into docs/ using fly-january 0.4.0 or later (remote theme assets) with chrome: none. GitHub Pages serves the result at https://vexy.dev/vexy-paraltext/.
src_docs/build.sh # strict build into docs/
src_docs/build.sh serve # live preview on http://127.0.0.1:8000
Do not edit docs/ by hand; the next build replaces it. The Docs workflow rebuilds docs/ and commits it on every push to main that changes src_docs/.
Release¶
Run ./test.sh and push the intended commit to the default branch. With an authenticated GitHub CLI, run ./publish.sh for the next patch or pass an explicit tag such as ./publish.sh v1.4.0.
The Release workflow creates the requested tag if needed, builds the wheel and source archive from it, and attaches both to the GitHub release. Its pypi job uploads those artifacts through PyPI Trusted Publishing. A version tag pushed directly also starts this workflow.
For a local preview, run uv run --no-project --script scripts/release.py --dry-run. The helper tests the working tree and builds tagged artifacts in a disposable copy. Release instructions