scverse-doc 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/CHANGELOG.md +21 -1
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/PKG-INFO +1 -1
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/biome.jsonc +1 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/pyproject.toml +1 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/scripts/sync_brand_tokens.py +30 -43
- scverse_doc-0.3.0/src/scverse_doc/_accents.json +25 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/autodoc/templates/autosummary/class.rst +5 -2
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/registry.py +12 -4
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/__init__.py +35 -14
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/static/_tokens.css +2 -2
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/static/styles/scverse.css +10 -2
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/theme.toml +12 -11
- scverse_doc-0.2.3/src/scverse_doc/_accents.json +0 -12
- scverse_doc-0.2.3/src/scverse_doc/_color.py +0 -146
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.codecov.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.cruft.json +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.editorconfig +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/dependabot.yml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/autofix.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/build.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/pr.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/release.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/sync.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.github/workflows/test.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.gitignore +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.pre-commit-config.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.readthedocs.yaml +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.vscode/extensions.json +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.vscode/launch.json +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/.vscode/settings.json +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/LICENSE +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/README.md +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/scripts/check_changelog.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/__init__.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/autodoc/__init__.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/autodoc/templates/autosummary/module.rst +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/config.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/napoleon.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/py.typed +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/release_notes.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/source.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/scverse-ecosystem.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/scverse-footer.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/scverse-sidebar-nav.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/sidebar-versions.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/toggle-primary-sidebar.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/toggle-secondary-sidebar.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/layout.html +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/static/scripts/readthedocs-integration.js +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/static/scverse-fa.svg +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/typed_fields.py +0 -0
- {scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/xref_overrides.py +0 -0
|
@@ -10,6 +10,24 @@ and this project adheres to [Semantic Versioning][].
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.3.0]
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `secondary_accent` theme option for the sidebar captions, which `True` sets to the package’s second brand colour from the website (#73)
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- package accent colors are synced from the scverse website’s `accents.json` (#74)
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- header shadow now only extends downward (#70)
|
|
26
|
+
- the autosummary class template now correctly handles classes referenced through aliased modules (#71)
|
|
27
|
+
- pertpy’s accent is its logo blue instead of scirpy’s pink (#72)
|
|
28
|
+
|
|
29
|
+
## [0.2.3]
|
|
30
|
+
|
|
13
31
|
### Added
|
|
14
32
|
|
|
15
33
|
- `scverse_doc.config.DEFAULTS` is now a class (#69)
|
|
@@ -52,7 +70,9 @@ and this project adheres to [Semantic Versioning][].
|
|
|
52
70
|
- Read the Docs integration: version selector and search, both with dark mode
|
|
53
71
|
- Autodoc, prose, and confval rendering extensions (from scverse-misc)
|
|
54
72
|
|
|
55
|
-
[Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.
|
|
73
|
+
[Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.3.0...main
|
|
74
|
+
[0.3.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.3.0
|
|
75
|
+
[0.2.3]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.3
|
|
56
76
|
[0.2.2]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.2
|
|
57
77
|
[0.2.1]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.1
|
|
58
78
|
[0.2.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.0
|
|
@@ -11,15 +11,14 @@ so transcribing its colours into this repository by hand
|
|
|
11
11
|
would create exactly the kind of drift this package exists to remove.
|
|
12
12
|
|
|
13
13
|
The website takes its neutral colours from Bootstrap’s tokens (``--bs-fg-*``, ``--bs-bg-*``, …),
|
|
14
|
-
which already carry dark values via ``light-dark()``, and defines only the brand hues itself
|
|
15
|
-
|
|
14
|
+
which already carry dark values via ``light-dark()``, and defines only the brand hues itself,
|
|
15
|
+
as OKLCH triples in ``assets/accents.json``.
|
|
16
|
+
This script looks up the tokens the theme needs in the website’s vendored Bootstrap and ``accents.json``,
|
|
16
17
|
resolves every ``var()`` down to literals, and writes them into ``_tokens.css`` as ``--scverse-color-x``.
|
|
17
|
-
The per-package accents go to ``_accents.json``, because the registry needs their values in Python
|
|
18
|
-
to derive readable shades from them.
|
|
19
|
-
|
|
20
18
|
Only the region between the marker comments is touched; the rest of the file is hand-authored.
|
|
21
19
|
|
|
22
|
-
The scverse logo used for the navbar link back to the website is copied verbatim for the same reason
|
|
20
|
+
The scverse logo used for the navbar link back to the website is copied verbatim for the same reason,
|
|
21
|
+
as is ``accents.json``, which the registry reads the package accents from.
|
|
23
22
|
|
|
24
23
|
Usage
|
|
25
24
|
-----
|
|
@@ -37,16 +36,16 @@ from pathlib import Path
|
|
|
37
36
|
HERE = Path(__file__).parent
|
|
38
37
|
STATIC = HERE.parent / "src" / "scverse_doc" / "theme" / "scverse" / "static"
|
|
39
38
|
TARGET = STATIC / "_tokens.css"
|
|
40
|
-
ACCENTS_TARGET = HERE.parent / "src" / "scverse_doc" / "_accents.json"
|
|
41
39
|
|
|
42
|
-
#: Website file ->
|
|
43
|
-
ASSETS = {
|
|
40
|
+
#: Website file -> package file, copied verbatim.
|
|
41
|
+
ASSETS = {
|
|
42
|
+
Path("static/img/logo/scverse-fa.svg"): STATIC / "scverse-fa.svg",
|
|
43
|
+
Path("assets/accents.json"): HERE.parent / "src" / "scverse_doc" / "_accents.json",
|
|
44
|
+
}
|
|
44
45
|
|
|
45
46
|
#: CSS custom property emitted here -> website custom property it is resolved from.
|
|
46
47
|
#: The pairing mirrors the one scverse/scverse.github.io#329 used when replacing its SCSS variables.
|
|
47
48
|
TOKEN_MAP = {
|
|
48
|
-
"--scverse-color-gradient-start": "--scverse-deep-blue",
|
|
49
|
-
"--scverse-color-gradient-end": "--scverse-sky-blue",
|
|
50
49
|
"--scverse-color-background": "--bs-bg-body",
|
|
51
50
|
"--scverse-color-text": "--bs-fg-body",
|
|
52
51
|
"--scverse-color-heading": "--bs-fg-1",
|
|
@@ -61,18 +60,10 @@ TOKEN_MAP = {
|
|
|
61
60
|
"--scverse-color-footer-bg": "--bs-bg-2",
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
#:
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"mudata": "--mudata-green",
|
|
69
|
-
"muon": "--muon-aquamarine",
|
|
70
|
-
"pertpy": "--scirpy-purple", # the website has no pertpy colour; it has always shared scirpy’s
|
|
71
|
-
"scanpy": "--scanpy-cerise",
|
|
72
|
-
"scirpy": "--scirpy-purple",
|
|
73
|
-
"scvi-tools": "--scvi-yellow",
|
|
74
|
-
"spatialdata": "--spatialdata-blue",
|
|
75
|
-
"squidpy": "--squidpy-violet",
|
|
63
|
+
#: CSS custom property emitted here -> (package, colour name) in the website’s ``accents.json``.
|
|
64
|
+
ACCENT_TOKEN_MAP = {
|
|
65
|
+
"--scverse-color-gradient-start": ("scverse", "deep-blue"),
|
|
66
|
+
"--scverse-color-gradient-end": ("scverse", "sky-blue"),
|
|
76
67
|
}
|
|
77
68
|
|
|
78
69
|
BEGIN = "/* BEGIN GENERATED BRAND TOKENS – DO NOT EDIT; regenerate with scripts/sync_brand_tokens.py */"
|
|
@@ -89,36 +80,34 @@ def parse_bootstrap(css: str) -> dict[str, str]:
|
|
|
89
80
|
return dict(DECL_RE.findall(";".join(blocks) + ";"))
|
|
90
81
|
|
|
91
82
|
|
|
92
|
-
def parse_scss(scss: str) -> dict[str, str]:
|
|
93
|
-
"""Extract custom property declarations from the website’s SCSS."""
|
|
94
|
-
return dict(DECL_RE.findall(scss))
|
|
95
|
-
|
|
96
|
-
|
|
97
83
|
def resolve(name: str, props: dict[str, str]) -> str:
|
|
98
84
|
"""Return the value of `name` with every ``var()`` in it recursively substituted."""
|
|
99
85
|
return re.sub(r"var\((--[\w-]+)\)", lambda m: resolve(m[1], props), props[name])
|
|
100
86
|
|
|
101
87
|
|
|
102
|
-
def render_region(props: dict[str, str], indent: str) -> str:
|
|
88
|
+
def render_region(props: dict[str, str], accents: dict[str, list[tuple[str, list[float]]]], indent: str) -> str:
|
|
103
89
|
"""Render the generated region – marker comments included – indented by `indent`."""
|
|
104
90
|
if missing := sorted(set(TOKEN_MAP.values()) - set(props)):
|
|
105
91
|
msg = f"custom properties vanished from the website: {', '.join(missing)}"
|
|
106
92
|
raise KeyError(msg)
|
|
107
|
-
lines = [
|
|
93
|
+
lines = [
|
|
94
|
+
BEGIN,
|
|
95
|
+
*(
|
|
96
|
+
f"{prop}: oklch({' '.join(map(str, dict(accents[pkg])[name]))});"
|
|
97
|
+
for prop, (pkg, name) in ACCENT_TOKEN_MAP.items()
|
|
98
|
+
),
|
|
99
|
+
*(f"{prop}: {resolve(src, props)};" for prop, src in TOKEN_MAP.items()),
|
|
100
|
+
END,
|
|
101
|
+
]
|
|
108
102
|
return "\n".join(indent + line for line in lines)
|
|
109
103
|
|
|
110
104
|
|
|
111
|
-
def
|
|
112
|
-
"""
|
|
113
|
-
return json.dumps({pkg: resolve(src, props) for pkg, src in ACCENT_MAP.items()}, indent=4) + "\n"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def render(props: dict[str, str], current: str) -> str:
|
|
117
|
-
"""Return `current` with its generated region replaced by one rendered from `props`."""
|
|
105
|
+
def render(props: dict[str, str], accents: dict[str, list[tuple[str, list[float]]]], current: str) -> str:
|
|
106
|
+
"""Return `current` with its generated region replaced by one rendered from `props` and `accents`."""
|
|
118
107
|
if (region := REGION_RE.search(current)) is None:
|
|
119
108
|
msg = f"{TARGET} has no “{BEGIN}” … “{END}” region"
|
|
120
109
|
raise LookupError(msg)
|
|
121
|
-
return current[: region.start()] + render_region(props, region[1]) + current[region.end() :]
|
|
110
|
+
return current[: region.start()] + render_region(props, accents, region[1]) + current[region.end() :]
|
|
122
111
|
|
|
123
112
|
|
|
124
113
|
def main() -> int:
|
|
@@ -128,12 +117,10 @@ def main() -> int:
|
|
|
128
117
|
parser.add_argument("--check", action="store_true", help="fail instead of writing if the output would change")
|
|
129
118
|
args = parser.parse_args()
|
|
130
119
|
|
|
131
|
-
props = parse_bootstrap(
|
|
132
|
-
|
|
133
|
-
) | parse_scss((args.website / "assets" / "main.scss").read_text())
|
|
120
|
+
props = parse_bootstrap((args.website / "static" / "bootstrap" / "css" / "bootstrap.min.css").read_text())
|
|
121
|
+
accents = json.loads((args.website / "assets" / "accents.json").read_text())
|
|
134
122
|
updates = {
|
|
135
|
-
TARGET: render(props, TARGET.read_text()).encode(),
|
|
136
|
-
ACCENTS_TARGET: render_accents(props).encode(),
|
|
123
|
+
TARGET: render(props, accents, TARGET.read_text()).encode(),
|
|
137
124
|
**{dst: (args.website / src).read_bytes() for src, dst in ASSETS.items()},
|
|
138
125
|
}
|
|
139
126
|
if args.check:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"anndata": [["orange", [0.711, 0.138, 51]]],
|
|
3
|
+
"scanpy": [
|
|
4
|
+
["cerise", [0.608, 0.209, 1]],
|
|
5
|
+
["mandy", [0.634, 0.1737, 22]]
|
|
6
|
+
],
|
|
7
|
+
"mudata": [["green", [0.686, 0.134, 154.4]]],
|
|
8
|
+
"muon": [["aquamarine", [0.863, 0.163, 154.5]]],
|
|
9
|
+
"spatialdata": [["blue", [0.714, 0.158, 247.3]]],
|
|
10
|
+
"squidpy": [["violet", [0.72, 0.112, 279]]],
|
|
11
|
+
"scirpy": [
|
|
12
|
+
["purple", [0.601, 0.209, 358.5]],
|
|
13
|
+
["orange", [0.7824, 0.156, 69]]
|
|
14
|
+
],
|
|
15
|
+
"pertpy": [
|
|
16
|
+
["blue", [0.5, 0.1, 249]],
|
|
17
|
+
["red", [0.595, 0.177, 14]]
|
|
18
|
+
],
|
|
19
|
+
"scvi": [["yellow", [0.824, 0.1634, 81]]],
|
|
20
|
+
"scverse": [
|
|
21
|
+
["deep-blue", [0.405, 0.205, 270]],
|
|
22
|
+
["sky-blue", [0.799, 0.108, 236]],
|
|
23
|
+
["gold", [0.758, 0.2, 92]]
|
|
24
|
+
]
|
|
25
|
+
}
|
{scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/autodoc/templates/autosummary/class.rst
RENAMED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
.. autoclass:: {{ fullname }}
|
|
8
8
|
|
|
9
9
|
{% set methods = methods | select("ne", "__init__") | list %}
|
|
10
|
+
{#- Inside autoclass, names resolve against the class’s real module, so prefix the class name:
|
|
11
|
+
`objname` can go through a module alias, and bare members break autosummary’s instance attribute fallback. #}
|
|
12
|
+
{% set clsname = fullname.split(".") | last %}
|
|
10
13
|
|
|
11
14
|
{% block attributes %}
|
|
12
15
|
{% for item in attributes %}
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
|
|
17
20
|
.. autosummary::
|
|
18
21
|
{% endif %}
|
|
19
|
-
~{{ [
|
|
22
|
+
~{{ [clsname, item] | join(".") }}
|
|
20
23
|
{%- endfor %}
|
|
21
24
|
{% endblock %}
|
|
22
25
|
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
|
|
29
32
|
.. autosummary::
|
|
30
33
|
{% endif %}
|
|
31
|
-
~{{ [
|
|
34
|
+
~{{ [clsname, item] | join(".") }}
|
|
32
35
|
{% endfor %}
|
|
33
36
|
{% endblock %}
|
|
34
37
|
|
|
@@ -55,11 +55,15 @@ def _build_cache(app: Sphinx) -> Path:
|
|
|
55
55
|
return _cache_dir
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
#: Brand accents from the website,
|
|
59
|
-
|
|
58
|
+
#: Brand accents from the website, copied by ``scripts/sync_brand_tokens.py``:
|
|
59
|
+
#: each key lists ``[name, [L, C, H]]`` pairs, primary first.
|
|
60
|
+
_ACCENTS: dict[str, list[str]] = {
|
|
61
|
+
{"scvi": "scvi-tools"}.get(pkg, pkg): ["oklch({} {} {})".format(*lch) for _, lch in colors]
|
|
62
|
+
for pkg, colors in json.loads(files(__package__).joinpath("_accents.json").read_text()).items()
|
|
63
|
+
}
|
|
60
64
|
|
|
61
65
|
#: The website’s ``--scverse-deep-blue``, used when a package has no accent of its own.
|
|
62
|
-
DEFAULT_ACCENT = _ACCENTS.pop("
|
|
66
|
+
DEFAULT_ACCENT = _ACCENTS.pop("scverse")[0]
|
|
63
67
|
|
|
64
68
|
#: Upstream ``category`` -> the ``kind`` recorded here.
|
|
65
69
|
#: ``core-infrastructure`` is skipped:
|
|
@@ -105,6 +109,9 @@ class Package:
|
|
|
105
109
|
accent: str = DEFAULT_ACCENT
|
|
106
110
|
"""The package’s brand accent, falling back to the scverse deep blue."""
|
|
107
111
|
|
|
112
|
+
secondary_accent: str | None = None
|
|
113
|
+
"""The package’s second brand colour, or :data:`None` if it has only one."""
|
|
114
|
+
|
|
108
115
|
|
|
109
116
|
class _Entry(TypedDict):
|
|
110
117
|
"""The fields of an upstream listing entry that the registry reads."""
|
|
@@ -148,7 +155,8 @@ def _load() -> Mapping[str, Package]:
|
|
|
148
155
|
inventory=meta.get("inventory"),
|
|
149
156
|
repo=meta.get("project_home"),
|
|
150
157
|
description=" ".join(meta.get("description", "").split()),
|
|
151
|
-
accent=_ACCENTS.get(name, DEFAULT_ACCENT
|
|
158
|
+
accent=accents[0] if (accents := _ACCENTS.get(name, [])) else DEFAULT_ACCENT,
|
|
159
|
+
secondary_accent=accents[1] if len(accents) >= 2 else None,
|
|
152
160
|
)
|
|
153
161
|
# Sorted here, because upstream’s listing order is not stable.
|
|
154
162
|
for name, meta in sorted(((meta["name"].casefold(), meta) for meta in _fetch()), key=itemgetter(0))
|
|
@@ -16,7 +16,6 @@ from typing import TYPE_CHECKING
|
|
|
16
16
|
|
|
17
17
|
from sphinx.util.typing import ExtensionMetadata
|
|
18
18
|
|
|
19
|
-
from .._color import derive_readable
|
|
20
19
|
from ..registry import DEFAULT_ACCENT, _build_cache, packages
|
|
21
20
|
|
|
22
21
|
if TYPE_CHECKING:
|
|
@@ -31,11 +30,28 @@ _THEME_PATH = Path(__file__).parent / "scverse"
|
|
|
31
30
|
_LIGHT_BACKGROUND = "#ffffff"
|
|
32
31
|
_DARK_BACKGROUND = "#14181e"
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
#: OKLCH lightness bounds at which any hue and chroma meets WCAG AA on `_LIGHT_BACKGROUND` / `_DARK_BACKGROUND`;
|
|
34
|
+
#: ``tests/test_color.py`` checks them.
|
|
35
|
+
_MAX_LIGHTNESS_ON_LIGHT = 0.54
|
|
36
|
+
_MIN_LIGHTNESS_ON_DARK = 0.66
|
|
37
|
+
|
|
38
|
+
_ACCENT_CSS = f"""\
|
|
39
|
+
:root {{{{
|
|
40
|
+
--scverse-color-accent-decorative: {{accent}};
|
|
41
|
+
--scverse-color-accent-text: light-dark(
|
|
42
|
+
oklch(from var(--scverse-color-accent-decorative) min(l, {_MAX_LIGHTNESS_ON_LIGHT}) c h),
|
|
43
|
+
oklch(from var(--scverse-color-accent-decorative) max(l, {_MIN_LIGHTNESS_ON_DARK}) c h)
|
|
44
|
+
);
|
|
45
|
+
}}}}
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
_SECONDARY_ACCENT_CSS = f"""\
|
|
49
|
+
:root {{{{
|
|
50
|
+
--scverse-color-secondary-accent-text: light-dark(
|
|
51
|
+
oklch(from {{accent}} min(l, {_MAX_LIGHTNESS_ON_LIGHT}) c h),
|
|
52
|
+
oklch(from {{accent}} max(l, {_MIN_LIGHTNESS_ON_DARK}) c h)
|
|
53
|
+
);
|
|
54
|
+
}}}}
|
|
39
55
|
"""
|
|
40
56
|
|
|
41
57
|
#: scverse.org itself is linked from the scverse menu beside them.
|
|
@@ -54,6 +70,15 @@ def _accent(config: Config) -> str:
|
|
|
54
70
|
return DEFAULT_ACCENT
|
|
55
71
|
|
|
56
72
|
|
|
73
|
+
def _secondary_accent(config: Config) -> str | None:
|
|
74
|
+
accent: str | bool = config.html_theme_options.get("secondary_accent")
|
|
75
|
+
if accent is not True:
|
|
76
|
+
return accent or None
|
|
77
|
+
if pkg := packages.get(_package_name(config)):
|
|
78
|
+
return pkg.secondary_accent
|
|
79
|
+
return None
|
|
80
|
+
|
|
81
|
+
|
|
57
82
|
def _add_chrome(config: Config) -> None:
|
|
58
83
|
"""Add the brand icon links and the colour mode, alongside whatever :mod:`scverse_doc.source` set."""
|
|
59
84
|
options = config.html_theme_options
|
|
@@ -78,16 +103,12 @@ def _configure(app: Sphinx) -> None:
|
|
|
78
103
|
|
|
79
104
|
_add_chrome(config)
|
|
80
105
|
|
|
81
|
-
|
|
106
|
+
css = _ACCENT_CSS.format(accent=_accent(config))
|
|
107
|
+
if secondary := _secondary_accent(config):
|
|
108
|
+
css += _SECONDARY_ACCENT_CSS.format(accent=secondary)
|
|
82
109
|
static_dir = _build_cache(app) / "static"
|
|
83
110
|
static_dir.mkdir(parents=True, exist_ok=True)
|
|
84
|
-
(static_dir / "scverse-accent.css").write_text(
|
|
85
|
-
_ACCENT_CSS.format(
|
|
86
|
-
accent=accent,
|
|
87
|
-
light=derive_readable(accent, _LIGHT_BACKGROUND),
|
|
88
|
-
dark=derive_readable(accent, _DARK_BACKGROUND),
|
|
89
|
-
)
|
|
90
|
-
)
|
|
111
|
+
(static_dir / "scverse-accent.css").write_text(css)
|
|
91
112
|
config.html_static_path = [*config.html_static_path, str(static_dir)]
|
|
92
113
|
app.add_css_file("scverse-accent.css")
|
|
93
114
|
app.add_js_file("scripts/readthedocs-integration.js", type="module")
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
:root {
|
|
11
11
|
/* BEGIN GENERATED BRAND TOKENS – DO NOT EDIT; regenerate with scripts/sync_brand_tokens.py */
|
|
12
|
-
--scverse-color-gradient-start:
|
|
13
|
-
--scverse-color-gradient-end:
|
|
12
|
+
--scverse-color-gradient-start: oklch(0.405 0.205 270);
|
|
13
|
+
--scverse-color-gradient-end: oklch(0.799 0.108 236);
|
|
14
14
|
--scverse-color-background: light-dark(#fff,color-mix(in oklch, #000 76%, oklch(60% .02 245)));
|
|
15
15
|
--scverse-color-text: light-dark(color-mix(in oklch, #000 64%, oklch(60% .02 245)),color-mix(in oklch, #fff 90%, oklch(60% .02 245)));
|
|
16
16
|
--scverse-color-heading: light-dark(color-mix(in oklch, #000 48%, oklch(60% .02 245)),color-mix(in oklch, #fff 60%, oklch(60% .02 245)));
|
{scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/static/styles/scverse.css
RENAMED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* the mode. If a component needs a dark-specific rule, the token vocabulary is missing something – add the
|
|
9
9
|
* token in _tokens.css instead.
|
|
10
10
|
* 3. The raw package accent is decorative only. Text and links use the derived --scverse-color-accent-text, which
|
|
11
|
-
* the
|
|
11
|
+
* clamps the accent’s lightness to meet WCAG AA against the current background. See scverse_doc.theme.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
@import url("../_tokens.css");
|
|
@@ -94,7 +94,8 @@ html:not(:has(.bd-header__inner)) {
|
|
|
94
94
|
/* Span the article container’s padding, so content doesn’t peek out beside it */
|
|
95
95
|
margin: -1rem -1rem 0;
|
|
96
96
|
padding-inline: 1rem;
|
|
97
|
-
|
|
97
|
+
/* pydata’s navbar shadow, horizontally shrunk so it only extends downwards */
|
|
98
|
+
box-shadow: -0.125rem 0.25rem 0.25rem -0.125rem var(--pst-color-shadow);
|
|
98
99
|
}
|
|
99
100
|
/* Where supported, only once the page is scrolled */
|
|
100
101
|
@supports (animation-timeline: scroll()) {
|
|
@@ -227,6 +228,13 @@ a.dropdown-item {
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
nav.bd-links p.caption {
|
|
232
|
+
color: var(
|
|
233
|
+
--scverse-color-secondary-accent-text,
|
|
234
|
+
var(--pst-color-text-base)
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
230
238
|
readthedocs-flyout {
|
|
231
239
|
--readthedocs-flyout-background-color: transparent;
|
|
232
240
|
--readthedocs-flyout-font-family: inherit;
|
|
@@ -9,22 +9,23 @@ sidebars = ["navbar-logo", "search-button-field", "scverse-sidebar-nav"]
|
|
|
9
9
|
[options]
|
|
10
10
|
package = ""
|
|
11
11
|
accent = ""
|
|
12
|
-
|
|
12
|
+
secondary_accent = false
|
|
13
|
+
show_ecosystem_dropdown = true
|
|
13
14
|
# No navbar: its parts live in the primary sidebar and the article header.
|
|
14
|
-
navbar_start =
|
|
15
|
-
navbar_center =
|
|
16
|
-
navbar_end =
|
|
17
|
-
navbar_persistent =
|
|
15
|
+
navbar_start = []
|
|
16
|
+
navbar_center = []
|
|
17
|
+
navbar_end = []
|
|
18
|
+
navbar_persistent = []
|
|
18
19
|
article_header_start = ["toggle-primary-sidebar", "breadcrumbs"]
|
|
19
20
|
article_header_end = ["theme-switcher", "navbar-icon-links", "scverse-ecosystem", "toggle-secondary-sidebar"]
|
|
20
21
|
primary_sidebar_end = ["sidebar-ethical-ads", "sidebar-versions"]
|
|
21
22
|
secondary_sidebar_items = ["page-toc", "edit-this-page", "sourcelink"]
|
|
22
|
-
footer_start = "scverse-footer"
|
|
23
|
-
footer_center =
|
|
24
|
-
footer_end =
|
|
25
|
-
show_toc_level =
|
|
26
|
-
navigation_depth =
|
|
27
|
-
collapse_navigation =
|
|
23
|
+
footer_start = ["scverse-footer"]
|
|
24
|
+
footer_center = []
|
|
25
|
+
footer_end = []
|
|
26
|
+
show_toc_level = 2
|
|
27
|
+
navigation_depth = 3
|
|
28
|
+
collapse_navigation = false
|
|
28
29
|
pygments_light_style = "tango"
|
|
29
30
|
pygments_dark_style = "monokai"
|
|
30
31
|
announcement = "https://scverse.org/announcement.html"
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
"""Colour maths for deriving accessible accent shades.
|
|
3
|
-
|
|
4
|
-
Package accents are chosen for brand recognition, not for contrast.
|
|
5
|
-
Several of the accents scverse already uses (``#6cf1a1`` for muon, ``#fbb822`` for scvi-tools)
|
|
6
|
-
fail WCAG AA as text colours on white, and others fail on a dark background.
|
|
7
|
-
So the raw accent is only ever used for decorative surfaces,
|
|
8
|
-
and text/link colours are *derived* from it here by moving lightness until the contrast target is met,
|
|
9
|
-
keeping hue and saturation intact so the result still reads as the package’s colour.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from __future__ import annotations
|
|
13
|
-
|
|
14
|
-
import colorsys
|
|
15
|
-
import re
|
|
16
|
-
from typing import NamedTuple
|
|
17
|
-
|
|
18
|
-
__all__ = ["contrast_ratio", "derive_readable", "parse_hex", "relative_luminance"]
|
|
19
|
-
|
|
20
|
-
#: Minimum contrast ratio for normal-size body text under WCAG 2.1 AA.
|
|
21
|
-
WCAG_AA_NORMAL = 4.5
|
|
22
|
-
|
|
23
|
-
_HEX_RE = re.compile(r"\A#?(?P<digits>[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\Z")
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class RGB(NamedTuple):
|
|
27
|
-
"""An sRGB colour with channels in ``[0, 1]``."""
|
|
28
|
-
|
|
29
|
-
r: float
|
|
30
|
-
g: float
|
|
31
|
-
b: float
|
|
32
|
-
|
|
33
|
-
def to_hex(self) -> str:
|
|
34
|
-
"""Render as a lowercase ``#rrggbb`` string."""
|
|
35
|
-
return "#" + "".join(f"{round(c * 255):02x}" for c in self)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def parse_hex(color: str) -> RGB:
|
|
39
|
-
"""Parse a CSS hex colour.
|
|
40
|
-
|
|
41
|
-
Parameters
|
|
42
|
-
----------
|
|
43
|
-
color
|
|
44
|
-
A ``#rgb`` or ``#rrggbb`` string, with or without the leading ``#``.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
The colour, with channels normalised to ``[0, 1]``.
|
|
49
|
-
|
|
50
|
-
Raises
|
|
51
|
-
------
|
|
52
|
-
ValueError
|
|
53
|
-
If `color` is not a three- or six-digit hex colour.
|
|
54
|
-
"""
|
|
55
|
-
if (m := _HEX_RE.match(color.strip())) is None:
|
|
56
|
-
msg = f"Not a hex colour: {color!r}"
|
|
57
|
-
raise ValueError(msg)
|
|
58
|
-
digits = m["digits"]
|
|
59
|
-
if len(digits) == 3:
|
|
60
|
-
digits = "".join(d * 2 for d in digits)
|
|
61
|
-
return RGB(*(c / 255 for c in bytes.fromhex(digits)))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _to_linear(channel: float) -> float:
|
|
65
|
-
"""Undo the sRGB transfer function for a single channel."""
|
|
66
|
-
return channel / 12.92 if channel <= 0.04045 else ((channel + 0.055) / 1.055) ** 2.4
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def relative_luminance(color: RGB | str) -> float:
|
|
70
|
-
"""Compute the WCAG relative luminance of a colour.
|
|
71
|
-
|
|
72
|
-
Parameters
|
|
73
|
-
----------
|
|
74
|
-
color
|
|
75
|
-
An :class:`RGB` colour or a hex string.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
Relative luminance in ``[0, 1]``, where 0 is black and 1 is white.
|
|
80
|
-
"""
|
|
81
|
-
r, g, b = parse_hex(color) if isinstance(color, str) else color
|
|
82
|
-
return 0.2126 * _to_linear(r) + 0.7152 * _to_linear(g) + 0.0722 * _to_linear(b)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def contrast_ratio(fg: RGB | str, bg: RGB | str) -> float:
|
|
86
|
-
"""Compute the WCAG contrast ratio between two colours.
|
|
87
|
-
|
|
88
|
-
Parameters
|
|
89
|
-
----------
|
|
90
|
-
fg
|
|
91
|
-
Foreground colour.
|
|
92
|
-
bg
|
|
93
|
-
Background colour.
|
|
94
|
-
|
|
95
|
-
Returns
|
|
96
|
-
-------
|
|
97
|
-
A ratio between 1 (identical) and 21 (black on white).
|
|
98
|
-
"""
|
|
99
|
-
lum_a, lum_b = relative_luminance(fg), relative_luminance(bg)
|
|
100
|
-
lighter, darker = max(lum_a, lum_b), min(lum_a, lum_b)
|
|
101
|
-
return (lighter + 0.05) / (darker + 0.05)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def derive_readable(accent: str, background: str, *, target: float = WCAG_AA_NORMAL) -> str:
|
|
105
|
-
"""Derive a text-safe variant of `accent` that meets `target` contrast against `background`.
|
|
106
|
-
|
|
107
|
-
Hue and saturation are preserved and only lightness is moved,
|
|
108
|
-
so the result still reads as the same colour.
|
|
109
|
-
Lightness moves away from the background:
|
|
110
|
-
darker on a light background, lighter on a dark one.
|
|
111
|
-
|
|
112
|
-
Parameters
|
|
113
|
-
----------
|
|
114
|
-
accent
|
|
115
|
-
The brand accent to adjust, as a hex string.
|
|
116
|
-
background
|
|
117
|
-
The background the derived colour will sit on, as a hex string.
|
|
118
|
-
target
|
|
119
|
-
The contrast ratio to reach.
|
|
120
|
-
|
|
121
|
-
Returns
|
|
122
|
-
-------
|
|
123
|
-
A hex colour meeting `target` where that is achievable by lightness alone,
|
|
124
|
-
otherwise the closest achievable colour, which is black or white.
|
|
125
|
-
|
|
126
|
-
Examples
|
|
127
|
-
--------
|
|
128
|
-
>>> derive_readable("#fbb822", "#ffffff") # scvi-tools yellow, unreadable as-is
|
|
129
|
-
'#9d6d03'
|
|
130
|
-
"""
|
|
131
|
-
if contrast_ratio(accent, background) >= target:
|
|
132
|
-
return parse_hex(accent).to_hex()
|
|
133
|
-
|
|
134
|
-
hue, lightness, saturation = colorsys.rgb_to_hls(*parse_hex(accent))
|
|
135
|
-
darken = relative_luminance(background) > 0.5
|
|
136
|
-
step = -1 / 512 if darken else 1 / 512
|
|
137
|
-
|
|
138
|
-
# Candidates are checked after rounding to 8-bit hex:
|
|
139
|
-
# a float lightness that clears the target can fall back under it once quantized,
|
|
140
|
-
# which is how #e5864b and #fbb822 ended up one hundredth short of AA.
|
|
141
|
-
while 0.0 <= (lightness := lightness + step) <= 1.0:
|
|
142
|
-
candidate = parse_hex(RGB(*colorsys.hls_to_rgb(hue, lightness, saturation)).to_hex())
|
|
143
|
-
if contrast_ratio(candidate, background) >= target:
|
|
144
|
-
return candidate.to_hex()
|
|
145
|
-
|
|
146
|
-
return "#000000" if darken else "#ffffff"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/autodoc/templates/autosummary/module.rst
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scverse_doc-0.2.3 → scverse_doc-0.3.0}/src/scverse_doc/theme/scverse/components/scverse-footer.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|