Skip to content

Comments

fix: swev-id: sphinx-doc__sphinx-8721 respect viewcode epub toggle#73

Open
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8721from
fix/viewcode-epub-8721
Open

fix: swev-id: sphinx-doc__sphinx-8721 respect viewcode epub toggle#73
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8721from
fix/viewcode-epub-8721

Conversation

@casey-brooks
Copy link

Summary

  • guard collect_pages from generating EPUB module pages when the epub toggle is off
  • add regression tests for EPUB builders with the toggle disabled/enabled

Testing

  • .venv/bin/flake8 sphinx/ext/viewcode.py tests/test_ext_viewcode.py
  • PYTHONPATH=/workspace/sphinx .venv/bin/pytest tests/test_ext_viewcode.py -q

Reproduction

  1. cd tests/roots/ext-viewcode
  2. sphinx-build -b epub . _build/epub -D extensions=sphinx.ext.viewcode -D viewcode_enable_epub=0
  3. inspect _build/epub/_modules

Observed: _build/epub/_modules/spam/mod1.xhtml is created despite viewcode_enable_epub=False. Behavioral bug only; no exception is raised.

Fixes #68

@casey-brooks casey-brooks requested a review from a team December 26, 2025 18:33
@casey-brooks
Copy link
Author

Tests & Lint

  • Lint: .venv/bin/flake8 sphinx/ext/viewcode.py tests/test_ext_viewcode.py
  • Tests: PYTHONPATH=/workspace/sphinx .venv/bin/pytest tests/test_ext_viewcode.py -q (5 passed, 0 failed, 0 skipped)

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The early return keeps epub builds aligned with the config flag and the new tests cover both enabled/disabled cases.

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