scverse-doc 0.2.0__tar.gz → 0.2.2__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.2/.github/workflows/pr.yaml +19 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/CHANGELOG.md +15 -3
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/PKG-INFO +1 -1
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/pyproject.toml +5 -1
- scverse_doc-0.2.2/scripts/check_changelog.py +144 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/autodoc/__init__.py +11 -5
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/config.py +2 -2
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/registry.py +14 -3
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/source.py +6 -6
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/__init__.py +3 -3
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/static/styles/scverse.css +18 -6
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/typed_fields.py +9 -3
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/xref_overrides.py +2 -3
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.codecov.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.cruft.json +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.editorconfig +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/dependabot.yml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/workflows/autofix.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/workflows/build.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/workflows/release.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/workflows/sync.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.github/workflows/test.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.gitignore +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.pre-commit-config.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.readthedocs.yaml +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.vscode/extensions.json +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.vscode/launch.json +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/.vscode/settings.json +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/LICENSE +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/README.md +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/biome.jsonc +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/scripts/sync_brand_tokens.py +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/__init__.py +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/_accents.json +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/_color.py +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/autodoc/templates/autosummary/class.rst +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/autodoc/templates/autosummary/module.rst +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/napoleon.py +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/py.typed +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/release_notes.py +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/scverse-ecosystem.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/scverse-footer.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/scverse-sidebar-nav.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/sidebar-versions.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/toggle-primary-sidebar.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/components/toggle-secondary-sidebar.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/layout.html +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/static/_tokens.css +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/static/scripts/readthedocs-integration.js +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/static/scverse-fa.svg +0 -0
- {scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/theme.toml +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: PR
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [opened, synchronize, reopened, edited]
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
jobs:
|
|
8
|
+
check-changelog:
|
|
9
|
+
name: Check changelog
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
13
|
+
with:
|
|
14
|
+
persist-credentials: false
|
|
15
|
+
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
|
|
16
|
+
- run: uv run scripts/check_changelog.py --pr="$PR" --title="$TITLE"
|
|
17
|
+
env:
|
|
18
|
+
PR: ${{ github.event.pull_request.number }}
|
|
19
|
+
TITLE: ${{ github.event.pull_request.title }}
|
|
@@ -10,11 +10,22 @@ and this project adheres to [Semantic Versioning][].
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- run the private-base-skipping code on the real class names in more cases (#66)
|
|
16
|
+
- make logo and search button fill sidebar (#67)
|
|
17
|
+
|
|
18
|
+
## [0.2.1]
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Hiding private base classes no longer crashes when a base is a string or has no `__name__` (#63)
|
|
23
|
+
|
|
13
24
|
## [0.2.0]
|
|
14
25
|
|
|
15
26
|
### Added
|
|
16
27
|
|
|
17
|
-
- Annotate prose return sections’ items with the members of a returned tuple
|
|
28
|
+
- Annotate prose return sections’ items with the members of a returned tuple (#56)
|
|
18
29
|
- `release-notes` directive, ported from `scanpydoc` (#51)
|
|
19
30
|
- Parameters and attributes as definition lists, ported from `scanpydoc`’s `definition_list_typed_field` (#54)
|
|
20
31
|
- `xref_overrides`, ported from `scanpydoc`’s `qualname_overrides`, also for Sphinx’ own annotations, and reporting unused entries (#53)
|
|
@@ -23,7 +34,7 @@ and this project adheres to [Semantic Versioning][].
|
|
|
23
34
|
|
|
24
35
|
### Fixed
|
|
25
36
|
|
|
26
|
-
- Handle attributes
|
|
37
|
+
- Handle attributes, i.e annotated fields on classes (#47)
|
|
27
38
|
|
|
28
39
|
## [0.1.0]
|
|
29
40
|
|
|
@@ -35,7 +46,8 @@ and this project adheres to [Semantic Versioning][].
|
|
|
35
46
|
- Read the Docs integration: version selector and search, both with dark mode
|
|
36
47
|
- Autodoc, prose, and confval rendering extensions (from scverse-misc)
|
|
37
48
|
|
|
38
|
-
[Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.2.
|
|
49
|
+
[Unreleased]: https://github.com/scverse/scverse-doc/compare/v0.2.1...main
|
|
50
|
+
[0.2.1]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.1
|
|
39
51
|
[0.2.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.2.0
|
|
40
52
|
[0.1.1]: https://github.com/scverse/scverse-doc/releases/tag/v0.1.1
|
|
41
53
|
[0.1.0]: https://github.com/scverse/scverse-doc/releases/tag/v0.1.0
|
|
@@ -54,6 +54,7 @@ test = [
|
|
|
54
54
|
"defusedxml", # for sphinx.testing’s HTML assertions
|
|
55
55
|
"pytest",
|
|
56
56
|
"pytest-cov", # For VS Code’s coverage functionality
|
|
57
|
+
"wenmode", # for scripts/check_changelog.py
|
|
57
58
|
]
|
|
58
59
|
doc = [
|
|
59
60
|
"ipykernel",
|
|
@@ -62,7 +63,7 @@ doc = [
|
|
|
62
63
|
"sphinx-autodoc-typehints",
|
|
63
64
|
"sphinxcontrib-bibtex>=1",
|
|
64
65
|
]
|
|
65
|
-
typecheck = [ "mypy", "types-docutils" ]
|
|
66
|
+
typecheck = [ "mypy", "types-docutils", "wenmode" ] # wenmode for scripts/check_changelog.py
|
|
66
67
|
|
|
67
68
|
[tool.hatch]
|
|
68
69
|
version.source = "vcs"
|
|
@@ -159,6 +160,8 @@ lint.pydocstyle.convention = "numpy"
|
|
|
159
160
|
files = [ "docs", "scripts", "src", "tests" ]
|
|
160
161
|
# Fixture conf.py files all share the module name "conf".
|
|
161
162
|
exclude = [ "tests/roots/" ]
|
|
163
|
+
disallow_any_explicit = true
|
|
164
|
+
disallow_any_generics = true
|
|
162
165
|
|
|
163
166
|
[tool.pytest]
|
|
164
167
|
addopts = [
|
|
@@ -172,6 +175,7 @@ filterwarnings = [
|
|
|
172
175
|
"ignore:The mapping interface for autodoc options:sphinx.deprecation.RemovedInSphinx11Warning",
|
|
173
176
|
"ignore::sphinx.deprecation.RemovedInSphinx11Warning:myst_parser",
|
|
174
177
|
]
|
|
178
|
+
pythonpath = [ "scripts" ]
|
|
175
179
|
strict = true
|
|
176
180
|
testpaths = [ "tests", "src" ]
|
|
177
181
|
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
# /// script
|
|
4
|
+
# requires-python = ">=3.12"
|
|
5
|
+
# dependencies = ["wenmode"]
|
|
6
|
+
# ///
|
|
7
|
+
"""Check that a PR’s changelog entry is in the section its conventional-commit title implies.
|
|
8
|
+
|
|
9
|
+
The entry is a list item under `## [Unreleased]` › `### <Section>` that ends with the PR number,
|
|
10
|
+
e.g. `- Some fix (#67)`.
|
|
11
|
+
PR titles with types that don’t map to a section (`ci:`, `docs:`, …) need no entry,
|
|
12
|
+
but every PR needs the changelog to keep its `## [Unreleased]` section,
|
|
13
|
+
and every `##` heading to be a link with a definition, e.g. `[0.1.0]: https://…`.
|
|
14
|
+
|
|
15
|
+
Usage
|
|
16
|
+
-----
|
|
17
|
+
uv run scripts/check_changelog.py --pr 67 --title 'fix: make logo fill sidebar'
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import re
|
|
23
|
+
from argparse import ArgumentParser
|
|
24
|
+
from dataclasses import dataclass, field
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from typing import TYPE_CHECKING
|
|
27
|
+
|
|
28
|
+
from wenmode import Wenmode
|
|
29
|
+
from wenmode.nodes import Heading, Link, List, ListItem, Literal, Paragraph, Parent, Text
|
|
30
|
+
|
|
31
|
+
if TYPE_CHECKING:
|
|
32
|
+
from wenmode.nodes import Node
|
|
33
|
+
|
|
34
|
+
SECTIONS = {"feat": "Added", "fix": "Fixed", "perf": "Changed"}
|
|
35
|
+
UNRELEASED = "Unreleased"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ChangelogError(SystemExit):
|
|
39
|
+
"""A problem with the changelog, exiting with a GitHub error annotation when uncaught."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, msg: str, *, file: Path, line: int | None = None) -> None:
|
|
42
|
+
self.msg = msg
|
|
43
|
+
self.line = line
|
|
44
|
+
loc = f"file={file}{f',line={line}' if line else ''}"
|
|
45
|
+
super().__init__(f"::error {loc}::{msg}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class Entry:
|
|
50
|
+
"""A changelog list item."""
|
|
51
|
+
|
|
52
|
+
line: int
|
|
53
|
+
pr: int | None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class Changelog:
|
|
58
|
+
"""A parsed changelog: version › section › entries."""
|
|
59
|
+
|
|
60
|
+
path: Path
|
|
61
|
+
versions: dict[str, dict[str, list[Entry]]] = field(default_factory=dict)
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def parse(cls, path: Path) -> Changelog:
|
|
65
|
+
"""Parse the changelog, raising :class:`ChangelogError` if it is malformed."""
|
|
66
|
+
text = path.read_text()
|
|
67
|
+
changelog = cls(path)
|
|
68
|
+
sections: dict[str, list[Entry]] | None = None
|
|
69
|
+
entries: list[Entry] | None = None
|
|
70
|
+
for node in Wenmode(positions=True).parse(text).children:
|
|
71
|
+
match node:
|
|
72
|
+
case Heading(depth=2, children=[Link() as link]):
|
|
73
|
+
sections = changelog.versions.setdefault(_text(link), {})
|
|
74
|
+
entries = None
|
|
75
|
+
case Heading(depth=2):
|
|
76
|
+
msg = f"“## {_text(node)}” isn’t a link; add a “[<version>]: <url>” definition"
|
|
77
|
+
raise ChangelogError(msg, file=path, line=_line(text, node))
|
|
78
|
+
case Heading(depth=3) if sections is not None:
|
|
79
|
+
entries = sections.setdefault(_text(node), [])
|
|
80
|
+
case List(children=items) if entries is not None:
|
|
81
|
+
entries.extend(_parse_entry(text, path, item) for item in items)
|
|
82
|
+
if UNRELEASED not in changelog.versions:
|
|
83
|
+
raise ChangelogError("No “## [Unreleased]” section", file=path)
|
|
84
|
+
return changelog
|
|
85
|
+
|
|
86
|
+
def check(self, pr: int, title: str) -> None:
|
|
87
|
+
"""Raise :class:`ChangelogError` unless the entry for `pr` is in the section `title` implies."""
|
|
88
|
+
if not (m := re.match(r"(\w+)(?:\([^)]*\))?!?:", title)) or not (want := SECTIONS.get(m[1])):
|
|
89
|
+
return
|
|
90
|
+
found = [
|
|
91
|
+
(entry, version, section)
|
|
92
|
+
for version, sections in self.versions.items()
|
|
93
|
+
for section, entries in sections.items()
|
|
94
|
+
for entry in entries
|
|
95
|
+
if entry.pr == pr
|
|
96
|
+
]
|
|
97
|
+
if any(version == UNRELEASED and section == want for _, version, section in found):
|
|
98
|
+
return
|
|
99
|
+
if not found:
|
|
100
|
+
msg = f"No list item ending in “(#{pr})”; “{title}” needs one under “## [Unreleased]” › “### {want}”"
|
|
101
|
+
raise ChangelogError(msg, file=self.path)
|
|
102
|
+
entry, version, section = found[0]
|
|
103
|
+
msg = f"Entry for #{pr} is under “## [{version}]” › “### {section}”, but “{title}” needs “## [Unreleased]” › “### {want}”"
|
|
104
|
+
raise ChangelogError(msg, file=self.path, line=entry.line)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _text(node: Node) -> str:
|
|
108
|
+
match node:
|
|
109
|
+
case Literal(value=value):
|
|
110
|
+
return value
|
|
111
|
+
case Parent(children=children):
|
|
112
|
+
return "".join(map(_text, children))
|
|
113
|
+
return ""
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _line(text: str, node: Node) -> int:
|
|
117
|
+
assert node.position is not None
|
|
118
|
+
return text.count("\n", 0, node.position.start) + 1
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _parse_entry(text: str, path: Path, item: Node) -> Entry:
|
|
122
|
+
line = _line(text, item)
|
|
123
|
+
match item:
|
|
124
|
+
case ListItem(children=[Paragraph(children=[*rest, Text(value=value)]), *_]):
|
|
125
|
+
if m := re.search(r"\(#(\d+)\)$", value):
|
|
126
|
+
if not rest and value == m[0]:
|
|
127
|
+
raise ChangelogError(f"Entry “{value}” has no description", file=path, line=line)
|
|
128
|
+
return Entry(line, int(m[1]))
|
|
129
|
+
return Entry(line, None)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def main() -> None:
|
|
133
|
+
"""Exit with a GitHub error annotation if the changelog is malformed or the entry is missing or misplaced."""
|
|
134
|
+
parser = ArgumentParser(description=__doc__)
|
|
135
|
+
parser.add_argument("--pr", type=int, required=True)
|
|
136
|
+
parser.add_argument("--title", required=True)
|
|
137
|
+
parser.add_argument("--changelog", type=Path, default=Path("CHANGELOG.md"))
|
|
138
|
+
args = parser.parse_args()
|
|
139
|
+
|
|
140
|
+
Changelog.parse(args.changelog).check(args.pr, args.title)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
main()
|
|
@@ -22,8 +22,6 @@ from sphinx.util import logging
|
|
|
22
22
|
from sphinx.util.typing import ExtensionMetadata
|
|
23
23
|
|
|
24
24
|
if TYPE_CHECKING:
|
|
25
|
-
from typing import Any
|
|
26
|
-
|
|
27
25
|
from sphinx.application import Sphinx
|
|
28
26
|
from sphinx.config import Config
|
|
29
27
|
|
|
@@ -51,8 +49,15 @@ def _member_type(obj_path: str) -> Literal["method", "property", "attribute"]:
|
|
|
51
49
|
return "attribute"
|
|
52
50
|
|
|
53
51
|
|
|
54
|
-
def _skip_private_bases(app: Sphinx, name: str, obj: type, options:
|
|
55
|
-
|
|
52
|
+
def _skip_private_bases(app: Sphinx, name: str, obj: type, options: object, bases: list[type | str]) -> None:
|
|
53
|
+
# Other handlers may have added strings, and some typing constructs have no `__name__`.
|
|
54
|
+
bases[:] = [
|
|
55
|
+
b
|
|
56
|
+
for b in bases
|
|
57
|
+
if b is not object
|
|
58
|
+
and get_origin(b) is not Generic
|
|
59
|
+
and not (b if isinstance(b, str) else getattr(b, "__name__", "")).rpartition(".")[2].startswith("_")
|
|
60
|
+
]
|
|
56
61
|
|
|
57
62
|
|
|
58
63
|
def _add_templates(app: Sphinx, config: Config) -> None:
|
|
@@ -67,5 +72,6 @@ def setup(app: Sphinx) -> ExtensionMetadata:
|
|
|
67
72
|
# TODO: autosummary builds its own jinja environment with no hook for filters, so this is global.
|
|
68
73
|
DEFAULT_FILTERS["member_type"] = _member_type
|
|
69
74
|
app.connect("config-inited", _add_templates)
|
|
70
|
-
|
|
75
|
+
# when running before sphinx-autodoc-typehints, we run on the actual `__name__`
|
|
76
|
+
app.connect("autodoc-process-bases", _skip_private_bases, priority=100)
|
|
71
77
|
return ExtensionMetadata(parallel_read_safe=True)
|
|
@@ -7,7 +7,7 @@ and fills in :data:`DEFAULTS`. Anything set in `conf.py` always wins.
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
-
from typing import TYPE_CHECKING
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
11
|
|
|
12
12
|
from sphinx.util.typing import ExtensionMetadata
|
|
13
13
|
|
|
@@ -41,7 +41,7 @@ MYST_ENABLE_EXTENSIONS = (
|
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
#: Sphinx config values applied unless `conf.py` sets them.
|
|
44
|
-
DEFAULTS: dict[str,
|
|
44
|
+
DEFAULTS: dict[str, object] = {
|
|
45
45
|
"autosummary_generate": True,
|
|
46
46
|
"autodoc_member_order": "groupwise",
|
|
47
47
|
"napoleon_google_docstring": False,
|
|
@@ -22,7 +22,7 @@ from functools import cache, cached_property
|
|
|
22
22
|
from importlib.resources import files
|
|
23
23
|
from operator import itemgetter
|
|
24
24
|
from pathlib import Path
|
|
25
|
-
from typing import TYPE_CHECKING,
|
|
25
|
+
from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict, cast
|
|
26
26
|
|
|
27
27
|
from sphinx.application import Sphinx # noqa: TC002 # `_build_cache`’s annotations must resolve at runtime
|
|
28
28
|
from sphinx.util import requests
|
|
@@ -106,8 +106,19 @@ class Package:
|
|
|
106
106
|
"""The package’s brand accent, falling back to the scverse deep blue."""
|
|
107
107
|
|
|
108
108
|
|
|
109
|
+
class _Entry(TypedDict):
|
|
110
|
+
"""The fields of an upstream listing entry that the registry reads."""
|
|
111
|
+
|
|
112
|
+
name: str
|
|
113
|
+
documentation_home: str
|
|
114
|
+
inventory: NotRequired[str]
|
|
115
|
+
project_home: NotRequired[str]
|
|
116
|
+
description: NotRequired[str]
|
|
117
|
+
category: NotRequired[str]
|
|
118
|
+
|
|
119
|
+
|
|
109
120
|
@cache
|
|
110
|
-
def _fetch() -> list[
|
|
121
|
+
def _fetch() -> list[_Entry]:
|
|
111
122
|
"""Fetch the upstream listing, going through `_cache_dir` if one is set."""
|
|
112
123
|
cached = _cache_dir / "scverse-packages.json" if _cache_dir is not None else None
|
|
113
124
|
if cached is not None and cached.is_file() and time.time() - cached.stat().st_mtime < _MAX_AGE_SECONDS:
|
|
@@ -122,7 +133,7 @@ def _fetch() -> list[dict[str, Any]]:
|
|
|
122
133
|
if cached is not None:
|
|
123
134
|
cached.parent.mkdir(parents=True, exist_ok=True)
|
|
124
135
|
cached.write_bytes(response.content)
|
|
125
|
-
listing: list[
|
|
136
|
+
listing: list[_Entry] = response.json()
|
|
126
137
|
return listing
|
|
127
138
|
|
|
128
139
|
|
|
@@ -20,7 +20,7 @@ from dataclasses import dataclass
|
|
|
20
20
|
from enum import Enum
|
|
21
21
|
from importlib import import_module
|
|
22
22
|
from pathlib import Path, PurePosixPath
|
|
23
|
-
from typing import TYPE_CHECKING,
|
|
23
|
+
from typing import TYPE_CHECKING, NamedTuple, Self
|
|
24
24
|
from urllib.parse import urlsplit
|
|
25
25
|
|
|
26
26
|
from sphinx.errors import ConfigError
|
|
@@ -128,13 +128,13 @@ def _ref(config: Config) -> str:
|
|
|
128
128
|
return "main"
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
def _theme_options(source: _Source) -> dict[str,
|
|
131
|
+
def _theme_options(source: _Source) -> dict[str, object]:
|
|
132
132
|
"""Every theme option some theme reads this from; only the declared ones are applied."""
|
|
133
133
|
if not source.provider:
|
|
134
134
|
# Every one of these makes a theme build per-page URLs we have no layout for:
|
|
135
135
|
# `sphinx-basic-ng` warns, `sphinx-book-theme` guesses the forge and errors out if it can’t.
|
|
136
136
|
return {}
|
|
137
|
-
options: dict[str,
|
|
137
|
+
options: dict[str, object] = {
|
|
138
138
|
# sphinx-basic-ng, and so furo
|
|
139
139
|
"source_repository": source.url,
|
|
140
140
|
"source_branch": source.ref,
|
|
@@ -155,7 +155,7 @@ def _theme_options(source: _Source) -> dict[str, Any]:
|
|
|
155
155
|
return options
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
def _html_context(source: _Source) -> dict[str,
|
|
158
|
+
def _html_context(source: _Source) -> dict[str, object]:
|
|
159
159
|
"""The `html_context` entries `pydata-sphinx-theme`, `sphinx_rtd_theme` and `furo` read."""
|
|
160
160
|
parts = urlsplit(source.url)
|
|
161
161
|
owner, _, name = parts.path.strip("/").rpartition("/")
|
|
@@ -198,10 +198,10 @@ def _configure_theme(app: Sphinx) -> None:
|
|
|
198
198
|
def _linkcode_url(source: _Source, module: str, fullname: str) -> str | None:
|
|
199
199
|
"""Link to a Python object’s definition, or :data:`None` if it has no findable source."""
|
|
200
200
|
try:
|
|
201
|
-
obj
|
|
201
|
+
obj = import_module(module)
|
|
202
202
|
for part in filter(None, fullname.split(".")):
|
|
203
203
|
obj = getattr(obj, part)
|
|
204
|
-
obj = inspect.unwrap(obj)
|
|
204
|
+
obj = inspect.unwrap(obj) if callable(obj) else obj
|
|
205
205
|
lines, start = inspect.getsourcelines(obj)
|
|
206
206
|
file = Path(inspect.getsourcefile(obj) or "")
|
|
207
207
|
except (ImportError, AttributeError, TypeError, OSError):
|
|
@@ -12,7 +12,7 @@ The accent colour and the “scverse packages” dropdown come from the
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
from pathlib import Path
|
|
15
|
-
from typing import TYPE_CHECKING
|
|
15
|
+
from typing import TYPE_CHECKING
|
|
16
16
|
|
|
17
17
|
from sphinx.util.typing import ExtensionMetadata
|
|
18
18
|
|
|
@@ -97,14 +97,14 @@ def _add_ecosystem_context(
|
|
|
97
97
|
app: Sphinx,
|
|
98
98
|
pagename: str,
|
|
99
99
|
templatename: str,
|
|
100
|
-
context: dict[str,
|
|
100
|
+
context: dict[str, object],
|
|
101
101
|
doctree: object,
|
|
102
102
|
) -> None:
|
|
103
103
|
"""Expose the registry to the scverse menu template."""
|
|
104
104
|
if app.config.html_theme != "scverse":
|
|
105
105
|
return
|
|
106
106
|
current = _package_name(app.config).lower()
|
|
107
|
-
groups: dict[str, list[dict[str,
|
|
107
|
+
groups: dict[str, list[dict[str, object]]] = {"core": [], "ecosystem": []}
|
|
108
108
|
for pkg in packages.values():
|
|
109
109
|
groups[pkg.kind].append({"name": pkg.name, "docs": pkg.docs, "current": pkg.name.lower() == current})
|
|
110
110
|
context["scverse_ecosystem"] = groups
|
{scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/theme/scverse/static/styles/scverse.css
RENAMED
|
@@ -74,9 +74,9 @@ html:not(:has(.bd-header__inner)) {
|
|
|
74
74
|
display: none;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/* pydata sizes the logo by the header height
|
|
77
|
+
/* pydata sizes the logo by the header height */
|
|
78
78
|
.navbar-brand {
|
|
79
|
-
--pst-header-height:
|
|
79
|
+
--pst-header-height: auto;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/* pydata’s overflow-x would make this the sticky header’s scroll container;
|
|
@@ -211,11 +211,23 @@ a.dropdown-item {
|
|
|
211
211
|
|
|
212
212
|
/* --- Sidebar ------------------------------------------------------------ */
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
.sidebar-primary-item {
|
|
215
|
+
/* Hide empty sidebar items; this:
|
|
216
|
+
* excludes defined custom elements (which only contain Shadow DOM)
|
|
217
|
+
* includes an empty ad container
|
|
218
|
+
*/
|
|
219
|
+
&:has(> :only-child:empty:not(readthedocs-flyout:defined)),
|
|
220
|
+
&:has(> #ethical-ad-placement):not(:has(> #ethical-ad-placement > *)) {
|
|
221
|
+
display: none;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* for visual consistency, make the search field fill the sidebar */
|
|
225
|
+
.search-button-field {
|
|
226
|
+
width: 100%;
|
|
227
|
+
}
|
|
217
228
|
}
|
|
218
|
-
|
|
229
|
+
|
|
230
|
+
readthedocs-flyout {
|
|
219
231
|
--readthedocs-flyout-background-color: transparent;
|
|
220
232
|
--readthedocs-flyout-font-family: inherit;
|
|
221
233
|
--readthedocs-flyout-divider-color: var(--scverse-color-border);
|
|
@@ -17,7 +17,7 @@ renders the term ``a`` classified as :class:`str`, with the description indented
|
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
|
-
from typing import TYPE_CHECKING, ClassVar
|
|
20
|
+
from typing import TYPE_CHECKING, ClassVar, TypedDict, Unpack
|
|
21
21
|
|
|
22
22
|
from docutils import nodes
|
|
23
23
|
from sphinx import addnodes
|
|
@@ -26,8 +26,8 @@ from sphinx.util.typing import ExtensionMetadata
|
|
|
26
26
|
|
|
27
27
|
if TYPE_CHECKING:
|
|
28
28
|
from collections.abc import Iterable
|
|
29
|
-
from typing import Any
|
|
30
29
|
|
|
30
|
+
from docutils.parsers.rst.states import Inliner
|
|
31
31
|
from sphinx.application import Sphinx
|
|
32
32
|
from sphinx.environment import BuildEnvironment
|
|
33
33
|
|
|
@@ -36,6 +36,12 @@ if TYPE_CHECKING:
|
|
|
36
36
|
__all__ = ["setup"]
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
class _XRefKw(TypedDict):
|
|
40
|
+
contnode: nodes.Node | None
|
|
41
|
+
inliner: Inliner | None
|
|
42
|
+
location: nodes.Node | None
|
|
43
|
+
|
|
44
|
+
|
|
39
45
|
class _DLTypedField(PyTypedField):
|
|
40
46
|
"""A :class:`~sphinx.domains.python.PyTypedField` that renders its items as a definition list."""
|
|
41
47
|
|
|
@@ -47,7 +53,7 @@ class _DLTypedField(PyTypedField):
|
|
|
47
53
|
domain: str,
|
|
48
54
|
items: Iterable[tuple[str, list[nodes.inline]]],
|
|
49
55
|
env: BuildEnvironment | None = None,
|
|
50
|
-
**kw:
|
|
56
|
+
**kw: Unpack[_XRefKw],
|
|
51
57
|
) -> nodes.field:
|
|
52
58
|
"""Render a field to a node holding a definition list."""
|
|
53
59
|
|
|
@@ -37,7 +37,6 @@ from sphinx.util.typing import ExtensionMetadata
|
|
|
37
37
|
if TYPE_CHECKING:
|
|
38
38
|
from collections.abc import Mapping
|
|
39
39
|
from types import ModuleType
|
|
40
|
-
from typing import Any
|
|
41
40
|
|
|
42
41
|
from docutils import nodes
|
|
43
42
|
from sphinx.addnodes import pending_xref
|
|
@@ -60,7 +59,7 @@ DEFAULT_OVERRIDES: dict[str, str] = {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
|
|
63
|
-
def _normalize(mapping: Mapping[
|
|
62
|
+
def _normalize[K: str | _Key](mapping: Mapping[K, str | _Key]) -> dict[_Key, _Key]:
|
|
64
63
|
"""Make keys and values ``(role, name)`` tuples, with role :data:`None` for any role."""
|
|
65
64
|
return {
|
|
66
65
|
(k if isinstance(k, tuple) else (None, k)): (v if isinstance(v, tuple) else (None, v))
|
|
@@ -88,7 +87,7 @@ def _exec_guarded_imports(module: ModuleType) -> None:
|
|
|
88
87
|
_logger.debug(f"Failed to execute guarded import {ast.unparse(stmt)!r} in {module.__name__}")
|
|
89
88
|
|
|
90
89
|
|
|
91
|
-
def _resolve_guarded_imports(app: Sphinx, obj:
|
|
90
|
+
def _resolve_guarded_imports(app: Sphinx, obj: object, bound_method: bool) -> None:
|
|
92
91
|
if isinstance(module_name := getattr(obj, "__module__", None), str) and module_name in sys.modules:
|
|
93
92
|
_exec_guarded_imports(sys.modules[module_name])
|
|
94
93
|
|
|
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
|
|
File without changes
|
{scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/autodoc/templates/autosummary/class.rst
RENAMED
|
File without changes
|
{scverse_doc-0.2.0 → scverse_doc-0.2.2}/src/scverse_doc/autodoc/templates/autosummary/module.rst
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scverse_doc-0.2.0 → scverse_doc-0.2.2}/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
|