Skip to content

Commit 56bde5f

Browse files
authored
Merge pull request #196 from compas-dev/doc_versions
Doc versioning
2 parents eec1f04 + fdb513d commit 56bde5f

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

.bumpversion.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ tag = True
88
search = version = release = '{current_version}'
99
replace = version = release = '{new_version}'
1010

11+
[bumpversion:file:docs/doc_versions.txt]
12+
search = {current_version}
13+
replace = {new_version}
14+
{current_version}
15+
1116
[bumpversion:file:src/compas_fab/__version__.py]
1217
search = __version__ = '{current_version}'
1318
replace = __version__ = '{new_version}'

.github/workflows/docs.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,27 @@ jobs:
2525
- name: Install
2626
run: |
2727
python -m pip install --no-cache-dir -r requirements-dev.txt
28-
- name: Get branch/tag name
29-
id: get-branch
30-
uses: ypicard/get-branch-name-github-action@v1
3128
- name: Generate docs
3229
if: ${{ success() }}
3330
run: |
3431
invoke docs
35-
mkdir -p deploy/compas_fab/${{ steps.get-branch.outputs.tag }} && mv -T dist/docs deploy/compas_fab/${{ steps.get-branch.outputs.tag }}/
32+
33+
# Get branch/tag/latest name from git
34+
GITHUB_REF_REGEX="tags/([0-9a-zA-Z\.\-]+)|(pull/[0-9]+)|heads/(.+)"
35+
36+
if [[ $GITHUB_REF =~ $GITHUB_REF_REGEX ]]; then
37+
if [[ $BASH_REMATCH = pull* ]]; then
38+
BRANCH_OR_TAG=pull_${BASH_REMATCH##*/}
39+
else
40+
BRANCH_OR_TAG=${BASH_REMATCH##*/}
41+
fi;
42+
if [[ $BRANCH_OR_TAG = master ]]; then
43+
BRANCH_OR_TAG=latest
44+
fi;
45+
fi;
46+
47+
echo "Docs will be deployed to https://gramaziokohler.github.io/compas_fab/$BRANCH_OR_TAG"
48+
mkdir -p deploy/compas_fab/$BRANCH_OR_TAG && mv -T dist/docs deploy/compas_fab/$BRANCH_OR_TAG/
3649
- name: Deploy docs
3750
if: success()
3851
uses: crazy-max/ghaction-github-pages@v2

docs/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
# autosummary options
6060
autosummary_generate = True
6161

62+
# collect doc versions
63+
package_docs_root = 'https://gramaziokohler.github.io/compas_fab/'
64+
65+
with open(os.path.join(os.path.dirname(__file__), 'doc_versions.txt'), 'r') as f:
66+
version_names = [version.strip() for version in f.readlines()]
67+
package_docs_versions = [(version, '{}{}'.format(package_docs_root, version))
68+
for version in version_names if version]
69+
6270
# on_rtd is whether we are on readthedocs.org
6371
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
6472
html_theme = 'compaspkg'
@@ -68,6 +76,8 @@
6876
"package_title": project,
6977
"package_version": release,
7078
"package_repo": 'https://github.com/compas-dev/compas_fab',
79+
"package_docs": package_docs_root,
80+
"package_old_versions": package_docs_versions
7181
}
7282

7383
html_split_index = False

docs/doc_versions.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
latest
2+
stable
3+
0.11.0
4+
0.10.1
5+
0.10.0
6+
0.1.0

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
attrs>=19.3.0
2-
sphinx_compas_theme>=0.4
2+
sphinx_compas_theme>=0.9
33
sphinx>=1.6
44
invoke>=0.14
5-
bump2version>=0.5.11
5+
bump2version>=1.0
66
check-manifest>=0.36
77
flake8
88
autopep8

0 commit comments

Comments
 (0)