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 Distribution

brainx_sphinx_header-0.3.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

brainx_sphinx_header-0.3.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file brainx_sphinx_header-0.3.0.tar.gz.

File metadata

  • Download URL: brainx_sphinx_header-0.3.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for brainx_sphinx_header-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6a1414eab3ed6a3cc4adcf3afa0255f957d70966adbf169e6cbd05445b74f0d0
MD5 134013ce74f65000eabf956662dc5420
BLAKE2b-256 589b50c3fa2086b82e732487892b759d2f8296f916288e2fcb06bd7ab310dfe5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for brainx_sphinx_header-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60762a8006f5f28629ed651700a89f0be1f1ac0fb003d8b768c98671bba7fdeb
MD5 d6f0bd0b137c8618c60691c74ce877e7
BLAKE2b-256 2e85aa4fe9162071b7e8646e6d600e201ad0cbeebc7f1b8928960f2ebe10815f

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