Skip to content

Commit f95f195

Browse files
committed
Special setup to allow mutliversion docs with the latest one shown by default
It works by placing a tiny index HTML fragment at the site root, which just links to the latest docs. Readers can tweak the URL to point to a previous version of the docs if they need to. Not ideal, but workable. Also, we now only refer to docs URLs by the major and minor version numbers, we ignore patch versions. This should mean that for any given minor version, the latest patch version to be released is the one which that minor version URL will provide.
1 parent f5a4d59 commit f95f195

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

.github/workflows/build-release.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,27 @@ jobs:
6363
needs: build-release
6464
steps:
6565
- uses: actions/checkout@v2
66-
- name: Set Tag / Branch Name
66+
- name: Set Tag Name
6767
shell: bash
68+
# trim prefix from ref to get tag name
6869
run: echo "TAG_NAME=${GITHUB_REF#'refs/tags/'}" >> $GITHUB_ENV
70+
- name: Format Docs Version Name
71+
shell: bash
72+
# trim patch version off version number as minor version specifies ABI changes
73+
run: echo "DOCS_VERSION=${TAG_NAME%.*}" >> $GITHUB_ENV
6974
- name: Build Doxygen Docs
7075
uses: mattnotmitt/[email protected]
76+
- name: Set up latest docs auto-linking
77+
shell: bash
78+
# make docs folder, move docs there, call script to generate HTML redirect in index
79+
run: |
80+
mkdir docs
81+
mv html docs/$DOCS_VERSION
82+
./generate_index $DOCS_VERSION
7183
- name: Deploy Docs to github-pages
7284
uses: JamesIves/[email protected]
7385
with:
7486
branch: gh-pages
7587
folder: html
76-
target-folder: ${{env.TAG_NAME}}
88+
target-folder: ${{env.DOCS_VERSION}}
7789
clean: false

generate_index

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# This script generates a tiny HTML file whose sole purpose is to
4+
# redirect to whichever folder the latest version of the docs is in
5+
#
6+
# This keeps things fairly simple, if a little clunky, as Github Pages
7+
# is a static site hosting service only (unless you're using Jekyll)
8+
# and Doxygen didn't support multi-version documentation sites at the
9+
# time of writing.
10+
11+
# pass version string for where the latest docs are as single parameter
12+
DOCS_VERSION=$1;
13+
# HTML template with DOCS_VERSION substituted
14+
HTML_FRAGMENT="<head><meta http-equiv='refresh' content='0; URL=${DOCS_VERSION}/'/></head><body><p>If you are not redirected in five seconds,<a href='${DOCS_VERSION}/'>click here</a>.</p></body>";
15+
# write out to the index HTML file that will appear at the root of Github Pages
16+
echo $HTML_FRAGMENT > "docs/index.html";

0 commit comments

Comments
 (0)