Skip to content

Commit 10820d2

Browse files
committed
Added simple implementation of versioned Doxygen docs. Close #7
THE FOLLOWING PREREQUISITES/ASSUMPTIONS ARE REQUIRED FOR THIS FEATURE TO WORK: - all release tags need to be of the form "vN.N.N" where N is a number (semantic versioning) - project should observe semantic versioning requirements for API changes, as docs are only generated for _minor_ versions, i.e. the docs for latest patch release 1.2.3 will overwrite the docs for patch version 1.2.2, being placed under the /v1.2/ docs subdirectory - the assumption is made that users accessing the docs from the site root want to be redirected to the latest version docs. There isn't a menu for browsing different versions of the docs, but one can manually change the URL to access docs for a given version that are known to exist. - docs for old minor versions are not deleted, only updated when new patch versions for them are released. This means that if a large number of minor versions are iterated over, the github-pages branch will become quite full! However, one can always manually delete the folders for old minor versions that are no longer needed.
1 parent f615c5c commit 10820d2

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.github/workflows/build-release.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [published]
66

77
jobs:
8-
build:
8+
build-release:
99
runs-on: ${{ matrix.os }}
1010
env:
1111
BUILD_TYPE: Release
@@ -57,3 +57,33 @@ jobs:
5757
with:
5858
name: project_build_${{ github.run_number }}_${{ matrix.platform_name }}
5959
path: ${{github.workspace}}/artifacts
60+
build-docs:
61+
runs-on: ubuntu-20.04
62+
# don't deploy docs unless release build succeeds
63+
needs: build-release
64+
steps:
65+
- uses: actions/checkout@v2
66+
- name: Set Tag Name
67+
shell: bash
68+
# trim prefix from ref to get tag name
69+
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
74+
- name: Build Doxygen Docs
75+
uses: mattnotmitt/[email protected]
76+
- name: Set up latest docs auto-linking
77+
shell: bash
78+
working-directory: ${{github.workspace}}
79+
# make docs folder, move docs there, call script to generate HTML redirect in index
80+
run: |
81+
mkdir docs
82+
cp -R html docs/$DOCS_VERSION
83+
./generate_index $DOCS_VERSION
84+
- name: Deploy Docs to github-pages
85+
uses: JamesIves/[email protected]
86+
with:
87+
branch: gh-pages
88+
folder: docs
89+
clean: false

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ on:
88
types: [opened, synchronize]
99

1010
jobs:
11-
build:
11+
test-docs-build:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Build Doxygen Docs
16+
uses: mattnotmitt/[email protected]
17+
18+
continuous-integration:
1219
runs-on: ${{ matrix.os }}
1320
env:
1421
BUILD_TYPE: Debug

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "C++20 Cross Platform Template"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER =
41+
PROJECT_NUMBER = $(TAG_NAME)
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

generate_index

Lines changed: 16 additions & 0 deletions
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)