Skip to content

Fix rc versions #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies = [
dev = ['pre-commit']
test = [
'pytest',
'pytest-mock',
'coverage',
'legacy-api-wrap',
'defusedxml', # sphinx[test] would also pull in cython
Expand Down
6 changes: 3 additions & 3 deletions src/scanpydoc/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from myst_parser.mdit_to_docutils.base import DocutilsRenderer


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


Expand Down Expand Up @@ -128,8 +128,8 @@ def render_version_group(
self._myst_renderer.current_node.append(target)
self._myst_renderer.update_section_level_state(section, 2)
# append children to section
with self._myst_renderer.current_node_context(section):
for _, p in versions:
for _, p in versions:
with self._myst_renderer.current_node_context(section):
self.render_include(p)
return target, section # ignored, just to not change the types

Expand Down
33 changes: 15 additions & 18 deletions tests/test_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from pathlib import Path
from collections.abc import Mapping, Callable

from pytest_mock import MockerFixture
from sphinx.application import Sphinx

Tree: TypeAlias = Mapping[str | Path, "Tree | str"]
Expand Down Expand Up @@ -67,18 +66,16 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
if "myst_parser" in app.extensions:
files = {
index_filename: index_template.format("."),
"1.2.0.md": "### 1.2.0",
"1.2.1.md": "### 1.2.1",
"1.3.0.md": "### 1.3.0",
"1.3.2.md": "### 1.3.2",
"1.2.0.md": "(v1.2.0)=\n### 1.2.0",
"1.2.1.md": "(v1.2.1)=\n### 1.2.1",
"1.3.0rc1.md": "(v1.3.0rc1)=\n### 1.3.0rc1",
}
else:
files = {
index_filename: index_template.format("."),
"1.2.0.rst": "1.2.0\n=====",
"1.2.1.rst": "1.2.1\n=====",
"1.3.0.rst": "1.3.0\n=====",
"1.3.2.rst": "1.3.2\n=====",
"1.2.0.rst": ".. _v1.2.0:\n1.2.0\n=====",
"1.2.1.rst": ".. _v1.2.1:\n1.2.1\n=====",
"1.3.0rc1.rst": ".. _v1.3.0rc1:\n1.3.0rc1\n========",
}
return files

Expand All @@ -88,20 +85,20 @@ def files(app: Sphinx, index_filename: str, index_template: str) -> Tree:
<section ids="version-1-3 v1-3" names="version\\ 1.3 v1.3">
<title>
Version 1.3
<section ids="id1" names="1.3.2">
<target refid="v1-3-0rc1">
<section ids="rc1 v1-3-0rc1" names="1.3.0rc1 v1.3.0rc1">
<title>
1.3.2
<section ids="id2" names="1.3.0">
<title>
1.3.0
1.3.0rc1
<target refid="v1-2">
<section ids="version-1-2 v1-2" names="version\\ 1.2 v1.2">
<title>
Version 1.2
<section ids="id3" names="1.2.1">
<target refid="v1-2-1">
<section ids="v1-2-1 id1" names="1.2.1 v1.2.1">
<title>
1.2.1
<section ids="id4" names="1.2.0">
<target refid="v1-2-0">
<section ids="v1-2-0 id2" names="1.2.0 v1.2.0">
<title>
1.2.0
"""
Expand Down Expand Up @@ -143,7 +140,7 @@ def test_error_wrong_file(


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

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