Sphinx extension that injects the canonical BrainX brand header and footer into any docs site, fetched live from brainx.chaobrain.com.
Project description
brainx-sphinx-header
Sphinx extension that injects the canonical BrainX brand header and footer into any docs site, fetched live from the landing site so every package's docs stays in visual sync.
Install
pip install brainx-sphinx-header
Use
In your docs/conf.py:
extensions = [
# ...
"brainx_sphinx_header",
]
That's it. On the next build, the BrainX header and footer are fetched from https://brainx.chaobrain.com/shared-header, cached at <docs>/_brand/, and emitted as _static/css/brainx-header.css + _static/js/brainx-header.js (plus the matching brainx-footer.{css,js}).
Configuration (optional)
All settings have sensible defaults. Override in conf.py only if you need to.
| Setting | Default | Purpose |
|---|---|---|
brainx_header_url |
"https://brainx.chaobrain.com/shared-header" |
Where to fetch the canonical header |
brainx_header_ttl |
3600 |
Cache TTL in seconds |
brainx_header_offline |
False |
Use cache only, never fetch |
brainx_header_local |
None |
Path to a local shared-header dir for live preview |
brainx_inject_base |
True |
Inject <base href="{html_baseurl}"> into the docs index so the site works at both /<pkg> and /<pkg>/ (no-op if html_baseurl is unset) |
Each setting also honors an environment variable (BRAINX_HEADER_URL, BRAINX_HEADER_TTL, BRAINX_HEADER_OFFLINE=1, BRAINX_HEADER_LOCAL) which takes precedence — handy for CI.
What it does
- Fetches
header.html,header.css,header.js,footer.html,footer.cssfrom the BrainX landing site (with TTL cache + stale fallback). - Emits them as Sphinx static assets and registers them via
add_css_file/add_js_file. - Header: appends CSS overrides that hide
sphinx_book_theme/pydata_sphinx_themenative top bars (header.bd-header,.bd-header-article,.header-article-items.header-article__inner); wires the BrainX header's burger and theme button to the theme's hidden originals (.primary-toggle,.theme-switch-button) so sidebar toggle and theme cycling keep working — no template overrides needed. - Footer: appends below the theme's native footer. No theme overrides — the BrainX footer coexists with the theme footer rather than replacing it. The build year is baked into the markup at extension-emit time.
- Slash-tolerant index: injects
<base href="{html_baseurl}">into the docs index page, so the site renders correctly whether reached viahttps://host/<pkg>orhttps://host/<pkg>/. Sub-pages already resolve correctly via their own real paths and are not touched. Pair with an exact-match nginx block (location = /<pkg> { alias .../current/index.html; default_type text/html; }) to actually serve the no-slash URL without a redirect. Disable viabrainx_inject_base = Falseif you want the historical 301-redirect behavior.
Local development
To preview a header change against your local landing-site build before pushing:
BRAINX_HEADER_LOCAL=/path/to/brainx.chaobrain.com/dist/shared-header sphinx-build -b html docs docs/_build/html
Supported themes
sphinx_book_theme, pydata_sphinx_theme (the bd-* selector family). Other themes will still render the BrainX header but without button delegation; their native header is unaffected.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brainx_sphinx_header-0.4.0.tar.gz.
File metadata
- Download URL: brainx_sphinx_header-0.4.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c1185a48067ee4088f4f093cc72f94b00df837eccde492f71634f0426ed2066
|
|
| MD5 |
55429d389f591e7daefa3250441b91cb
|
|
| BLAKE2b-256 |
b6671f0732fcc2d68dc24d579ab15d228ae8bed277e2ca0eb9aeaf6e9ffd4c9c
|
File details
Details for the file brainx_sphinx_header-0.4.0-py3-none-any.whl.
File metadata
- Download URL: brainx_sphinx_header-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d826bb82cc25bc36e1d73e00b6d14b70c41b328aeea7dda4e050ee31e326e76
|
|
| MD5 |
46c7423728a56323a4c0d365d89beb23
|
|
| BLAKE2b-256 |
2708112d8fcfba60f2b6d314982564a766a827333c86971ef3320742875fe5a0
|