Skip to main content

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

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.css from 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_theme native 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.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brainx_sphinx_header-0.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file brainx_sphinx_header-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for brainx_sphinx_header-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50fbf5dd16104699f3b2f6e0371d421e37df108a7f9e59954acca8b6bde38f40
MD5 5a59431c257abc9ec419afe1a595c407
BLAKE2b-256 306d63fde2e9ccfe4a2957577e7c4a38ebe48e0f28e25877a25d4eabc4029764

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page