Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding version support to docs #196

Closed
wants to merge 3 commits into from
Closed
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
49 changes: 49 additions & 0 deletions .github/workflows/documentation_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: documentation update

on:
push:
tags:
- '*'

permissions:
contents: write

jobs:
testing:
name: Documentation
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: checkout actions
uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: install dependencies
run: conda install -c conda-forge freecad -y

- name: install package
run: |
pip install --upgrade pip
pip install .[docs]
- name: Sphinx build
run: |
sphinx-build docs _build
cp _build _build/${{ github.ref_name }}
- name: Deploy to GitHub Pages
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v4
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
# force_orphan: true https://github.com/peaceiris/actions-gh-pages/issues/455
keep_files: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: documentation
name: documentation update dev

on:
pull_request:
Expand Down Expand Up @@ -41,12 +41,13 @@ jobs:
pip install .[docs]
- name: Sphinx build
run: |
sphinx-build docs _build
sphinx-build docs _build/dev
- name: Deploy to GitHub Pages
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v4
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
publish_dir: _build/dev
# force_orphan: true https://github.com/peaceiris/actions-gh-pages/issues/455
keep_files: true
40 changes: 32 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import re
import sys

sys.path.insert(0, os.path.abspath("../../src"))
Expand All @@ -22,7 +23,12 @@
author = "Juan-Pablo Catalan and Patrick Sauvan"

# The full version, including alpha/beta/rc tags
release = "1.0.1"
# import geouned
version='1.1.0'
# version = geouned.__version__
# # The full version, including alpha/beta/rc tags.
# release = geouned.__version__



# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -51,17 +57,35 @@

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# The theme to use for HTML and HTML Help pages.
# this theme supports versions https://github.com/pydata/pydata-sphinx-theme
html_theme = "pydata_sphinx_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_context = {
"display_github": True,
}
# html_context = {
# "display_github": True,
# }
# html_favicon = "favicon.ico"

# Version match must match the 'version' key in version_swticher.json
pattern = re.compile(r'^[0-9]+\.[0-9]+')
version_match = pattern.search(version)
if version_match:
version_match = version_match.group() + ".x"
elif 'dev' in version:
version_match = "dev"
else:
version_match = version

html_theme_options = {
'switcher': {
'json_url': 'https://raw.githubusercontent.com/fusion-neutronics/GEOUNED/adding_version_support_to_docs/docs/version_switcher.json',
'version_match': '1.1.0',
},
'nav_title': 'Geouned',
'navbar_start': ['version-switcher', 'navbar-icon-links'],
}
11 changes: 11 additions & 0 deletions docs/version_switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "1.1.0 (stable)",
"version": "1.1.0",
"url": "https://geouned-org.github.io/GEOUNED/stable"
},
{
"version": "1.0.1",
"url": "https://geouned-org.github.io/GEOUNED/1.0.1"
}
]
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ tests = [
]
docs = [
"sphinx",
"sphinx_rtd_theme",
"pydata-sphinx-theme",
"sphinx_autodoc_typehints",
"sphinx_rtd_theme",
]

[project.scripts]
Expand Down
Loading