Skip to content

Add option to generate PDFs alongside HTML builds in parallel#148

Open
jdillard wants to merge 22 commits into
useblocks:mainfrom
jdillard:parallel-build
Open

Add option to generate PDFs alongside HTML builds in parallel#148
jdillard wants to merge 22 commits into
useblocks:mainfrom
jdillard:parallel-build

Conversation

@jdillard

@jdillard jdillard commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

I thought it would be nice to be able to automatically have a PDF as part of your HTML build without having to do additional build configuration to make that possible. This change builds the PDF in parallel using a subprocess and copies it into the HTML output directory, to make the extension more plug an play.

Summary of changes

  • Adds simplepdf_parallel_build config option that, when set to True, spawns a concurrent sphinx-build -b simplepdf subprocess during any html based build (e.g. html, singlehtml, dirhtml)
    • Only the final PDF is copied into the output directory — all intermediate HTML artifacts are discarded
    • Inspired by the subprocess pattern used in NVIDIA/sphinx-llm
  • WeasyPrint is now imported only when simplepdf_use_weasyprint_api is used, so HTML-only builds no longer fail on extension load
  • Added tests

Usage

# conf.py
extensions = ["sphinx_simplepdf"]
simplepdf_parallel_build = True

Then make html produces both HTML and a PDF in the output directory.

AI Disclosure

I used Claude Code to assist with this PR, but checked it's output and made several modifications along the way.

Testing

Currently running in production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants