Skip to content

fix(docs): restore gp-sphinx FOWT prevention#527

Merged
tony merged 2 commits intomasterfrom
fix/theme-flicker-conf
May 3, 2026
Merged

fix(docs): restore gp-sphinx FOWT prevention#527
tony merged 2 commits intomasterfrom
fix/theme-flicker-conf

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented May 3, 2026

Restores the inline <script> that hides <body> until the resolved theme is applied — without it, the page renders with the default theme briefly before flipping to the user's preference, showing as a dark→light flash on light-theme loads.

Root cause

docs/conf.py defined def setup(app) after globals().update(conf). Python module-namespace order means the user's setup silently shadowed the one gp_sphinx.config.merge_sphinx_config() returns. With gp-sphinx's setup never running, four hooks the theme relies on never registered:

  • _inject_fowt_prevention head-injection (the visible flicker bug)
  • _inject_copybutton_bridge selector script
  • js/spa-nav.js SPA-navigation script
  • remove_tabs_js build-finished cleanup
  • myst / myst-md Pygments lexers

Fix

Mirror the chain pattern already in use at vcspull/docs/conf.py: pop conf["setup"] into _gp_setup before globals().update(conf), then call _gp_setup(app) as the first statement of the user's setup(app).

Verification

Local just build-docs produces a <head> containing both:

  • <style>html.gp-sphinx-theme-pending body:not([data-theme]){visibility:hidden}</style>
  • <script data-cfasync="false">(function(){var t=localStorage.getItem("theme")||"auto";...})()</script>

These were absent from the live site before this PR. Grep proof on the local build: gp-sphinx-theme-pending count goes from 02.

tony added 2 commits May 3, 2026 18:05
why: docs/conf.py defined `def setup(app)` AFTER
`globals().update(conf)`, which silently shadowed the `setup`
callback `gp_sphinx.config.merge_sphinx_config()` returns. With
gp-sphinx's setup never running, the inline `<script
data-cfasync="false">` that gates body paint until `data-theme` is
set was never injected — causing the dark→light flicker visible at
load time. Mirrors the pop+chain pattern at vcspull/docs/conf.py.

what:
- pop `conf["setup"]` into `_gp_setup` before `globals().update(conf)`
- call `_gp_setup(app)` as the first statement of the user's
  `setup(app)` so gp-sphinx's hooks register first

side effects (all previously silently disabled, now restored):
- `js/spa-nav.js` SPA-navigation script
- GP_SPHINX_COPYBUTTON_SELECTOR bridge for sphinx-copybutton
- `remove_tabs_js` build-finished cleanup
- `myst` / `myst-md` Pygments lexers
@tony tony force-pushed the fix/theme-flicker-conf branch from e49aaec to 8fb250d Compare May 3, 2026 23:07
@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.23%. Comparing base (ccde355) to head (8fb250d).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #527   +/-   ##
=======================================
  Coverage   58.23%   58.23%           
=======================================
  Files          40       40           
  Lines        6489     6489           
  Branches     1098     1098           
=======================================
  Hits         3779     3779           
  Misses       2177     2177           
  Partials      533      533           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony tony merged commit 580908e into master May 3, 2026
7 checks passed
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.

1 participant