Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/publish_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
build:
env:
DOC_URL: "https://rascalsoftware.github.io/RasCAL-2/"
DOC_VERSION: "dev"
runs-on: ubuntu-latest

steps:
Expand All @@ -32,8 +33,11 @@ jobs:
- name: Build and Deploy Docs
run: |
cd main/doc
if [ ${{ github.ref_type }} == "tag" ]; then
export DOC_VERSION=${{github.ref_name}}
fi
make html
python deploy.py ${{github.ref}}
python deploy.py
cd ../../web
git config user.name github-actions
git config user.email github-actions@github.com
Expand Down
12 changes: 3 additions & 9 deletions doc/deploy.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import json
import os
import shutil
import sys
from urllib.parse import urljoin

sys.path.insert(0, os.path.abspath(".."))

from rascal2 import RASCAL2_VERSION
from version import get_doc_version


DOCS_PATH = os.path.abspath(os.path.dirname(__file__))
BUILD_PATH = os.path.join(DOCS_PATH, 'build', 'html')
ROOT_PATH = os.path.join(DOCS_PATH, "..", "..")

url = os.environ.get('DOC_URL', '')
version = str(RASCAL2_VERSION)
if len(sys.argv) > 1 and sys.argv[1].strip().endswith(version):
doc_version = version
else:
doc_version = "dev"
doc_version = get_doc_version()

WEB_PATH = os.path.join(ROOT_PATH, "web", doc_version)

if os.path.isdir(WEB_PATH):
Expand Down
17 changes: 14 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@
import os
import sys
import datetime
from urllib.parse import urljoin

sys.path.insert(0, os.path.abspath("../.."))
sys.path.insert(0, os.path.abspath(".."))

from rascal2 import RASCAL2_VERSION
from version import get_doc_version


DOCS_PATH = os.path.abspath(os.path.dirname(__file__))
BUILD_PATH = os.path.join(DOCS_PATH, 'build', 'html')
ROOT_PATH = os.path.join(DOCS_PATH, "..", "..")

url = os.environ.get('DOC_URL', '')

project = 'RasCAL-2'
copyright = u"2024-{}, ISIS Neutron and Muon Source".format(datetime.date.today().year)
author = 'ISIS Neutron and Muon Source'
version = RASCAL2_VERSION
version = get_doc_version()
# The full version, including alpha/beta/rc tags.
release = version
# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -52,6 +59,10 @@
"icon": "fa-brands fa-github",
},
],
'navbar_start': ['navbar-logo', 'version-switcher'],
'switcher': {'json_url': urljoin(url, 'switcher.json'),
'version_match': version,
'check_switcher': False, },
}

html_sidebars = {
Expand Down
22 changes: 22 additions & 0 deletions doc/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import re

# The regex for major, minor and bugfix version, including alpha/beta/rc tags
VERSION_REGEX = re.compile(r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)"
r"(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
r"(?:\.(?:0|[1-9]\d*|\d *[a-zA-Z-][0-9a-zA-Z-]*))*))?"
r"(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?")


def get_doc_version():
"""Grabs doc version from environment variable"""
doc_version = 'dev'
version = os.environ.get('DOC_VERSION', 'dev')

if version != 'dev':
tmp = VERSION_REGEX.match(version.replace(' ', ''))
if tmp is not None:
major, minor, *other = list(tmp.groups())
doc_version = f'{major}.{minor}'

return doc_version
Loading