summaryrefslogtreecommitdiffstats
path: root/documentation/set_versions.py
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-07-19 10:12:12 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-20 14:25:01 +0100
commit9926c0bf2f272d386911639635885fc8c55abc14 (patch)
treec7e738e71765fb364b5507baf4a8dfff11ae6d61 /documentation/set_versions.py
parent102278a77f01fe0363f9a95b2c07fd15811a7b4a (diff)
downloadpoky-9926c0bf2f272d386911639635885fc8c55abc14.tar.gz
docs: auto-generate releases.rst
In order to maintain one less file, let's auto-generate the releases.rst file which contains a link for each release ever released. This gets auto-generated by checking the tags available in this git repo and adding a link for each that exists. A few tags are notoriously missing from this git repo and they are manually listed then, until the tags are pushed for the appropriate commit. Cc: Quentin Schulz <foss@0leil.net> (From yocto-docs rev: c581eda3f87390b3e5223daff74d0ed6567ec51a) Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Reviewed-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/set_versions.py')
-rwxr-xr-xdocumentation/set_versions.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index a7ceb3455a..ddf70851cb 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -1,9 +1,11 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2# 2#
3# Add version information to poky.yaml based upon current git branch/tags 3# Add version information to poky.yaml based upon current git branch/tags
4# Also generate the list of available manuals (releases.rst file)
4# 5#
5# Copyright Linux Foundation 6# Copyright Linux Foundation
6# Author: Richard Purdie <richard.purdie@linuxfoundation.org> 7# Author: Richard Purdie <richard.purdie@linuxfoundation.org>
8# Author: Quentin Schulz <foss@0leil.net>
7# 9#
8# SPDX-License-Identifier: MIT 10# SPDX-License-Identifier: MIT
9# 11#
@@ -14,6 +16,7 @@ import collections
14import sys 16import sys
15import os 17import os
16import itertools 18import itertools
19import re
17 20
18ourversion = None 21ourversion = None
19if len(sys.argv) == 2: 22if len(sys.argv) == 2:
@@ -231,3 +234,77 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch
231 234
232print("switchers.js generated from switchers.js.in") 235print("switchers.js generated from switchers.js.in")
233 236
237# generate releases.rst
238
239# list missing tags in yocto-docs
240missing_tags = [
241 'yocto-0.9',
242 'yocto-1.0', 'yocto-1.0.1',
243 'yocto-1.1', 'yocto-1.1.1',
244 'yocto-1.2',
245 'yocto-1.4.4', 'yocto-1.4.5',
246 'yocto-1.5', 'yocto-1.5.2', 'yocto-1.5.3', 'yocto-1.5.4',
247 'yocto-1.6', 'yocto-1.6.1', 'yocto-1.6.2',
248 'yocto-1.7', 'yocto-1.7.1',
249 'yocto-1.9',
250 'yocto-2.5.3',
251 'yocto-3.1', 'yocto-3.1.1', 'yocto-3.1.2', 'yocto-3.1.3',
252 ]
253
254semver = re.compile(r'yocto-(\d+)\.(\d+)(?:\.)?(\d*)')
255
256# git is able to properly order semver versions but not python
257# instead of adding a dependency on semver module, let's convert the version
258# into a decimal number, e.g. 11.23.1 will be 112301 and 1.5 will be 010500 so
259# it can be used as a key for the sorting algorithm.
260# This can be removed once all the old tags are re-created.
261def tag_to_semver_like(v):
262 v_semver = semver.search(v)
263 v_maj, v_min, v_patch = v_semver.groups('0')
264 return int("{:0>2}{:0>2}{:0>2}".format(v_maj, v_min, v_patch), 10)
265
266yocto_tags = subprocess.run(["git", "tag", "--list", "--sort=version:refname", "yocto-*"], capture_output=True, text=True).stdout
267yocto_tags = sorted(yocto_tags.split() + missing_tags, key=tag_to_semver_like)
268tags = [tag[6:] for tag in yocto_tags]
269
270with open('releases.rst', 'w') as f:
271 f.write('===========================\n')
272 f.write(' Supported Release Manuals\n')
273 f.write('===========================\n')
274 f.write('\n')
275
276 for activerelease in activereleases:
277 title = "Release Series %s (%s)" % (release_series[activerelease], activerelease)
278 f.write('*' * len(title) + '\n')
279 f.write(title + '\n')
280 f.write('*' * len(title) + '\n')
281 f.write('\n')
282
283 for tag in tags:
284 if tag == release_series[activerelease] or tag.startswith('%s.' % release_series[activerelease]):
285 f.write('- :yocto_docs:`%s Documentation </%s>`\n' % (tag, tag))
286 f.write('\n')
287
288 f.write('==========================\n')
289 f.write(' Outdated Release Manuals\n')
290 f.write('==========================\n')
291 f.write('\n')
292
293 for series in release_series:
294 if series == devbranch or series in activereleases:
295 continue
296
297 if series == "jethro-pre":
298 continue
299
300 title = "Release Series %s (%s)" % (release_series[series], series)
301 f.write('*' * len(title) + '\n')
302 f.write(title + '\n')
303 f.write('*' * len(title) + '\n')
304 f.write('\n')
305 if series == "jethro":
306 f.write('- :yocto_docs:`1.9 Documentation </1.9>`\n')
307 for tag in tags:
308 if tag == release_series[series] or tag.startswith('%s.' % release_series[series]):
309 f.write('- :yocto_docs:`%s Documentation </%s>`\n' % (tag, tag))
310 f.write('\n')