Sphinx Serializing HTML Extension
sphinxcontrib-serializinghtml is a Sphinx extension that outputs "serialized" HTML files, specifically in JSON and Pickle formats. This enables external applications or custom post-processing tools to consume documentation content without needing to parse raw HTML. The library is currently at version 2.0.0 and follows a release cadence tied to Sphinx releases, with recent updates addressing dependency management and Python/Sphinx version compatibility.
Warnings
- breaking Python 3.5, 3.6, 3.7, and 3.8 support was dropped in version 1.1.6. Version 2.0.0 and later require Python >= 3.9.
- breaking The minimum required Sphinx version was raised to 5.0 in `sphinxcontrib-serializinghtml` version 1.1.6. Using older Sphinx versions with recent `sphinxcontrib-serializinghtml` releases will likely result in errors.
- gotcha Older versions (e.g., 1.1.1) of `sphinxcontrib-serializinghtml` experienced circular import issues if Sphinx was directly listed as a dependency, causing build failures. This was addressed in later 1.1.x versions, specifically version 1.1.10 removed Sphinx as a required direct dependency to prevent such conflicts.
- gotcha This extension provides special builders (`json` and `pickle`). To generate serialized output, you must explicitly use these builders (e.g., `make json` or `sphinx-build -b json`), not the default `html` builder. The output will be in `.fjson` and `.fpickle` files, not standard `.html`.
Install
-
pip install sphinxcontrib-serializinghtml
Imports
- sphinxcontrib.serializinghtml
# in conf.py extensions = [ 'sphinxcontrib.serializinghtml' ]
Quickstart
# 1. Create a Sphinx project (if you don't have one): # sphinx-quickstart # 2. In your conf.py file, add the extension: # extensions = [ # 'sphinxcontrib.serializinghtml' # ] # 3. Build the documentation to JSON or Pickle format: # From your project root (where Makefile or make.bat is located): # make json # or # make pickle # Alternatively, using sphinx-build directly: # sphinx-build -b json -d _build/doctrees . _build/json # sphinx-build -b pickle -d _build/doctrees . _build/pickle