Skip to content

Commit d510e96

Browse files
timtreisclaude
andcommitted
Sync tooling and docs with cookiecutter-scverse v0.7.0 (phase 2+3)
- Switch from optional-dependencies to dependency-groups (PEP 735) - Add hatch environments (default, docs, hatch-test matrix) - Add build.yaml CI workflow (uv build + twine check) - Replace prettier with biome, add pyproject-fmt and pre-commit-hooks - Switch docs from mathjax to KaTeX, add sphinx-tabs and opengraph - Update .readthedocs.yaml to use hatch docs:build - Rewrite contributing.md with hatch/uv/pip tabs, keep plot-testing guide - Add [tool.cruft] skip list for future template syncs - Keep pixi config, html_logo, full intersphinx mappings, nitpicky=False Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5da843a commit d510e96

9 files changed

Lines changed: 562 additions & 198 deletions

File tree

.github/workflows/build.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
package:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
with:
19+
filter: blob:none
20+
fetch-depth: 0
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
- name: Build package
24+
run: uv build
25+
- name: Check package
26+
run: uvx twine check --strict dist/*.whl

.pre-commit-config.yaml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,36 @@ default_stages:
55
- pre-commit
66
- pre-push
77
minimum_pre_commit_version: 2.16.0
8-
ci:
9-
skip: []
108
repos:
11-
- repo: https://github.com/rbubley/mirrors-prettier
12-
rev: v3.8.1
9+
- repo: https://github.com/biomejs/pre-commit
10+
rev: v2.3.10
1311
hooks:
14-
- id: prettier
12+
- id: biome-format
13+
exclude: ^\.cruft\.json$ # inconsistent indentation with cruft
14+
- repo: https://github.com/tox-dev/pyproject-fmt
15+
rev: v2.11.1
16+
hooks:
17+
- id: pyproject-fmt
1518
- repo: https://github.com/astral-sh/ruff-pre-commit
1619
rev: v0.15.5
1720
hooks:
18-
- id: ruff
21+
- id: ruff-check
22+
types_or: [python, pyi, jupyter]
1923
args: [--fix, --exit-non-zero-on-fix]
2024
- id: ruff-format
25+
types_or: [python, pyi, jupyter]
26+
- repo: https://github.com/pre-commit/pre-commit-hooks
27+
rev: v6.0.0
28+
hooks:
29+
- id: detect-private-key
30+
- id: check-ast
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
args: [--fix=lf]
34+
- id: trailing-whitespace
35+
- id: check-case-conflict
36+
- id: check-merge-conflict
37+
args: [--assume-in-merge]
2138
- repo: https://github.com/pre-commit/mirrors-mypy
2239
rev: v1.19.1
2340
hooks:

.readthedocs.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
# https://docs.readthedocs.io/en/stable/config-file/v2.html
12
version: 2
23
build:
34
os: ubuntu-24.04
45
tools:
5-
python: "3.12"
6-
commands:
7-
- asdf plugin add uv
8-
- asdf install uv latest
9-
- asdf global uv latest
10-
- uv venv
11-
- uv pip install .[docs,pre]
12-
- .venv/bin/python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
13-
sphinx:
14-
configuration: docs/conf.py
15-
fail_on_warning: false
6+
python: "3.13"
7+
nodejs: latest
8+
jobs:
9+
create_environment:
10+
- asdf plugin add uv
11+
- asdf install uv latest
12+
- asdf global uv latest
13+
build:
14+
html:
15+
- uvx hatch run docs:build
16+
- mv docs/_build $READTHEDOCS_OUTPUT

.vscode/extensions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
// Linting and formatting
1414
"editorconfig.editorconfig",
1515
"charliermarsh.ruff",
16-
"biomejs.biome"
17-
]
16+
"biomejs.biome",
17+
],
1818
}

.vscode/launch.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"args": ["-M", "html", ".", "_build"],
1313
"cwd": "${workspaceFolder}/docs",
1414
"console": "internalConsole",
15-
"justMyCode": false
15+
"justMyCode": false,
1616
},
1717
{
1818
"name": "Python: Debug Test",
@@ -23,11 +23,11 @@
2323
"console": "internalConsole",
2424
"justMyCode": false,
2525
"env": {
26-
"PYTEST_ADDOPTS": "--color=yes"
26+
"PYTEST_ADDOPTS": "--color=yes",
2727
},
2828
"presentation": {
29-
"hidden": true
30-
}
31-
}
32-
]
29+
"hidden": true,
30+
},
31+
},
32+
],
3333
}

.vscode/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"[python][json][jsonc]": {
3-
"editor.formatOnSave": true
3+
"editor.formatOnSave": true,
44
},
55
"[python]": {
66
"editor.defaultFormatter": "charliermarsh.ruff",
77
"editor.codeActionsOnSave": {
88
"source.fixAll": "always",
9-
"source.organizeImports": "always"
10-
}
9+
"source.organizeImports": "always",
10+
},
1111
},
1212
"[json][jsonc]": {
13-
"editor.defaultFormatter": "biomejs.biome"
13+
"editor.defaultFormatter": "biomejs.biome",
1414
},
1515
"python.analysis.typeCheckingMode": "basic",
1616
"python.testing.pytestEnabled": true,
17-
"python.testing.pytestArgs": ["-vv", "--color=yes"]
17+
"python.testing.pytestArgs": ["-vv", "--color=yes"],
1818
}

docs/conf.py

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
# -- Path setup --------------------------------------------------------------
8+
import shutil
89
import sys
910
from datetime import datetime
1011
from importlib.metadata import metadata
1112
from pathlib import Path
1213

14+
from sphinxcontrib import katex
15+
1316
HERE = Path(__file__).parent
1417
sys.path.insert(0, str(HERE / "extensions"))
1518

@@ -19,13 +22,12 @@
1922
# NOTE: If you installed your project in editable mode, this might be stale.
2023
# If this is the case, reinstall it to refresh the metadata
2124
info = metadata("spatialdata-plot")
22-
project_name = info["Name"]
25+
project = info["Name"]
2326
author = info["Author"]
24-
copyright = f"{datetime.now():%Y}, {author}"
27+
copyright = f"{datetime.now():%Y}, {author}."
2528
version = info["Version"]
26-
27-
# repository_url = f"https://github.com/scverse/{project_name}"
28-
29+
urls = dict(pu.split(", ") for pu in info.get_all("Project-URL"))
30+
repository_url = urls["Source"]
2931

3032
# The full version, including alpha/beta/rc tags
3133
release = info["Version"]
@@ -38,7 +40,7 @@
3840
html_context = {
3941
"display_github": True, # Integrate GitHub
4042
"github_user": "scverse",
41-
"github_repo": "https://github.com/scverse/spatialdata-plot",
43+
"github_repo": project,
4244
"github_version": "main",
4345
"conf_py_path": "/docs/",
4446
}
@@ -55,23 +57,23 @@
5557
"sphinx.ext.autosummary",
5658
"sphinx.ext.napoleon",
5759
"sphinxcontrib.bibtex",
60+
"sphinxcontrib.katex",
5861
"sphinx_autodoc_typehints",
59-
"sphinx.ext.mathjax",
62+
"sphinx_tabs.tabs",
6063
"IPython.sphinxext.ipython_console_highlighting",
61-
"sphinx_design",
64+
"sphinxext.opengraph",
6265
*[p.stem for p in (HERE / "extensions").glob("*.py")],
6366
]
6467

6568
autosummary_generate = True
66-
autodoc_process_signature = True
6769
autodoc_member_order = "groupwise"
6870
default_role = "literal"
6971
napoleon_google_docstring = False
7072
napoleon_numpy_docstring = True
7173
napoleon_include_init_with_doc = False
7274
napoleon_use_rtype = True # having a separate entry generally helps readability
7375
napoleon_use_param = True
74-
myst_heading_anchors = 3 # create anchors for h1-h3
76+
myst_heading_anchors = 6 # create anchors for h1-h6
7577
myst_enable_extensions = [
7678
"amsmath",
7779
"colon_fence",
@@ -93,7 +95,9 @@
9395
}
9496

9597
intersphinx_mapping = {
98+
"python": ("https://docs.python.org/3.13", None),
9699
"anndata": ("https://anndata.readthedocs.io/en/stable/", None),
100+
"scanpy": ("https://scanpy.readthedocs.io/en/stable/", None),
97101
"numpy": ("https://numpy.org/doc/stable/", None),
98102
"geopandas": ("https://geopandas.org/en/stable/", None),
99103
"xarray": ("https://docs.xarray.dev/en/stable/", None),
@@ -108,18 +112,13 @@
108112
exclude_patterns = [
109113
"_build",
110114
"Thumbs.db",
115+
".DS_Store",
111116
"**.ipynb_checkpoints",
112117
"tutorials/notebooks/index.md",
113118
"tutorials/notebooks/README.md",
114119
"tutorials/notebooks/references.md",
115120
"tutorials/notebooks/notebooks/paper_reproducibility/*",
116121
]
117-
# Ignore warnings.
118-
nitpicky = False # TODO: solve upstream.
119-
# nitpick_ignore = [
120-
# ("py:class", "spatial_image.SpatialImage"),
121-
# ("py:class", "multiscale_spatial_image.multiscale_spatial_image.MultiscaleSpatialImage"),
122-
# ]
123122

124123

125124
# -- Options for HTML output -------------------------------------------------
@@ -128,36 +127,26 @@
128127
# a list of builtin themes.
129128
#
130129
html_theme = "sphinx_book_theme"
131-
# html_theme = "sphinx_rtd_theme"
132130
html_static_path = ["_static"]
133-
html_title = project_name
131+
html_css_files = ["css/custom.css"]
132+
html_title = project
134133
html_logo = "_static/img/spatialdata_horizontal.png"
135134

136-
# html_theme_options = {
137-
# "repository_url": repository_url,
138-
# "use_repository_button": True,
139-
# }
135+
html_theme_options = {
136+
"repository_url": repository_url,
137+
"use_repository_button": True,
138+
"path_to_docs": "docs/",
139+
"navigation_with_keys": False,
140+
}
140141

141142
pygments_style = "default"
143+
katex_prerender = shutil.which(katex.NODEJS_BINARY) is not None
144+
145+
# Ignore warnings.
146+
nitpicky = False # TODO: solve upstream.
142147

143148
nitpick_ignore = [
144149
# If building the documentation fails because of a missing link that is outside your control,
145150
# you can add an exception to this list.
146151
("py:class", "igraph.Graph"),
147152
]
148-
149-
150-
def setup(app):
151-
"""App setup hook."""
152-
app.add_config_value(
153-
"recommonmark_config",
154-
{
155-
"auto_toc_tree_section": "Contents",
156-
"enable_auto_toc_tree": True,
157-
"enable_math": True,
158-
"enable_inline_math": False,
159-
"enable_eval_rst": True,
160-
},
161-
True,
162-
)
163-
app.add_css_file("css/custom.css")

0 commit comments

Comments
 (0)