diff --git a/.gitignore b/.gitignore index 8053e201..7f430ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -136,14 +136,12 @@ cython_debug/ # Hide PyPI token .pypitoken -#pretext-core -pretext/core/pretext.py -pretext/core/braille_format.py -pretext/core/common.py -pretext/core/stack.py -pretext/core/webwork.py +#pretext-core: almost everything... +pretext/core/* +# ... but not the __init__.py file +!pretext/core/__init__.py tests/examples/core -#zipped resources +#zipped resourcescd pretext/resources/*.zip #xml resources (rs_file) pretext/resources/*.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index fcaec6cb..ca0dcebe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change ## [Unreleased] +### Fixed + +- SCORM with assessment tracking now works with Blackboard. + +### Added + +- Improvements to the Braille output format. +- Improvements to the EPUB output format. +- Improvements to the Jupyter notebook output format. +- Upgrade to latest release of revealjs for slideshow targets. Includes support of single-file, offline slideshows and other slideshow improvements. +- Improvements to Fill-In-The-Blank questions. +- Asymptote support for offscreen rendering of images. +- Hypothesis.is support via publication file setting. + + ## [2.44.0] - 2026-07-08 Includes updates to core through commit: [07c8b5c](https://github.com/PreTeXtBook/pretext/commit/07c8b5c9a9a55e95ec27073e88bd5c9c61b9c161) diff --git a/docs/api.md b/docs/api.md index 330afd06..9976103e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,12 +1,49 @@ -# Using PreTeXt as a library +# Using pretext-cli as a Python library -The PreTeXt-CLI includes `Project` and `Target` classes which can be used when this package is imported as a library. +The `pretext-cli` package can be used directly from Python, without spawning +CLI subprocesses. -More details are coming soon. +The two main entry points are: + +- `Project.parse(...)`: load an existing `project.ptx` manifest. +- `Project(...)` + `new_target(...)`: build projects programmatically when no + manifest exists. + +## Quick start + +```python +from pathlib import Path +from pretext import project as pr + +# Case 1: You already have project.ptx +project = pr.Project.parse(Path(".")) +project.get_target("web").build() + +# Case 2: No project.ptx (for example, core/examples/epub) +project = pr.Project(ptx_version="2", source=Path(""), publication=Path("")) +target = project.new_target( + "ebook", + "epub", + source=Path("epub-sampler.xml"), + publication=Path("publication.xml"), +) +target.build() +``` + +## Why set `source` and `publication` to `Path("")`? + +`Project` prepends its own base paths to each target's `source` and +`publication` paths. + +- Default `Project.source` is `source/`. +- Default `Project.publication` is `publication/`. + +When your files live directly in the project root (as in the core EPUB +example), setting both to `Path("")` makes target paths resolve from that root. ## Logging -This package uses python's logging library and implements a logger with name `"ptxlogger"`. To get the same messages as the CLI gives (with default level of `INFO`), you can include the following. +To mirror CLI-style log output in library usage: ```python import logging @@ -17,12 +54,15 @@ logger.add_log_stream_handler() log.setLevel(logging.INFO) ``` -The `logger.add_log_stream_handler()` function simply creates a stream-handler that outputs to stdout. You could set up `log` however you like using the options provided by the `logging` library. If you would like to get spit out the logs to a file as the CLI does, you could include the line +To also log to files: ```python logger.add_log_file_handler(path_to_log_directory) ``` -## Report pretext version +## Version reporting + +If you want the running CLI version in your app logs, either: -If you want to include the current running version of PreTeXt in your app, you can call `utils.report_version` to get a info-level log report of the version, or import `VERSION` from the base of the project and use that in your own log message. +- call `utils.report_version()` for the built-in message, or +- import `VERSION` and log it yourself. diff --git a/pretext/__init__.py b/pretext/__init__.py index 4155f300..ff185d3e 100644 --- a/pretext/__init__.py +++ b/pretext/__init__.py @@ -18,7 +18,7 @@ VERSION = get_version("pretext", Path(__file__).parent.parent) -CORE_COMMIT = "c605c6f4f7fc5e3afc377372a952dd40c902dc2b" +CORE_COMMIT = "eec74773ac46acb74bb423b7b216d64b2416ee27" def activate() -> None: diff --git a/tests/test_project.py b/tests/test_project.py index c7c34ede..08961ca0 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -618,12 +618,17 @@ def test_latex_build(tmp_path: Path) -> None: def test_epub_build(tmp_path: Path) -> None: """An epub-format target builds a single .epub file.""" prj_path = tmp_path / "simple" - shutil.copytree(EXAMPLES_DIR / "projects" / "project_refactor" / "simple", prj_path) + shutil.copytree(EXAMPLES_DIR / "core" / "examples" / "epub", prj_path) with utils.working_directory(prj_path): - project = pr.Project.parse() - target = project.new_target("ebook", "epub") + project = pr.Project(ptx_version="2", source=Path(""), publication=Path("")) + target = project.new_target( + "ebook", + "epub", + source=Path("epub-sampler.xml"), + publication=Path("publication.xml"), + ) target.build() - assert (prj_path / "output" / "ebook" / "main.epub").exists() + assert (prj_path / "output" / "ebook" / "epub-sampler.epub").exists() @pytest.mark.skipif(