From 5b4c71905d11f68132bebfcb3eb3e247855adf4a Mon Sep 17 00:00:00 2001 From: Deepak Khatri <lorforlinux@beagleboard.org> Date: Fri, 2 Sep 2022 01:04:16 +0530 Subject: [PATCH] Update versions code --- PAGES | 0 _templates/versions.html | 8 ++++---- conf.py | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 PAGES diff --git a/PAGES b/PAGES new file mode 100644 index 00000000..e69de29b diff --git a/_templates/versions.html b/_templates/versions.html index aee13e78..eef0aa48 100644 --- a/_templates/versions.html +++ b/_templates/versions.html @@ -2,15 +2,15 @@ <div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> <span class="rst-current-version" data-toggle="rst-current-version"> <span class="fa fa-book"> BeagleBoard Project</span> - v: latest + v: {{ pages_slug }} <span class="fa fa-caret-down"></span> </span> <div class="rst-other-versions"> <dl> <dt>{{ _('Document Release Versions') }}</dt> - <dd><a href="{{pages_url}}">latest</a></dd> - <dd><a href="{{pages_url}}/0.0">0.0</a></dd> - <dd><a href="{{pages_url}}/0.1">0.1</a></dd> + {% for version_slug, version_url in versions %} + <dd><a href="{{pages_url}}{{version_url}}">{{ version_slug }}</a></dd> + {% endfor %} </dl> <dl> <dt>{{ _('Downloads') }}</dt> diff --git a/conf.py b/conf.py index 5f97e1ea..22fa763b 100644 --- a/conf.py +++ b/conf.py @@ -81,6 +81,10 @@ with open(BBDOCS_BASE / "VERSION") as f: release = version +pages_url = "" +pages_slug = "" +docs_url = "" + # parse pages details from 'PAGES' file with open(BBDOCS_BASE / "PAGES") as f: m = re.match( @@ -94,16 +98,12 @@ with open(BBDOCS_BASE / "PAGES") as f: if not m: sys.stderr.write("Warning: Could not extract pages information\n") - pages_url = "Unknown" - pages_slug = "Unknown" else: url, slug = m.groups(1) + slug = "latest" if slug == "main" else slug pages_url = url pages_slug = slug - if slug == "main": - docs_url = "/".join((url, "latest")) - else: - docs_url = "/".join((url, slug)) + docs_url = "/".join((url, slug)) html_context = { "display_gitlab": True, @@ -116,7 +116,12 @@ html_context = { "pages_url": pages_url, "pages_slug": pages_slug, "docs_url": docs_url, - "current_version": version + "current_version": version, + "versions": ( + ("latest", "/"), + ("0.0", "/0.0/"), + ("0.1", "/0.1/") + ), } # -- Options for LaTeX output --------------------------------------------- -- GitLab