Utilities for building a PreTeXt textbook workflow from mixed open-source inputs (CNXML and PreTeXt)
Project description
book-builder
book-builder is a CLI for building a PreTeXt textbook workspace from planning CSVs and open-source source books (CNXML + PreTeXt).
It is designed for a practical production flow:
- Generate a full
source/+reference/skeleton from curriculum metadata. - Export source TOCs to normalized CSVs.
- Populate
reference/with adapted content. - Run content enrich/audit workflows.
Quick entry (2-minute start)
Install:
pipx install book-builder
From your textbook project root (the folder that contains textbook_info/):
# 1) Generate source + reference structure
book-builder skeleton
# 2) Populate reference content from TOC/metadata
book-builder populate
# 3) Run typical content post-processing
book-builder content
See all commands:
book-builder --help
Project Structure for Users
When users install book-builder and use it, they'll work with this structure:
my-textbook-project/
├── textbook_info/
│ ├── template.ptx
│ ├── Book Structure.csv
│ ├── Open Textbooks.csv
│ ├── Automatic Links.csv
│ └── Learning Outcomes.csv
├── source/
│ ├── content.ptx
│ └── [chapter directories and sec-*.ptx files]
├── reference/
│ ├── content.ptx
│ └── [chapter directories and sec-*.ptx files]
├── reference_tocs/
│ ├── stax-toc.csv
│ ├── orcca-toc.csv
│ └── [other generated toc / id-map CSV files]
├── assets/
│ ├── lesson_plans/
│ └── [images/media copied during processing]
├── adapted-works/
│ └── [upstream CNXML or PreTeXt source repositories]
├── secret/
│ ├── credentials.json
│ ├── google_ids.json
│ └── token.pickle
└── [other project files]
All paths are resolved relative to your current working directory (Path.cwd()), not the package installation folder.
Required input files vs generated files
Required inputs (you provide)
These should exist before running the listed commands.
textbook_info/template.ptx- used by:
book-builder skeleton(forsource/section template)
- used by:
textbook_info/Book Structure.csv- used by:
book-builder skeleton,book-builder populate - automatically generate through
book-builder load-textbook-sheet
- used by:
textbook_info/Open Textbooks.csv- used by:
book-builder populate - automatically generate through
book-builder load-open-textbooks-sheet
- used by:
textbook_info/Automatic Links.csv- used by:
book-builder add-objectives,book-builder add-resources,book-builder generate-syllabus,book-builder generate-lo,book-builder syllabus-tables,book-builder validate-paths
- used by:
textbook_info/Learning Outcomes.csv- used by:
book-builder generate-lo,book-builder syllabus-tables - automatically generate through
book-builder load-textbook-sheet
- used by:
Optional but commonly needed:
adapted-works/...- used by:
book-builder stax-toc,book-builder pretext-toc, and then indirectly bypopulate
- used by:
secret/credentials.json(required for Google API auth)- used by:
book-builder pull-plans,book-builder validate-paths,book-builder audit
- used by:
secret/google_ids.json(sheet/folder IDs)- used by:
book-builder pull-plans,book-builder validate-paths,book-builder audit - This should have structure:
{ "grade" : {"grade_10": {"textbook_spreadsheet_id": "XXXX", "lesson_plans_folder_id": "XXXX" }, "grade_11": {"textbook_spreadsheet_id": "XXXX", "lesson_plans_folder_id": "XXXX" } }, "open_textbooks_spreadsheet_id": "XXXX" }- used by:
Generated files/directories (tool creates)
source/andreference/trees- generated by:
book-builder skeleton - includes
content.ptx, chapter folders, and section files - Important:
reference/is generated byskeleton
- generated by:
reference_tocs/*.csv- generated by:
book-builder stax-toc,book-builder pretext-toc
- generated by:
reference_tocs/*-id-mapping.csv- generated by:
book-builder pretext-toc(mapping output)
- generated by:
reference_tocs/stax-toc.enriched.csv- generated by:
book-builder populate(default CNXML/auto flow)
- generated by:
assets/lesson_plans/*- generated/downloaded by:
book-builder pull-plans
- generated/downloaded by:
textbook_info/orphaned_ptx,textbook_info/orphaned.ptx- generated by:
book-builder audit-questions
- generated by:
source/syllabus-alignment.ptx,source/lo-coverage-table.ptx- generated by:
book-builder generate-syllabus,book-builder generate-lo, orbook-builder syllabus-tables
- generated by:
secret/token.pickle- generated on first successful Google OAuth flow
Command map
Core workflow
book-builder skeleton- create empty
source/andreference/structures fromBook Structure.csv
- create empty
book-builder populate- match rows to TOC entries and inject adapted content into
reference/
- match rows to TOC entries and inject adapted content into
book-builder content- run common post-processing sequence:
add-objectivesadd-resourcesnamespacegenerate-syllabusgenerate-lo
- run common post-processing sequence:
TOC generation
book-builder stax-toc <resource_folder> <collection_name>- export CNXML collection structure to
reference_tocs/
- export CNXML collection structure to
book-builder pretext-toc <root>- export PreTeXt include tree to
reference_tocs/
- export PreTeXt include tree to
Content helpers
book-builder add-objectivesbook-builder add-resourcesbook-builder namespacebook-builder add-labelsbook-builder generate-syllabusbook-builder generate-lobook-builder syllabus-tables
Audits and Google sync
book-builder pull-plansbook-builder validate-pathsbook-builder audit-pdfsbook-builder audit-questionsbook-builder audit(runs pull + validate + pdf audit + question audit)
Typical end-to-end workflow
# 0) Inspect command options
book-builder --help
# 1) Build source/reference scaffold from curriculum plan
book-builder skeleton
# 2) Build TOCs from source repositories (examples)
book-builder stax-toc adapted-works/PREALG prealgebra-2e
book-builder pretext-toc adapted-works/ORCCA/src/orcca.ptx --resource-name ORCCA
# 3) Populate reference content
book-builder populate --source-format auto
# 4) Add objectives/resources/namespace/syllabus tables
book-builder content
# 5) Optional audits
book-builder audit-questions
book-builder audit-pdfs
Useful populate flags while testing:
--limit Nto process only firstNmatching rows--dry-runto run matching without writes--no-copy-imagesto skip image copy
Installation
From PyPI (recommended)
pipx install book-builder
Development install
git clone https://github.com/B28LH/book-builder.git
cd book-builder
pip install -e .[dev]
Requirements:
- Python 3.12+
Development
Common Make targets:
make run-checks # isort, black, ruff, mypy, pytest
make docs # local Sphinx autobuild
make build # package build artifacts
Documentation lives under docs/source.
Troubleshooting
- If commands cannot find
textbook_info/..., make sure you are running from your project root. - If Google commands fail auth, confirm both
secret/credentials.jsonandsecret/google_ids.jsonexist. secret/token.pickleis created automatically after OAuth; deleting it forces re-auth.- If
populatehas poor matches, verifyBook Structure.csv,Open Textbooks.csv, and TOC CSVs are aligned.
License
This project is licensed under the terms in LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file book_builder-0.1.0.tar.gz.
File metadata
- Download URL: book_builder-0.1.0.tar.gz
- Upload date:
- Size: 80.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70838d5adfb45ac09dd881adccbb0caf4732a0e35d9995a8646120ab0da9f2b1
|
|
| MD5 |
dccc86186c48e5bd365477a6bce4d0b1
|
|
| BLAKE2b-256 |
4f1175f18f105f751a956e0062b34c07778d26ed372dadd31263accaf9a272ef
|
Provenance
The following attestation bundles were made for book_builder-0.1.0.tar.gz:
Publisher:
publish.yml on B28LH/book-builder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
book_builder-0.1.0.tar.gz -
Subject digest:
70838d5adfb45ac09dd881adccbb0caf4732a0e35d9995a8646120ab0da9f2b1 - Sigstore transparency entry: 1147594096
- Sigstore integration time:
-
Permalink:
B28LH/book-builder@8a3bd4687d2e03dc3745421eba3d65f2f4ea4ece -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/B28LH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a3bd4687d2e03dc3745421eba3d65f2f4ea4ece -
Trigger Event:
push
-
Statement type:
File details
Details for the file book_builder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: book_builder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 91.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3a69e818ecaa626b60bbba55a2fd4f1a3aee66e4aab1084b8bbf26db039e37
|
|
| MD5 |
4a3a005064b8eba9ecebcf18bdd30e51
|
|
| BLAKE2b-256 |
fb5c0aa402bdee6dca78d9c17a84a21181406ca2caf18846a5f03518d1f1d079
|
Provenance
The following attestation bundles were made for book_builder-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on B28LH/book-builder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
book_builder-0.1.0-py3-none-any.whl -
Subject digest:
0a3a69e818ecaa626b60bbba55a2fd4f1a3aee66e4aab1084b8bbf26db039e37 - Sigstore transparency entry: 1147594173
- Sigstore integration time:
-
Permalink:
B28LH/book-builder@8a3bd4687d2e03dc3745421eba3d65f2f4ea4ece -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/B28LH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a3bd4687d2e03dc3745421eba3d65f2f4ea4ece -
Trigger Event:
push
-
Statement type: