Skip to content

Commit fb37ca2

Browse files
committed
fix: add Sphinx builder docwriter shim for ablog compatibility
1 parent 4eb07e4 commit fb37ca2

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/scripts/strip_outputs.py

100755100644
File mode changed.

.github/workflows/deploy-docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ jobs:
2727
build:
2828
runs-on: ubuntu-latest
2929
env:
30-
# Enable notebook execution on CI by default for push and schedule events.
31-
# Also allow manual override via workflow_dispatch input `run_notebooks`.
32-
UCLCHEM_EXECUTE_NOTEBOOKS: ${{ (github.event_name == 'push') || (github.event_name == 'schedule') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_notebooks == 'true') }}
30+
# Temporarily DISABLE notebook execution by default to shorten build time.
31+
# Notebooks can still be executed manually via workflow_dispatch + input `run_notebooks: true`.
32+
# To re-enable automatic execution on push/schedule, revert this change.
33+
UCLCHEM_EXECUTE_NOTEBOOKS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.run_notebooks == 'true' }}
3334

3435
steps:
3536
- name: Checkout documentation repository

conf.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,27 @@
225225
blog_authors = {
226226
"UCLCHEM Team": ("UCLCHEM Team", "https://uclchem.github.io"),
227227
}
228+
229+
# ---------------------------------------------------------------------------
230+
# Compatibility shim: ensure Sphinx builder provides a docwriter attribute
231+
# This addresses incompatibilities where extensions (e.g. ablog) expect the
232+
# builder to have a `docwriter` writer object. We attach an HTMLWriter on
233+
# `builder-inited` if it is missing to avoid AttributeError during rendering.
234+
# ---------------------------------------------------------------------------
235+
def _ensure_docwriter(app):
236+
try:
237+
from sphinx.writers.html import HTMLWriter
238+
if not hasattr(app.builder, "docwriter"):
239+
app.builder.docwriter = HTMLWriter(app.builder)
240+
app.logger.debug("Attached HTMLWriter to app.builder for ablog compatibility")
241+
except Exception as exc:
242+
# Use logger to surface the issue in build logs without failing the build
243+
try:
244+
app.logger.warning(f"Could not attach HTMLWriter to builder: {exc}")
245+
except Exception:
246+
pass
247+
248+
249+
def setup(app):
250+
app.connect("builder-inited", _ensure_docwriter)
251+
return {"version": "0.1"}

0 commit comments

Comments
 (0)