Metadata-Version: 2.4
Name: doxtr-html-theme-core
Version: 0.5.1
Summary: Core accessible Sphinx HTML theme powered by doxtr-theme-core and modern web standards.
Author: Jens Frey
Project-URL: Homepage, https://github.com/doxtr/doxtr-html-theme-core
Project-URL: Repository, https://github.com/doxtr/doxtr-html-theme-core
Project-URL: Issues, https://github.com/doxtr/doxtr-html-theme-core/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: Sphinx :: Extension
Classifier: Framework :: Sphinx :: Theme
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Documentation :: Sphinx
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: doxtr-theme-core>=0.5.2
Requires-Dist: Sphinx>=7.0
Requires-Dist: Pillow>=10.0
Dynamic: license-file

# doxtr-html-theme-core

Base Sphinx HTML theme (`doxtr_core` / `doxtr_html_theme_core`) built on `doxtr-theme-core` with semantic design tokens (`--dd-*`), `light-dark()` + persistent color-scheme toggle, WCAG AA contrast guardrails, native `<dialog>` mobile drawer, CSS Anchor/Scrollspy TOC, copy-code commands, and cross-builder `.. stylebox::` styling.

## Installation

```bash
pip install doxtr-html-theme-core
```

## Loading the Theme

Just like `pydata_sphinx_theme`, no `extensions` entry is needed for HTML builds:

```python
# conf.py
html_theme = "doxtr_core"  # or "doxtr_html_theme_core"
```

You can also list `"doxtr_html_theme_core"` in `extensions` explicitly or let `doxtr-theme-core` / `doxtr-theme-aubergine` orchestrate it for multi-format builds.

## Mixing & Matching per Format

Combine `doxtr_core` HTML with another PDF or EPUB theme (for example `doxtr_pdf_theme_aubergine`):

```python
extensions = ["doxtr_pdf_theme_aubergine"]
html_theme = "doxtr_core"
```

If another HTML theme (`html_theme = "pydata_sphinx_theme"`) is active alongside `doxtr_theme_*`, `doxtr-html-theme-core` leaves the active HTML theme untouched.

## Sharing One Color Theme Across Layouts

Pair `doxtr_core` HTML with a brand palette or custom `doxtr_semantic_palette` so HTML, PDF, and EPUB share identical colors even when using different layouts:

```python
extensions = ["doxtr_theme_aubergine"]  # provides Aubergine palette & PDF theme
html_theme = "doxtr_core"               # keep Core HTML layout in Aubergine colors
```

Or configure your own palette via `doxtr_semantic_palette`:

```python
extensions = ["doxtr_pdf_theme_aubergine"]
html_theme = "doxtr_core"
doxtr_semantic_palette = {
    "primary": "#0F4C81",
    "secondary": "#1D4ED8",
    "accent": "#EA580C",
    "dark": {"primary": "#93C5FD", "page": "#0F172A"},
}
```

## Theme Authoring Guidance

When building a child HTML theme (inheriting `doxtr_core`) or a brand `ThemeSpec` (via `doxtr-theme-core`):

### 1. Header Brand Title (`html_title` / `project`)

The top-left header link and mobile drawer title represent the **documentation project**, not the theme itself. By default, `doxtr-html-theme-core` resolves the header title in this order:

1. User `html_theme_options["short_name"]` or `doxtr_branding["short_name"]`
2. User `html_short_title` in `conf.py`
3. User `html_theme_options["brand_name"]`
4. User `html_title` in `conf.py` (falls back to `project`, then the root document title)

- **Never** set `short_name` or `brand_name` in `ThemeSpec.html_options` or in a child theme's `theme.conf`.
- **Never** hardcode the theme's name in `header.html` or `drawer.html` — always render `{{ (doxtr_header_title or theme_brand_name or shorttitle)|e }}`.
- Put default brand logos (`logo_light`, `logo_dark`, `favicon`) on `BrandConfig` rather than `ThemeSpec.html_options` so `conf.py`'s `html_logo` continues to take precedence.

### 2. Announcement Banner Option (`announcement_banner`)

Every Doxtr HTML theme must expose `announcement_banner` and leave it **empty (`""`) by default** so end users (via `conf.py`) and staging/review tooling (such as `doxtr test` via `-D html_theme_options.announcement_banner=...`) can display a top-of-page notice consistently across every theme:

1. **Declare and inherit**: Inheriting `doxtr_core` automatically registers `announcement_banner =` in `theme.conf`, renders `{% block announcement %}` inside `layout.html` (`<div class="doxtr-announcement" role="region" aria-label="Announcement"><div class="doxtr-announcement-inner">{{ theme_announcement_banner }}</div></div>`), and includes base `@layer theme` CSS in `doxtr-core.css`.
2. **Preserve `block announcement` if overriding `block header`**: In any child `layout.html` that overrides `{% block header %}`, call `{{ self.announcement() }}` (or render the same `.doxtr-announcement` markup when `theme_announcement_banner` is truthy) directly above `.doxtr-skip-link`.
3. **Style with semantic tokens in `@layer theme`**: Customize `.doxtr-announcement` inside `@layer theme` using WCAG-checked `--dd-*` tokens (e.g. `var(--dd-primary)` and `var(--dd-on-primary, var(--dd-bg))`).
4. **Leave empty by default**: Keep `announcement_banner =` empty in `theme.conf`, and either omit `announcement_banner` or set `"announcement_banner": ""` in `ThemeSpec.html_options`. **Never** pre-fill `announcement_banner` (or add a custom top bar) with a description of the theme, color scheme, or layout — users can already derive that from looking at the rendered page.
5. **Test both states**: Verify default builds render no `.doxtr-announcement` banner and both `html_theme_options = {"announcement_banner": "..."}` and `-D html_theme_options.announcement_banner=...` render it cleanly.

### Option Ownership Summary

| Option | Owner | Notes |
| --- | --- | --- |
| `html_title`, `project`, `html_short_title` | User `conf.py` | Drives top-left header & drawer title |
| `short_name`, `brand_name` | User `conf.py` (`html_theme_options`) | Must remain empty in `theme.conf` & omitted from `ThemeSpec.html_options` |
| `announcement_banner` | Exposed empty by all HTML themes; populated by User `conf.py` / `doxtr test` | Must be supported in all HTML themes, remain `""` by default in `theme.conf` & `ThemeSpec.html_options`, and never describe the theme/layout |
| `logo_light`, `logo_dark`, `favicon` | `BrandConfig` (overridable by user `html_logo` / `html_theme_options`) | Theme default artwork |
| `show_toc`, `show_nav`, `color_scheme_toggle`, etc. | `ThemeSpec.html_options` / `theme.conf` | Theme defaults overridable by user |

`doxtr-html-theme-core` also enforces these rules programmatically at build time via `THEME_SPEC_FORBIDDEN_HTML_OPTIONS` and exposes the guidance string via `HTML_THEME_AUTHOR_GUIDANCE` / `get_html_theme_author_guidance()`.

## Preview

Rendered from [doxamples](https://github.com/doxtr/doxamples).

| Light Mode | Dark Mode |
| --- | --- |
| ![Core HTML Light](previews/doxamples-html-core-light.png) | ![Core HTML Dark](previews/doxamples-html-core-dark.png) |

