Skip to main content

Sphinx directives and Web Components for interactive textbook content.

Project description

sphinx-touchbook

PyPI Tests Author Guide License

sphinx-touchbook is a Sphinx extension project for authors who want interactive textbook pages without giving up ordinary Sphinx documents. Authors write semantic reStructuredText directives, Sphinx parses them into docutils nodes, Python generators render builder-specific output, and JavaScript components progressively enhance the generated HTML.

This project is inspired by Runestone Interactive, which pioneered interactive textbook components for computer science education. sphinx-touchbook is a Sphinx-oriented port of that general idea: it keeps authoring and builds inside Sphinx while Runestone's main project has moved away from Sphinx-based authoring and toward PreTeXt-authored books.

The focus of this project is 'Sphinx-native' interactive books and nothing else. Runestone is a much more sophisticated environment with instructor resources, student tracking, and LMS integration. If you want those features then you should consider Runestone as a resource.

Setup

To build documents Python is required.

Create and activate a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Install the Python package with test, documentation build and publish to pypi dependencies:

python3 -m pip install --upgrade pip
python3 -m pip install -e '.[test,docs,publish]'

To test documents Node.js with npm is required.

Install JavaScript test dependencies:

npm ci

Build Documents

Build the author guide as HTML:

python3 -m sphinx -b html docs build/authorguide --fail-on-warning

The generated site starts at:

build/authorguide/index.html

To build LaTeX or PDF requires either a local LaTeX installation compatible with Sphinx, or a docker image:

Build LaTeX source locally:

python3 -m sphinx -b latex docs build/latex --fail-on-warning

Build the author guide PDF with the Sphinx LaTeX container:

docker run --rm \
  -v "$PWD:/docs" \
  -w /docs \
  sphinxdoc/sphinx-latexpdf:latest \
  sh -c 'python3 -m pip install ".[docs]" && python -m sphinx -M latexpdf docs build/latexpdf --fail-on-warning'

See the author guide in docs/ for directive syntax, options, examples, accessibility notes, and fallback behavior.

Run Tests

Run the Python directive and generator tests:

python3 -m pytest tests/test_*.py

Run isolated JavaScript component tests:

npm run test:web-components

Build install package

  python3 -m build
  python3 -m twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_touchbook-0.1.1.tar.gz (6.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_touchbook-0.1.1-py3-none-any.whl (6.5 MB view details)

Uploaded Python 3

File details

Details for the file sphinx_touchbook-0.1.1.tar.gz.

File metadata

  • Download URL: sphinx_touchbook-0.1.1.tar.gz
  • Upload date:
  • Size: 6.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for sphinx_touchbook-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7cf33d3f66f37db027b2ec1022d4b02cc15c87162ca705ccca24d2b963fdd340
MD5 5fb78fe837f32e1fa36a109e4a7a7daf
BLAKE2b-256 5c2720882f766fdb63c84a3aa84afe974e24145e117866009c8ca60851097db0

See more details on using hashes here.

File details

Details for the file sphinx_touchbook-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_touchbook-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cee2e52c151a67822098e8ceb4450eda7a6191f63137d08fa324c65039a0512f
MD5 f8d3ae25811612a309d68c20c4a38ba3
BLAKE2b-256 0f0406ebc8ac80b35fe0587b370f1bf42e93509b2e4a7534c6c3a73efb5a1664

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page