scverse-doc 0.3.0__tar.gz → 0.4.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.
Files changed (62) hide show
  1. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.editorconfig +1 -1
  2. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/autofix.yaml +2 -2
  3. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/build.yaml +1 -1
  4. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/pr.yaml +1 -1
  5. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/release.yaml +2 -2
  6. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/sync.yaml +9 -3
  7. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/workflows/test.yaml +7 -7
  8. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.gitignore +2 -0
  9. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.pre-commit-config.yaml +7 -4
  10. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/CHANGELOG.md +20 -1
  11. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/PKG-INFO +5 -2
  12. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/biome.jsonc +2 -1
  13. scverse_doc-0.4.0/hatch_build.py +22 -0
  14. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/pyproject.toml +16 -8
  15. scverse_doc-0.3.0/scripts/sync_brand_tokens.py → scverse_doc-0.4.0/scripts/sync_upstream.py +14 -5
  16. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/__init__.py +4 -1
  17. scverse_doc-0.4.0/src/scverse_doc/_accents.json +48 -0
  18. scverse_doc-0.4.0/src/scverse_doc/math_core.py +117 -0
  19. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/registry.py +2 -2
  20. scverse_doc-0.4.0/src/scverse_doc/static/math_core.css +13 -0
  21. scverse_doc-0.4.0/src/scverse_doc/static/mathmlfixes.css +93 -0
  22. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/__init__.py +4 -0
  23. scverse_doc-0.4.0/src/scverse_doc/theme/_bundle.py +33 -0
  24. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/toggle-secondary-sidebar.html +1 -1
  25. scverse_doc-0.4.0/src/scverse_doc/theme/scverse/static/styles/_pydata.css +140 -0
  26. scverse_doc-0.4.0/src/scverse_doc/theme/scverse/static/styles/_readthedocs.css +63 -0
  27. {scverse_doc-0.3.0/src/scverse_doc/theme/scverse/static → scverse_doc-0.4.0/src/scverse_doc/theme/scverse/static/styles}/_tokens.css +1 -1
  28. scverse_doc-0.4.0/src/scverse_doc/theme/scverse/static/styles/scverse.css +178 -0
  29. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/theme.toml +2 -1
  30. scverse_doc-0.3.0/src/scverse_doc/_accents.json +0 -25
  31. scverse_doc-0.3.0/src/scverse_doc/theme/scverse/static/styles/scverse.css +0 -366
  32. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.codecov.yaml +0 -0
  33. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.cruft.json +0 -0
  34. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  35. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  36. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  37. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.github/dependabot.yml +0 -0
  38. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.readthedocs.yaml +0 -0
  39. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.vscode/extensions.json +0 -0
  40. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.vscode/launch.json +0 -0
  41. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/.vscode/settings.json +0 -0
  42. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/LICENSE +0 -0
  43. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/README.md +0 -0
  44. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/scripts/check_changelog.py +0 -0
  45. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/autodoc/__init__.py +0 -0
  46. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/autodoc/templates/autosummary/class.rst +0 -0
  47. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/autodoc/templates/autosummary/module.rst +0 -0
  48. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/config.py +0 -0
  49. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/napoleon.py +0 -0
  50. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/py.typed +0 -0
  51. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/release_notes.py +0 -0
  52. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/source.py +0 -0
  53. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/scverse-ecosystem.html +0 -0
  54. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/scverse-footer.html +0 -0
  55. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/scverse-sidebar-nav.html +0 -0
  56. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/sidebar-versions.html +0 -0
  57. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/components/toggle-primary-sidebar.html +0 -0
  58. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/layout.html +0 -0
  59. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/static/scripts/readthedocs-integration.js +0 -0
  60. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/theme/scverse/static/scverse-fa.svg +0 -0
  61. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/typed_fields.py +0 -0
  62. {scverse_doc-0.3.0 → scverse_doc-0.4.0}/src/scverse_doc/xref_overrides.py +0 -0
@@ -8,7 +8,7 @@ charset = utf-8
8
8
  trim_trailing_whitespace = true
9
9
  insert_final_newline = true
10
10
 
11
- [{*.{yml,yaml,toml},.cruft.json}]
11
+ [{*.yml,*.yaml,*.toml,.cruft.json}]
12
12
  indent_size = 2
13
13
 
14
14
  [Makefile]
@@ -19,11 +19,11 @@ jobs:
19
19
  fetch-depth: 0
20
20
  filter: blob:none
21
21
  persist-credentials: false
22
- - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
22
+ - uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
23
23
  with:
24
24
  enable-cache: true
25
25
  - run: uv tool install hatch
26
26
  - name: Run pre-commit hooks
27
27
  run: uvx prek run --all-files --show-diff-on-failure --color=always
28
28
  - uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
29
- if: '!cancelled()'
29
+ if: "!cancelled()"
@@ -23,7 +23,7 @@ jobs:
23
23
  fetch-depth: 0
24
24
  persist-credentials: false
25
25
  - name: Install uv
26
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
26
+ uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
27
27
  - name: Build package
28
28
  run: uv build
29
29
  - name: Check package
@@ -12,7 +12,7 @@ jobs:
12
12
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
13
13
  with:
14
14
  persist-credentials: false
15
- - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
15
+ - uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
16
16
  - run: uv run scripts/check_changelog.py --pr="$PR" --title="$TITLE"
17
17
  env:
18
18
  PR: ${{ github.event.pull_request.number }}
@@ -24,10 +24,10 @@ jobs:
24
24
  fetch-depth: 0
25
25
  persist-credentials: false
26
26
  - name: Install uv
27
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
27
+ uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
28
28
  with:
29
29
  enable-cache: false
30
30
  - name: Build package
31
31
  run: uv build
32
32
  - name: Publish package distributions to PyPI
33
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
33
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
@@ -6,8 +6,9 @@ on:
6
6
  workflow_dispatch:
7
7
  pull_request:
8
8
  paths:
9
- - src/scverse_doc/theme/scverse/static/_tokens.css
9
+ - src/scverse_doc/theme/scverse/static/styles/_tokens.css
10
10
  - src/scverse_doc/theme/scverse/static/scverse-fa.svg
11
+ - src/scverse_doc/static/mathmlfixes.css
11
12
  - scripts/**
12
13
 
13
14
  permissions:
@@ -26,5 +27,10 @@ jobs:
26
27
  repository: scverse/scverse.github.io
27
28
  path: .upstream/website
28
29
  persist-credentials: false
29
- - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
30
- - run: uv run scripts/sync_brand_tokens.py --website .upstream/website --check
30
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31
+ with:
32
+ repository: tmke8/math-core
33
+ path: .upstream/math-core
34
+ persist-credentials: false
35
+ - uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
36
+ - run: uv run scripts/sync_upstream.py --website .upstream/website --math-core .upstream/math-core --check
@@ -33,7 +33,7 @@ jobs:
33
33
  fetch-depth: 0
34
34
  persist-credentials: false
35
35
  - &setup-uv
36
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
36
+ uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
37
37
  - name: Get test environments
38
38
  id: get-envs
39
39
  run: |
@@ -52,8 +52,8 @@ jobs:
52
52
  test:
53
53
  needs: get-environments
54
54
  permissions:
55
- id-token: write # for codecov OIDC
56
- contents: read
55
+ id-token: write # for codecov OIDC
56
+ contents: read
57
57
 
58
58
  strategy:
59
59
  fail-fast: false
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  name: ${{ matrix.env.label }}
65
65
  runs-on: ${{ matrix.os }}
66
- continue-on-error: ${{ contains(matrix.env.name, 'pre') }} # make "all-green" pass even if pre-release job fails
66
+ continue-on-error: ${{ contains(matrix.env.name, 'pre') }} # make "all-green" pass even if pre-release job fails
67
67
  env:
68
68
  UV_PYTHON: ${{ matrix.env.python }}
69
69
 
@@ -102,6 +102,6 @@ jobs:
102
102
  - test
103
103
  runs-on: ubuntu-latest
104
104
  steps:
105
- - uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
106
- with:
107
- jobs: ${{ toJSON(needs) }}
105
+ - uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
106
+ with:
107
+ jobs: ${{ toJSON(needs) }}
@@ -11,6 +11,8 @@ __pycache__/
11
11
 
12
12
  # Distribution / packaging
13
13
  /dist/
14
+ # Built by hatch_build.py
15
+ *.min.css*
14
16
 
15
17
  # Tests and coverage
16
18
  /data/
@@ -7,23 +7,26 @@ default_stages:
7
7
  minimum_pre_commit_version: 2.16.0
8
8
  repos:
9
9
  - repo: https://github.com/biomejs/pre-commit
10
- rev: v2.5.15
10
+ rev: v2.6.3
11
11
  hooks:
12
12
  - id: biome-format
13
13
  exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually.
14
14
  groups: [format]
15
+ - id: biome-lint
16
+ args: [--error-on-warnings]
15
17
  - repo: https://github.com/tox-dev/pyproject-fmt
16
18
  rev: v2.30.3
17
19
  hooks:
18
20
  - id: pyproject-fmt
19
21
  groups: [format]
20
22
  - repo: https://github.com/djlint/djLint
21
- rev: v1.46.4
23
+ rev: v1.47.0
22
24
  hooks:
23
25
  - id: djlint-reformat
26
+ groups: [format]
24
27
  - id: djlint
25
28
  - repo: https://github.com/astral-sh/ruff-pre-commit
26
- rev: v0.17.0
29
+ rev: v0.17.2
27
30
  hooks:
28
31
  - id: ruff-check
29
32
  args: [--fix, --exit-non-zero-on-fix]
@@ -57,7 +60,7 @@ repos:
57
60
  - id: check-merge-conflict
58
61
  args: [--assume-in-merge]
59
62
  - repo: https://github.com/zizmorcore/zizmor-pre-commit
60
- rev: v1.30.1
63
+ rev: v1.31.1
61
64
  hooks:
62
65
  - id: zizmor
63
66
  args: [--no-progress, --fix]
@@ -10,6 +10,24 @@ and this project adheres to [Semantic Versioning][].
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.4.0]
14
+
15
+ ### Changed
16
+
17
+ - Sphinx 9.1 or newer is required
18
+
19
+ ### Added
20
+
21
+ - `scverse_doc.math_core` renders math to MathML at build time via [math-core](https://github.com/tmke8/math-core) instead of MathJax (#75)
22
+ - `math_core_options` configures the converter, e.g. with macros
23
+ - math-core’s `mathmlfixes.css` is included, fixing e.g. `\boxed` and `\cancel` in Chromium
24
+
25
+ ### Fixed
26
+
27
+ - rapids-singlecell’s accents are synced from the website (#78)
28
+ - mantispy’s accents are synced from the website (#81)
29
+ - liana’s, CellRank’s and PyDESeq2’s accents and squidpy’s second accent are synced from the website (#83)
30
+
13
31
  ## [0.3.0]
14
32
 
15
33
  ### Added
@@ -70,7 +88,8 @@ and this project adheres to [Semantic Versioning][].
70
88
  - Read the Docs integration: version selector and search, both with dark mode
71
89
  - Autodoc, prose, and confval rendering extensions (from scverse-misc)
72
90
 
73
- [Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.3.0...main
91
+ [Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.4.0...main
92
+ [0.4.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.4.0
74
93
  [0.3.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.3.0
75
94
  [0.2.3]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.3
76
95
  [0.2.2]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: scverse-doc
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Scverse documentation theme and utilities.
5
5
  Project-URL: Documentation, https://scverse-doc.readthedocs.io/
6
6
  Project-URL: Homepage, https://github.com/scverse/scverse-doc
@@ -18,18 +18,21 @@ Classifier: Programming Language :: Python :: 3.15
18
18
  Classifier: Typing :: Typed
19
19
  Requires-Python: >=3.12
20
20
  Requires-Dist: packaging
21
- Requires-Dist: sphinx>=8.1
21
+ Requires-Dist: sphinx>=9.1
22
22
  Provides-Extra: config
23
23
  Requires-Dist: myst-nb>=1.1; extra == 'config'
24
24
  Requires-Dist: sphinx-copybutton; extra == 'config'
25
25
  Requires-Dist: sphinx-design; extra == 'config'
26
26
  Requires-Dist: sphinxext-opengraph; extra == 'config'
27
27
  Provides-Extra: full
28
+ Requires-Dist: math-core; extra == 'full'
28
29
  Requires-Dist: myst-nb>=1.1; extra == 'full'
29
30
  Requires-Dist: pydata-sphinx-theme>=0.23; extra == 'full'
30
31
  Requires-Dist: sphinx-copybutton; extra == 'full'
31
32
  Requires-Dist: sphinx-design; extra == 'full'
32
33
  Requires-Dist: sphinxext-opengraph; extra == 'full'
34
+ Provides-Extra: math-core
35
+ Requires-Dist: math-core; extra == 'math-core'
33
36
  Provides-Extra: theme
34
37
  Requires-Dist: pydata-sphinx-theme>=0.23; extra == 'theme'
35
38
  Description-Content-Type: text/markdown
@@ -7,7 +7,8 @@
7
7
  "**",
8
8
  "!src/scverse_doc/registry.json",
9
9
  "!src/scverse_doc/_accents.json",
10
- "!src/scverse_doc/theme/scverse/static/_tokens.css",
10
+ "!src/scverse_doc/static/mathmlfixes.css",
11
+ "!src/scverse_doc/theme/scverse/static/styles/_tokens.css",
11
12
  ],
12
13
  },
13
14
  "formatter": { "useEditorconfig": true },
@@ -0,0 +1,22 @@
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ """Build the theme’s ``styles/*.min.css``, see ``scverse_doc.theme._bundle``."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import runpy
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ from hatchling.builders.hooks.plugin.interface import BuildHookInterface
11
+
12
+
13
+ class CSSBundleHook(BuildHookInterface): # type: ignore[type-arg]
14
+ """Bundle the theme stylesheets."""
15
+
16
+ def initialize(self, version: str, build_data: dict[str, Any]) -> None: # noqa: D102
17
+ # By path, as the package isn’t installed yet.
18
+ mod = runpy.run_path(str(Path(self.root) / "src/scverse_doc/theme/_bundle.py"))
19
+ if (exe := mod["find_lightningcss"]()) is None:
20
+ msg = "lightningcss binary not found"
21
+ raise RuntimeError(msg)
22
+ mod["bundle"](exe)
@@ -1,6 +1,6 @@
1
1
  [build-system]
2
2
  build-backend = "hatchling.build"
3
- requires = [ "hatch-fancy-pypi-readme", "hatch-vcs", "hatchling" ]
3
+ requires = [ "hatch-fancy-pypi-readme", "hatch-vcs", "hatchling", "lightningcss-cli" ]
4
4
 
5
5
  [project]
6
6
  name = "scverse-doc"
@@ -25,7 +25,7 @@ classifiers = [
25
25
  "Typing :: Typed",
26
26
  ]
27
27
  dynamic = [ "readme", "version" ]
28
- dependencies = [ "packaging", "sphinx>=8.1" ]
28
+ dependencies = [ "packaging", "sphinx>=9.1" ]
29
29
  # The extension stack of `scverse_doc.config`.
30
30
  optional-dependencies.config = [
31
31
  "myst-nb>=1.1",
@@ -34,7 +34,8 @@ optional-dependencies.config = [
34
34
  "sphinxext-opengraph",
35
35
  ]
36
36
  # Everything, as the `scverse_doc` extension needs.
37
- optional-dependencies.full = [ "scverse-doc[config,theme]" ]
37
+ optional-dependencies.full = [ "scverse-doc[config,math-core,theme]" ]
38
+ optional-dependencies.math-core = [ "math-core" ]
38
39
  # `html_theme = "scverse"`, i.e. `scverse_doc.theme`.
39
40
  optional-dependencies.theme = [ "pydata-sphinx-theme>=0.23" ]
40
41
  # https://docs.pypi.org/project_metadata/#project-urls
@@ -50,18 +51,21 @@ dev = [
50
51
  "twine>=4.0.2",
51
52
  ]
52
53
  test = [
53
- "coloraide", # to check the accent lightness bounds
54
+ "coloraide", # to check the accent lightness bounds
54
55
  "coverage>=7.10",
55
- "defusedxml", # for sphinx.testing’s HTML assertions
56
+ "defusedxml", # for sphinx.testing’s HTML assertions
57
+ "lightningcss-cli", # to rebuild the theme’s stylesheet bundles
56
58
  "pytest",
57
- "pytest-cov", # For VS Code’s coverage functionality
58
- "wenmode", # for scripts/check_changelog.py
59
+ "pytest-cov", # For VS Code’s coverage functionality
60
+ "wenmode", # for scripts/check_changelog.py
59
61
  ]
60
62
  doc = [
61
63
  "ipykernel",
62
64
  "ipython",
65
+ "lightningcss-cli", # to rebuild the theme’s stylesheet bundles
63
66
  "scverse-misc[sphinx]>=0.1.2",
64
67
  "sphinx-autodoc-typehints",
68
+ "sphinx-toolbox>=4.3.1", # `rest-example` directive
65
69
  "sphinxcontrib-bibtex>=1",
66
70
  ]
67
71
  typecheck = [ "mypy", "types-docutils", "wenmode" ] # wenmode for scripts/check_changelog.py
@@ -72,6 +76,10 @@ metadata.hooks.fancy-pypi-readme.content-type = "text/markdown"
72
76
  metadata.hooks.fancy-pypi-readme.fragments = [
73
77
  { path = "README.md", start-after = "<!-- badges-end -->\n" },
74
78
  ]
79
+ build.targets.wheel.exclude = [ "/src/scverse_doc/theme/scverse/static/styles/" ]
80
+ build.targets.wheel.artifacts = [ "/src/scverse_doc/theme/scverse/static/styles/*.min.css*" ]
81
+ # Builds `styles/*.min.css`, which replace the stylesheet sources in wheels, see `hatch_build.py`.
82
+ build.targets.wheel.hooks.custom = {}
75
83
  build.targets.sdist.exclude = [ "/docs", "/tests" ]
76
84
  envs.default.installer = "uv"
77
85
  envs.default.dependency-groups = [ "dev" ]
@@ -85,7 +93,7 @@ envs.hatch-check-code.scripts.lint-check = "echo 'try `hatch check code --fix`';
85
93
  envs.hatch-check-code.scripts.lint-fix = "prek run -a --no-group=format --no-group=typecheck"
86
94
  envs.hatch-check-fmt.dependencies = [ "prek" ]
87
95
  envs.hatch-check-fmt.scripts.format-check = "echo 'try `hatch check fmt --fix`'; false"
88
- envs.hatch-check-fmt.scripts.format-fix = "prek run -a --group=format --no-group=typecheck"
96
+ envs.hatch-check-fmt.scripts.format-fix = "prek run -a --group=format"
89
97
  envs.hatch-check-types.features = [ "full" ]
90
98
  envs.hatch-check-types.scripts.check = [ "mypy" ]
91
99
  envs.hatch-check-types.dependency-groups = [ "typecheck", "doc", "test" ]
@@ -4,7 +4,7 @@
4
4
  # requires-python = ">=3.12"
5
5
  # dependencies = []
6
6
  # ///
7
- """Refresh the generated brand assets from the scverse website.
7
+ """Refresh the files generated or copied from upstream: the scverse website and math-core.
8
8
 
9
9
  The website is the brand’s source of truth,
10
10
  so transcribing its colours into this repository by hand
@@ -20,9 +20,11 @@ Only the region between the marker comments is touched; the rest of the file is
20
20
  The scverse logo used for the navbar link back to the website is copied verbatim for the same reason,
21
21
  as is ``accents.json``, which the registry reads the package accents from.
22
22
 
23
+ math-core’s stylesheet fixing browsers’ MathML rendering is copied verbatim from its repository.
24
+
23
25
  Usage
24
26
  -----
25
- uv run scripts/sync_brand_tokens.py --website ../scverse.github.io
27
+ uv run scripts/sync_upstream.py --website ../scverse.github.io --math-core ../math-core
26
28
  """
27
29
 
28
30
  from __future__ import annotations
@@ -35,7 +37,7 @@ from pathlib import Path
35
37
 
36
38
  HERE = Path(__file__).parent
37
39
  STATIC = HERE.parent / "src" / "scverse_doc" / "theme" / "scverse" / "static"
38
- TARGET = STATIC / "_tokens.css"
40
+ TARGET = STATIC / "styles" / "_tokens.css"
39
41
 
40
42
  #: Website file -> package file, copied verbatim.
41
43
  ASSETS = {
@@ -43,6 +45,11 @@ ASSETS = {
43
45
  Path("assets/accents.json"): HERE.parent / "src" / "scverse_doc" / "_accents.json",
44
46
  }
45
47
 
48
+ #: math-core file -> package file, copied verbatim.
49
+ MATH_CORE_ASSETS = {
50
+ Path("css/mathmlfixes.css"): HERE.parent / "src" / "scverse_doc" / "static" / "mathmlfixes.css",
51
+ }
52
+
46
53
  #: CSS custom property emitted here -> website custom property it is resolved from.
47
54
  #: The pairing mirrors the one scverse/scverse.github.io#329 used when replacing its SCSS variables.
48
55
  TOKEN_MAP = {
@@ -66,7 +73,7 @@ ACCENT_TOKEN_MAP = {
66
73
  "--scverse-color-gradient-end": ("scverse", "sky-blue"),
67
74
  }
68
75
 
69
- BEGIN = "/* BEGIN GENERATED BRAND TOKENS – DO NOT EDIT; regenerate with scripts/sync_brand_tokens.py */"
76
+ BEGIN = "/* BEGIN GENERATED BRAND TOKENS – DO NOT EDIT; regenerate with scripts/sync_upstream.py */"
70
77
  END = "/* END GENERATED BRAND TOKENS */"
71
78
 
72
79
  #: The fenced region, captured together with the indentation of its opening marker.
@@ -114,6 +121,7 @@ def main() -> int:
114
121
  """Write the refreshed token stylesheet to disk."""
115
122
  parser = argparse.ArgumentParser(description=__doc__)
116
123
  parser.add_argument("--website", type=Path, required=True, help="checkout of scverse/scverse.github.io")
124
+ parser.add_argument("--math-core", type=Path, required=True, help="checkout of tmke8/math-core")
117
125
  parser.add_argument("--check", action="store_true", help="fail instead of writing if the output would change")
118
126
  args = parser.parse_args()
119
127
 
@@ -122,10 +130,11 @@ def main() -> int:
122
130
  updates = {
123
131
  TARGET: render(props, accents, TARGET.read_text()).encode(),
124
132
  **{dst: (args.website / src).read_bytes() for src, dst in ASSETS.items()},
133
+ **{dst: (args.math_core / src).read_bytes() for src, dst in MATH_CORE_ASSETS.items()},
125
134
  }
126
135
  if args.check:
127
136
  if outdated := [str(dst) for dst, new in updates.items() if not dst.is_file() or dst.read_bytes() != new]:
128
- print(f"{', '.join(outdated)} out of date; rerun scripts/sync_brand_tokens.py", file=sys.stderr)
137
+ print(f"{', '.join(outdated)} out of date; rerun scripts/sync_upstream.py", file=sys.stderr)
129
138
  return 1
130
139
  return 0
131
140
  for dst, new in updates.items():
@@ -16,6 +16,8 @@ each of which also works on its own:
16
16
  The layout of the API pages.
17
17
  :mod:`scverse_doc.config`
18
18
  The extension stack and the shared defaults.
19
+ :mod:`scverse_doc.math_core`
20
+ Math rendered to MathML at build time, via math-core.
19
21
  :mod:`scverse_doc.napoleon`
20
22
  Prose return sections in NumPy-style docstrings.
21
23
  :mod:`scverse_doc.registry`
@@ -40,7 +42,7 @@ from typing import TYPE_CHECKING
40
42
 
41
43
  from sphinx.util.typing import ExtensionMetadata
42
44
 
43
- from . import autodoc, config, napoleon, registry, release_notes, source, theme, typed_fields, xref_overrides
45
+ from . import autodoc, config, math_core, napoleon, registry, release_notes, source, theme, typed_fields, xref_overrides
44
46
  from .config import _is_set_by_user
45
47
 
46
48
  if TYPE_CHECKING:
@@ -50,6 +52,7 @@ if TYPE_CHECKING:
50
52
  __all__ = [
51
53
  "autodoc",
52
54
  "config",
55
+ "math_core",
53
56
  "napoleon",
54
57
  "registry",
55
58
  "release_notes",
@@ -0,0 +1,48 @@
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": [
11
+ ["violet", [0.72, 0.112, 279]],
12
+ ["yellow", [0.876, 0.169, 91.5]]
13
+ ],
14
+ "scirpy": [
15
+ ["purple", [0.601, 0.209, 358.5]],
16
+ ["orange", [0.7824, 0.156, 69]]
17
+ ],
18
+ "pertpy": [
19
+ ["blue", [0.5, 0.1, 249]],
20
+ ["red", [0.595, 0.177, 14]]
21
+ ],
22
+ "rapids-singlecell": [
23
+ ["green", [0.713, 0.194, 130.8]],
24
+ ["violet", [0.518, 0.293, 290.0]]
25
+ ],
26
+ "mantispy": [
27
+ ["teal", [0.568, 0.091, 197.8]],
28
+ ["orange", [0.686, 0.188, 47.4]]
29
+ ],
30
+ "liana": [
31
+ ["crimson", [0.517, 0.193, 6.0]],
32
+ ["turquoise", [0.899, 0.158, 184.3]]
33
+ ],
34
+ "cellrank": [
35
+ ["navy", [0.36, 0.14, 265.9]],
36
+ ["blue", [0.63, 0.186, 260.2]]
37
+ ],
38
+ "pydeseq2": [
39
+ ["green", [0.676, 0.189, 145.9]],
40
+ ["dark-green", [0.521, 0.17, 143.3]]
41
+ ],
42
+ "scvi-tools": [["yellow", [0.824, 0.1634, 81]]],
43
+ "scverse": [
44
+ ["deep-blue", [0.405, 0.205, 270]],
45
+ ["sky-blue", [0.799, 0.108, 236]],
46
+ ["gold", [0.758, 0.2, 92]]
47
+ ]
48
+ }
@@ -0,0 +1,117 @@
1
+ # SPDX-License-Identifier: MPL-2.0
2
+ r"""Math rendering via ``math-core``.
3
+
4
+ Browsers support MathML today,
5
+ so math-core_ is the most lightweight way to render math on the web.
6
+
7
+ Examples
8
+ --------
9
+ Inline math, and a block equation referenced via its ``:label:``:
10
+
11
+ .. rest-example::
12
+
13
+ :math:`e^{i\pi} = -1`, see :eq:`math-example`.
14
+
15
+ .. math::
16
+ :label: math-example
17
+
18
+ \operatorname{AA}(c_\text{fg}, c_\text{bg}) \geq 4.5
19
+
20
+ Equations separated by blank lines, or rows separated by ``\\``, are aligned at ``&``:
21
+
22
+ .. rest-example::
23
+
24
+ .. math::
25
+
26
+ a &= b + c
27
+
28
+ d &= e
29
+
30
+ ``:no-wrap:`` passes the LaTeX as is, e.g. for your own environment:
31
+
32
+ .. rest-example::
33
+
34
+ .. math::
35
+ :no-wrap:
36
+
37
+ \begin{cases} 1 & x > 0 \\ 0 & \text{otherwise} \end{cases}
38
+
39
+ Configure the converter, e.g. with your own macros, via :confval:`math_core_options`.
40
+ math-core’s ``mathmlfixes.css`` is included, mainly to fix Chromium’s rendering.
41
+
42
+ .. _math-core: https://github.com/tmke8/math-core
43
+ """
44
+
45
+ from pathlib import Path
46
+
47
+ from docutils import nodes
48
+ from sphinx.application import Sphinx
49
+ from sphinx.config import Config
50
+ from sphinx.locale import _
51
+ from sphinx.util import logging
52
+ from sphinx.util.math import get_node_equation_number
53
+ from sphinx.util.typing import ExtensionMetadata
54
+ from sphinx.writers.html5 import HTML5Translator
55
+
56
+ logger = logging.getLogger(__name__)
57
+
58
+
59
+ class _MathVisitor:
60
+ def configure(self, app: Sphinx, config: Config) -> None:
61
+ """Create the converters from :confval:`math_core_options`."""
62
+ from math_core import LatexToMathML
63
+
64
+ self.converter = LatexToMathML(**config.math_core_options)
65
+ self.fallback = LatexToMathML(**{**config.math_core_options, "continue_on_error": True})
66
+
67
+ def visit(self, renderer: HTML5Translator, node: nodes.math | nodes.math_block):
68
+ """Handles inline math `` :math:`…` `` and block math ``.. math:: …``."""
69
+ from math_core import LatexError
70
+
71
+ tex = node.astext()
72
+ if display_style := isinstance(node, nodes.math_block):
73
+ # `starttag` sets expected `id` for `:eq:` references; markup mirrors `sphinx.ext.mathjax`
74
+ renderer.body.append(renderer.starttag(node, "div", CLASS="math"))
75
+ if node["number"]:
76
+ renderer.body.append(f'<span class="eqno">({get_node_equation_number(renderer, node)})')
77
+ renderer.add_permalink_ref(node, _("Link to this equation"))
78
+ renderer.body.append("</span>")
79
+ if not node.get("no-wrap", node.get("nowrap", False)):
80
+ tex = _wrap(tex)
81
+ try:
82
+ out = self.converter.convert_all([(tex, display_style)])
83
+ except LatexError as e:
84
+ logger.warning("LaTeX error:%s", e, location=node)
85
+ out = self.fallback.convert_all([(tex, display_style)])
86
+ renderer.body.extend(out)
87
+ if display_style:
88
+ renderer.body.append("</div>\n")
89
+ raise nodes.SkipNode
90
+
91
+
92
+ def _wrap(tex: str) -> str:
93
+ """Align multiple equations or rows, like `sphinx.ext.mathjax`."""
94
+ # uses ``aligned``, as math-core lacks ``split``:
95
+ # https://github.com/tmke8/math-core/issues/154
96
+ # TODO: once split exists, we should use Sphinx’ `wrap_displaymath` instead of this
97
+ parts = [part.strip() for part in tex.split("\n\n") if part.strip()]
98
+ if len(parts) == 1 and r"\\" not in parts[0]:
99
+ return parts[0]
100
+ return r"\begin{aligned}" + r"\\".join(parts) + r"\end{aligned}"
101
+
102
+
103
+ # `mathmlfixes.css` is synced from math-core by `scripts/sync_upstream.py`
104
+ _STATIC = Path(__file__).with_name("static")
105
+
106
+
107
+ def setup(app: Sphinx):
108
+ """Register the custom math-core HTML renderer."""
109
+ visitor = _MathVisitor()
110
+ # we raise SkipNode, so no need for depart (the `None`s)
111
+ app.add_html_math_renderer("mathcore", (visitor.visit, None), (visitor.visit, None))
112
+ app.add_config_value("math_core_options", {}, "env", types=frozenset({dict}))
113
+ app.connect("config-inited", visitor.configure)
114
+ app.add_static_dir(_STATIC)
115
+ app.add_css_file("mathmlfixes.css")
116
+ app.add_css_file("math_core.css")
117
+ return ExtensionMetadata(parallel_read_safe=True)
@@ -55,10 +55,10 @@ def _build_cache(app: Sphinx) -> Path:
55
55
  return _cache_dir
56
56
 
57
57
 
58
- #: Brand accents from the website, copied by ``scripts/sync_brand_tokens.py``:
58
+ #: Brand accents from the website, copied by ``scripts/sync_upstream.py``:
59
59
  #: each key lists ``[name, [L, C, H]]`` pairs, primary first.
60
60
  _ACCENTS: dict[str, list[str]] = {
61
- {"scvi": "scvi-tools"}.get(pkg, pkg): ["oklch({} {} {})".format(*lch) for _, lch in colors]
61
+ pkg: ["oklch({} {} {})".format(*lch) for _, lch in colors]
62
62
  for pkg, colors in json.loads(files(__package__).joinpath("_accents.json").read_text()).items()
63
63
  }
64
64
 
@@ -0,0 +1,13 @@
1
+ /* SPDX-License-Identifier: MPL-2.0 */
2
+ /* LaTeX that math-core couldn’t convert: the source, with the error as tooltip */
3
+ .math-core-error {
4
+ color: var(--pst-color-danger, #d32f2f);
5
+ text-decoration: underline wavy;
6
+ cursor: help;
7
+ }
8
+
9
+ /* pydata-sphinx-theme lays out `div.math` as a reversed flex row and only grows MathJax’s container */
10
+ div.math > :not(.eqno) {
11
+ flex-grow: 1;
12
+ overflow: auto hidden;
13
+ }