diff --git a/.github/workflows/documentation_release.yml b/.github/workflows/documentation_release.yml new file mode 100644 index 00000000..2b08ab63 --- /dev/null +++ b/.github/workflows/documentation_release.yml @@ -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 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation_update_dev.yml similarity index 82% rename from .github/workflows/documentation.yml rename to .github/workflows/documentation_update_dev.yml index 41934563..8bb539c9 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation_update_dev.yml @@ -1,4 +1,4 @@ -name: documentation +name: documentation update dev on: pull_request: @@ -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 \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 4af84bb2..e8569265 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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")) @@ -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 --------------------------------------------------- @@ -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'], +} \ No newline at end of file diff --git a/docs/version_switcher.json b/docs/version_switcher.json new file mode 100644 index 00000000..5b38419d --- /dev/null +++ b/docs/version_switcher.json @@ -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" + } +] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ea4bbfd9..f8fcb9f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,9 +43,8 @@ tests = [ ] docs = [ "sphinx", - "sphinx_rtd_theme", + "pydata-sphinx-theme", "sphinx_autodoc_typehints", - "sphinx_rtd_theme", ] [project.scripts]