Skip to content

Commit 5c5f0cc

Browse files
authored
Fix rc versions (#173)
1 parent 99624f1 commit 5c5f0cc

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ dependencies = [
2727
dev = ['pre-commit']
2828
test = [
2929
'pytest',
30-
'pytest-mock',
3130
'coverage',
3231
'legacy-api-wrap',
3332
'defusedxml', # sphinx[test] would also pull in cython

src/scanpydoc/release_notes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from myst_parser.mdit_to_docutils.base import DocutilsRenderer
5454

5555

56-
FULL_VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)(?:\..*)?$")
56+
FULL_VERSION_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)(?:.*)?$")
5757
"""Regex matching a full version number including patch part, maybe with more after."""
5858

5959

@@ -128,8 +128,8 @@ def render_version_group(
128128
self._myst_renderer.current_node.append(target)
129129
self._myst_renderer.update_section_level_state(section, 2)
130130
# append children to section
131-
with self._myst_renderer.current_node_context(section):
132-
for _, p in versions:
131+
for _, p in versions:
132+
with self._myst_renderer.current_node_context(section):
133133
self.render_include(p)
134134
return target, section # ignored, just to not change the types
135135

tests/test_release_notes.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from pathlib import Path
1919
from collections.abc import Mapping, Callable
2020

21-
from pytest_mock import MockerFixture
2221
from sphinx.application import Sphinx
2322

2423
Tree: TypeAlias = Mapping[str | Path, "Tree | str"]
@@ -67,18 +66,16 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
6766
if "myst_parser" in app.extensions:
6867
files = {
6968
index_filename: index_template.format("."),
70-
"1.2.0.md": "### 1.2.0",
71-
"1.2.1.md": "### 1.2.1",
72-
"1.3.0.md": "### 1.3.0",
73-
"1.3.2.md": "### 1.3.2",
69+
"1.2.0.md": "(v1.2.0)=\n### 1.2.0",
70+
"1.2.1.md": "(v1.2.1)=\n### 1.2.1",
71+
"1.3.0rc1.md": "(v1.3.0rc1)=\n### 1.3.0rc1",
7472
}
7573
else:
7674
files = {
7775
index_filename: index_template.format("."),
78-
"1.2.0.rst": "1.2.0\n=====",
79-
"1.2.1.rst": "1.2.1\n=====",
80-
"1.3.0.rst": "1.3.0\n=====",
81-
"1.3.2.rst": "1.3.2\n=====",
76+
"1.2.0.rst": ".. _v1.2.0:\n1.2.0\n=====",
77+
"1.2.1.rst": ".. _v1.2.1:\n1.2.1\n=====",
78+
"1.3.0rc1.rst": ".. _v1.3.0rc1:\n1.3.0rc1\n========",
8279
}
8380
return files
8481

@@ -88,20 +85,20 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
8885
<section ids="version-1-3 v1-3" names="version\\ 1.3 v1.3">
8986
<title>
9087
Version 1.3
91-
<section ids="id1" names="1.3.2">
88+
<target refid="v1-3-0rc1">
89+
<section ids="rc1 v1-3-0rc1" names="1.3.0rc1 v1.3.0rc1">
9290
<title>
93-
1.3.2
94-
<section ids="id2" names="1.3.0">
95-
<title>
96-
1.3.0
91+
1.3.0rc1
9792
<target refid="v1-2">
9893
<section ids="version-1-2 v1-2" names="version\\ 1.2 v1.2">
9994
<title>
10095
Version 1.2
101-
<section ids="id3" names="1.2.1">
96+
<target refid="v1-2-1">
97+
<section ids="v1-2-1 id1" names="1.2.1 v1.2.1">
10298
<title>
10399
1.2.1
104-
<section ids="id4" names="1.2.0">
100+
<target refid="v1-2-0">
101+
<section ids="v1-2-0 id2" names="1.2.0 v1.2.0">
105102
<title>
106103
1.2.0
107104
"""
@@ -143,7 +140,7 @@ def test_error_wrong_file(
143140

144141

145142
def test_error_no_src(
146-
mocker: MockerFixture,
143+
monkeypatch: pytest.MonkeyPatch,
147144
tmp_path: Path,
148145
app: Sphinx,
149146
files: Tree,
@@ -152,7 +149,7 @@ def test_error_no_src(
152149
pytest.skip("rst parser doesn’t need this")
153150
app.warningiserror = True
154151
rn, _ = directives.directive("release-notes", get_language("en"), new_document(""))
155-
mocker.patch.object(rn, "get_source_info", return_value=("<string>", 0))
152+
monkeypatch.setattr(rn, "get_source_info", lambda *_, **__: ("<string>", 0))
156153

157154
mkfiles(tmp_path, files)
158155
with pytest.raises(SphinxWarning, match=r"Cannot find relative path to: <string>"):

0 commit comments

Comments
 (0)