Skip to main content

Sphinx extension that injects the canonical BrainX brand header into any docs site, fetched live from brainx.chaobrain.com.

Project description

brainx-sphinx-header

Sphinx extension that injects the canonical BrainX brand header 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
# or, before publishing:
pip install "git+https://github.com/chaobrain/brainx.chaobrain.com.git#subdirectory=sphinx-ext"

Use

In your docs/conf.py:

extensions = [
    # ...
    "brainx_sphinx_header",
]

That's it. On the next build, the BrainX header is 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.

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 and header.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.
  • 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.

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.1.0.tar.gz (5.4 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.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: brainx_sphinx_header-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 a0ad848099a4b537802267c1fa551f6b7fad67234e65deb61d73a6878bef7bf0
MD5 87ab628bcde029dc591cfb1aeb1a9f4d
BLAKE2b-256 febc72463ddcb50e0d918d4121deaf0e373faac315ec0da5067f7b07b1eb2cc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for brainx_sphinx_header-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 091dd70f4455b1c8c1d204c12f9ae09fbe1b9a13abdedbc4e29f1bf9c4e2c937
MD5 9bebdbc500057f46da2a30d27d43b6e2
BLAKE2b-256 4ee8fab87aeeb18c22db11af5174d5d90d4f8faf949c9246e1251b4c43837878

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