Skip to content

Commit ef4a9cc

Browse files
authored
[chore] Automate creation of release notes toc (#1155)
* [chore] Automate creation of release notes toc * Add missing things * Improve TOCs * Rename function * Fix toctree sorting * Address comments in PR
1 parent c06a86c commit ef4a9cc

File tree

9 files changed

+54
-82
lines changed

9 files changed

+54
-82
lines changed

cuda_bindings/docs/source/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
# -- Path setup --------------------------------------------------------------
1111

12-
# If extensions (or modules to document with autodoc) are in another directory,
13-
# add these directories to sys.path here. If the directory is relative to the
14-
# documentation root, use os.path.abspath to make it absolute, like shown here.
1512
import os
13+
import sys
14+
from pathlib import Path
1615

17-
# import sys
18-
# sys.path.insert(0, os.path.abspath('.'))
16+
sys.path.insert(0, str((Path(__file__).parents[3] / "cuda_python" / "docs" / "exts").absolute()))
1917

2018

2119
# -- Project information -----------------------------------------------------
@@ -41,6 +39,7 @@
4139
"myst_nb",
4240
"enum_tools.autoenum",
4341
"sphinx_copybutton",
42+
"release_toc",
4443
]
4544

4645
nb_execution_mode = "off"

cuda_bindings/docs/source/release.rst

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,6 @@ Release Notes
66

77
.. toctree::
88
:maxdepth: 3
9+
:glob:
910

10-
13.0.3 <release/13.0.3-notes.rst>
11-
13.0.2 <release/13.0.2-notes.rst>
12-
13.0.1 <release/13.0.1-notes.rst>
13-
13.0.0 <release/13.0.0-notes.rst>
14-
12.9.4 <release/12.9.4-notes.rst>
15-
12.9.3 <release/12.9.3-notes.rst>
16-
12.9.2 <release/12.9.2-notes.rst>
17-
12.9.1 <release/12.9.1-notes.rst>
18-
12.9.0 <release/12.9.0-notes.rst>
19-
12.8.0 <release/12.8.0-notes.rst>
20-
12.6.2 <release/12.6.2-notes.rst>
21-
12.6.1 <release/12.6.1-notes.rst>
22-
12.6.0 <release/12.6.0-notes.rst>
23-
12.5.0 <release/12.5.0-notes.rst>
24-
12.4.0 <release/12.4.0-notes.rst>
25-
12.3.0 <release/12.3.0-notes.rst>
26-
12.2.1 <release/12.2.1-notes.rst>
27-
12.2.0 <release/12.2.0-notes.rst>
28-
12.1.0 <release/12.1.0-notes.rst>
29-
12.0.0 <release/12.0.0-notes.rst>
30-
11.8.7 <release/11.8.7-notes.rst>
31-
11.8.6 <release/11.8.6-notes.rst>
32-
11.8.5 <release/11.8.5-notes.rst>
33-
11.8.4 <release/11.8.4-notes.rst>
34-
11.8.3 <release/11.8.3-notes.rst>
35-
11.8.2 <release/11.8.2-notes.rst>
36-
11.8.1 <release/11.8.1-notes.rst>
37-
11.8.0 <release/11.8.0-notes.rst>
38-
11.7.1 <release/11.7.1-notes.rst>
39-
11.7.0 <release/11.7.0-notes.rst>
40-
11.6.1 <release/11.6.1-notes.rst>
41-
11.6.0 <release/11.6.0-notes.rst>
42-
11.5.0 <release/11.5.0-notes.rst>
43-
11.4.0 <release/11.4.0-notes.rst>
11+
release/*[0-9]-notes

cuda_core/docs/source/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
# -- Path setup --------------------------------------------------------------
1111

12-
# If extensions (or modules to document with autodoc) are in another directory,
13-
# add these directories to sys.path here. If the directory is relative to the
14-
# documentation root, use os.path.abspath to make it absolute, like shown here.
1512
import os
13+
import sys
14+
from pathlib import Path
1615

17-
# sys.path.insert(0, os.path.abspath('.'))
16+
sys.path.insert(0, str((Path(__file__).parents[3] / "cuda_python" / "docs" / "exts").absolute()))
1817

1918

2019
# -- Project information -----------------------------------------------------
@@ -41,6 +40,7 @@
4140
"enum_tools.autoenum",
4241
"sphinx_copybutton",
4342
"sphinx_toolbox.more_autodoc.autoprotocol",
43+
"release_toc",
4444
]
4545

4646
# Add any paths that contain templates here, relative to this directory.

cuda_core/docs/source/release.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ Release Notes
66

77
.. toctree::
88
:maxdepth: 3
9+
:glob:
910

10-
0.4.0 <release/0.4.0-notes>
11-
0.3.2 <release/0.3.2-notes>
12-
0.3.1 <release/0.3.1-notes>
13-
0.3.0 <release/0.3.0-notes>
14-
0.2.0 <release/0.2.0-notes>
15-
0.1.1 <release/0.1.1-notes>
16-
0.1.0 <release/0.1.0-notes>
11+
release/*[0-9]-notes

cuda_pathfinder/docs/source/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
# -- Path setup --------------------------------------------------------------
1111

12-
# If extensions (or modules to document with autodoc) are in another directory,
13-
# add these directories to sys.path here. If the directory is relative to the
14-
# documentation root, use os.path.abspath to make it absolute, like shown here.
1512
import os
13+
import sys
14+
from pathlib import Path
1615

17-
# import sys
18-
# sys.path.insert(0, os.path.abspath('.'))
16+
sys.path.insert(0, str((Path(__file__).parents[3] / "cuda_python" / "docs" / "exts").absolute()))
1917

2018

2119
# -- Project information -----------------------------------------------------
@@ -41,6 +39,7 @@
4139
"myst_nb",
4240
"enum_tools.autoenum",
4341
"sphinx_copybutton",
42+
"release_toc",
4443
]
4544

4645
nb_execution_mode = "off"

cuda_pathfinder/docs/source/release.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ Release Notes
66

77
.. toctree::
88
:maxdepth: 3
9+
:glob:
910

10-
1.3.1 <release/1.3.1-notes>
11-
1.3.0 <release/1.3.0-notes>
12-
1.2.3 <release/1.2.3-notes>
13-
1.2.2 <release/1.2.2-notes>
14-
1.2.1 <release/1.2.1-notes>
15-
1.2.0 <release/1.2.0-notes>
16-
1.1.0 <release/1.1.0-notes>
17-
1.0.0 <release/1.0.0-notes>
11+
release/*[0-9]-notes
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
from pathlib import Path
5+
6+
from packaging.version import Version
7+
from sphinx.directives.other import TocTree
8+
9+
10+
class TocTreeSorted(TocTree):
11+
"""A toctree directive that sorts entries by version."""
12+
13+
def parse_content(self, toctree):
14+
super().parse_content(toctree)
15+
16+
if not toctree["glob"]:
17+
return
18+
19+
entries = toctree.get("entries", [])
20+
if not entries:
21+
return
22+
23+
entries = [(Version(Path(x[1]).name.removesuffix("-notes")), x[1]) for x in entries]
24+
entries.sort(key=lambda x: x[0], reverse=True)
25+
entries = [(str(x[0]), x[1]) for x in entries]
26+
toctree["entries"] = entries
27+
28+
29+
def setup(app):
30+
app.add_directive("toctree", TocTreeSorted, override=True)

cuda_python/docs/source/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
# -- Path setup --------------------------------------------------------------
1111

12-
# If extensions (or modules to document with autodoc) are in another directory,
13-
# add these directories to sys.path here. If the directory is relative to the
14-
# documentation root, use os.path.abspath to make it absolute, like shown here.
1512
import os
13+
import sys
14+
from pathlib import Path
1615

17-
# import sys
18-
# sys.path.insert(0, os.path.abspath('.'))
16+
sys.path.insert(0, str((Path(__file__).parents[1] / "exts").absolute()))
1917

2018

2119
# -- Project information -----------------------------------------------------
@@ -38,6 +36,7 @@
3836
"sphinx.ext.napoleon",
3937
"myst_nb",
4038
"enum_tools.autoenum",
39+
"release_toc",
4140
]
4241

4342
# Add any paths that contain templates here, relative to this directory.

cuda_python/docs/source/release.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ Release Notes
66

77
.. toctree::
88
:maxdepth: 3
9+
:glob:
910

10-
13.0.3 <release/13.0.3-notes.rst>
11-
13.0.2 <release/13.0.2-notes.rst>
12-
13.0.1 <release/13.0.1-notes.rst>
13-
13.0.0 <release/13.0.0-notes.rst>
14-
12.9.4 <release/12.9.4-notes.rst>
15-
12.9.3 <release/12.9.3-notes.rst>
16-
12.9.2 <release/12.9.2-notes.rst>
17-
12.9.1 <release/12.9.1-notes.rst>
18-
12.9.0 <release/12.9.0-notes.rst>
19-
12.8.0 <release/12.8.0-notes.rst>
20-
12.6.2 <release/12.6.2-notes.rst>
21-
12.6.1 <release/12.6.1-notes.rst>
22-
11.8.7 <release/11.8.7-notes.rst>
23-
11.8.6 <release/11.8.6-notes.rst>
11+
release/*[0-9]-notes

0 commit comments

Comments
 (0)