Skip to content

Commit 8581502

Browse files
docs: generate Reference version list from json file
Signed-off-by: Martin Fischer <[email protected]>
1 parent 32d6c54 commit 8581502

File tree

4 files changed

+61
-44
lines changed

4 files changed

+61
-44
lines changed

RELEASE_PROCESS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ spelled with complete minutiae.
156156
1. Edit `version/rawversion/version.go` and bump the `Version` value to the new
157157
release version. If there were API changes, also bump `APIVersion` value.
158158
Make sure to also bump the version in the swagger.yaml `pkg/api/server/docs.go`
159-
For major and minor versions also add the new branch name to
160-
`docs/source/Reference.rst` to show the new swagger version on docs.podman.io.
159+
For major and minor versions also add the new version to
160+
`docs/source/_static/versions.json` to show the new swagger version on docs.podman.io.
161161
1. Commit this and sign the commit (`git commit -a -s -S`). The commit message
162162
should be `Bump to vX.Y.Z` (using the actual version numbers).
163163
1. Push this single change to your GitHub fork, and make a new PR,

docs/source/Reference.rst

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,4 @@ Show the API documentation for version:
77

88
* `latest (main branch) <_static/api.html>`_
99

10-
* `version 5.6 <_static/api.html?version=v5.6>`_
11-
12-
* `version 5.5 <_static/api.html?version=v5.5>`_
13-
14-
* `version 5.4 <_static/api.html?version=v5.4>`_
15-
16-
* `version 5.3 <_static/api.html?version=v5.3>`_
17-
18-
* `version 5.2 <_static/api.html?version=v5.2>`_
19-
20-
* `version 5.1 <_static/api.html?version=v5.1>`_
21-
22-
* `version 5.0 <_static/api.html?version=v5.0>`_
23-
24-
* `version 4.9 <_static/api.html?version=v4.9>`_
25-
26-
* `version 4.8 <_static/api.html?version=v4.8>`_
27-
28-
* `version 4.7 <_static/api.html?version=v4.7>`_
29-
30-
* `version 4.6 <_static/api.html?version=v4.6>`_
31-
32-
* `version 4.5 <_static/api.html?version=v4.5>`_
33-
34-
* `version 4.4 <_static/api.html?version=v4.4>`_
35-
36-
* `version 4.3 <_static/api.html?version=v4.3>`_
37-
38-
* `version 4.2 <_static/api.html?version=v4.2>`_
39-
40-
* `version 4.1 <_static/api.html?version=v4.1>`_
41-
42-
* `version 4.0 <_static/api.html?version=v4.0>`_
43-
44-
* `version 3.4 <_static/api.html?version=v3.4>`_
45-
46-
* `version 3.3 <_static/api.html?version=v3.3>`_
47-
48-
* `version 3.2 <_static/api.html?version=v3.2>`_
49-
50-
* `version 3.1 <_static/api.html?version=v3.1>`_
10+
.. api-versions::

docs/source/_static/versions.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
"5.6",
3+
"5.5",
4+
"5.4",
5+
"5.3",
6+
"5.2",
7+
"5.1",
8+
"5.0",
9+
"4.9",
10+
"4.8",
11+
"4.7",
12+
"4.6",
13+
"4.5",
14+
"4.4",
15+
"4.3",
16+
"4.2",
17+
"4.1",
18+
"4.0",
19+
"3.4",
20+
"3.3",
21+
"3.2",
22+
"3.1"
23+
]

docs/source/conf.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

17-
import re
17+
import json
1818
import os
19+
import re
1920
import subprocess
2021

22+
from docutils.parsers.rst import Directive
23+
from docutils import nodes
24+
2125
# Define the canonical URL for our custom docs.podman.io domain configured on Read the Docs
2226
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
2327

@@ -103,5 +107,35 @@ def convert_markdown_title(app, docname, source):
103107
# after the user's last visit.
104108
source[0] = re.sub(r"^% (.*)\s(\d)", r"```{title} \g<1>\n```", source[0])
105109

110+
111+
class APIVersionsDirective(Directive):
112+
"""
113+
Custom directive to generate a bullet list from the versions defined in _static/versions.json.
114+
115+
Usage in RST:
116+
.. api-versions::
117+
"""
118+
required_arguments = 0
119+
has_content = False
120+
121+
def run(self):
122+
env = self.state.document.settings.env
123+
json_file = f"{env.app.confdir}/_static/versions.json"
124+
125+
with open(json_file, "r") as f:
126+
versions = json.load(f)
127+
128+
bullet_list = nodes.bullet_list()
129+
130+
for version in versions:
131+
list_item = nodes.list_item()
132+
paragraph = nodes.paragraph()
133+
paragraph += nodes.reference("", f"version {version}", refuri=f"_static/api.html?version=v{version}")
134+
list_item += paragraph
135+
bullet_list += list_item
136+
137+
return [bullet_list]
138+
106139
def setup(app):
140+
app.add_directive("api-versions", APIVersionsDirective)
107141
app.connect("source-read", convert_markdown_title)

0 commit comments

Comments
 (0)