diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0506aae..e7501bc 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,6 +4,7 @@ on: push: branches: - devel-2.0 + - master workflow_dispatch: permissions: @@ -23,6 +24,14 @@ jobs: - name: Checkout uses: actions/checkout@v6 + - name: Define documentation versions + run: | + { + echo 'BLEND_DOC_VERSIONS<> "${GITHUB_ENV}" + - name: Set up Python uses: actions/setup-python@v6 with: @@ -42,22 +51,46 @@ jobs: texlive-latex-extra \ texlive-latex-recommended - - name: Configure CMake + - name: Configure development documentation run: | - cmake -S . -B build \ + cmake -S . -B build-devel \ -DBLEND_BUILD_DOCS=ON \ -DBLEND_BUILD_EXAMPLES=OFF \ -DBLEND_BUILD_TESTS=OFF \ -DSPHINX_BUILD_EXECUTABLE="$(command -v sphinx-build)" - - name: Build HTML and PDF documentation - run: cmake --build build --target docs + - name: Build development documentation + env: + BLEND_DOC_CURRENT_VERSION: devel-2.0 + BLEND_DOC_GITHUB_VERSION: devel-2.0 + run: cmake --build build-devel --target docs + + - name: Configure 2.0.0 documentation + run: | + cmake -S . -B build-2.0.0 \ + -DBLEND_BUILD_DOCS=ON \ + -DBLEND_BUILD_EXAMPLES=OFF \ + -DBLEND_BUILD_TESTS=OFF \ + -DSPHINX_BUILD_EXECUTABLE="$(command -v sphinx-build)" + + - name: Build 2.0.0 documentation + env: + BLEND_DOC_CURRENT_VERSION: 2.0.0 + BLEND_DOC_GITHUB_VERSION: v2.0.0 + run: cmake --build build-2.0.0 --target docs + + - name: Assemble documentation site + run: | + cmake -E make_directory build/site + cmake -E copy_directory build-devel/doc/html build/site + cmake -E make_directory build/site/2.0.0 + cmake -E copy_directory build-2.0.0/doc/html build/site/2.0.0 - name: Check documentation links - run: python .github/scripts/check_docs_links.py build/doc/html + run: python .github/scripts/check_docs_links.py build/site - name: Disable Jekyll processing - run: touch build/doc/html/.nojekyll + run: touch build/site/.nojekyll - name: Configure GitHub Pages uses: actions/configure-pages@v6 @@ -65,7 +98,7 @@ jobs: - name: Upload GitHub Pages artifact uses: actions/upload-pages-artifact@v5 with: - path: build/doc/html + path: build/site deploy: name: Deploy documentation diff --git a/README.md b/README.md index 1b98378..104c4c9 100755 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![CI](https://github.com/Bioye97/blend/actions/workflows/ci.yml/badge.svg)](https://github.com/Bioye97/blend/actions/workflows/ci.yml) [![Documentation](https://github.com/Bioye97/blend/actions/workflows/pages.yml/badge.svg)](https://github.com/Bioye97/blend/actions/workflows/pages.yml) [![Documentation](https://img.shields.io/badge/docs-latest-green.svg)](https://bioye97.github.io/blend/) -[![GitHub release](https://img.shields.io/github/v/release/Bioye97/blend)](https://github.com/Bioye97/blend/releases) -[![License](https://img.shields.io/github/license/Bioye97/blend)](https://github.com/Bioye97/blend) +[![GitHub release](https://img.shields.io/github/v/tag/Bioye97/blend?label=release&sort=semver)](https://github.com/Bioye97/blend/releases/tag/v2.0.0) +[![License](https://img.shields.io/badge/license-LGPL--3.0-blue.svg)](LICENSE) ## What is BLEND? diff --git a/doc/rst/source/conf.py b/doc/rst/source/conf.py index f6a924b..8ed3803 100644 --- a/doc/rst/source/conf.py +++ b/doc/rst/source/conf.py @@ -1,4 +1,5 @@ import importlib.util +import json import os from pathlib import Path @@ -35,16 +36,38 @@ "navigation_depth": 4, "style_external_links": True, } + + +def _blend_versions(): + default_versions = [ + ("devel-2.0", "https://bioye97.github.io/blend/"), + ("2.0.0", "https://bioye97.github.io/blend/2.0.0/"), + ] + raw_versions = os.environ.get("BLEND_DOC_VERSIONS") + if not raw_versions: + return default_versions + + try: + versions = json.loads(raw_versions) + except json.JSONDecodeError as exc: + raise RuntimeError("BLEND_DOC_VERSIONS must be JSON") from exc + + parsed_versions = [] + for item in versions: + if not isinstance(item, list) or len(item) != 2: + raise RuntimeError("BLEND_DOC_VERSIONS entries must be [label, url] pairs") + parsed_versions.append((str(item[0]), str(item[1]))) + return parsed_versions + + html_context = { "display_github": True, "github_user": "Bioye97", "github_repo": "blend", - "github_version": "devel-2.0", + "github_version": os.environ.get("BLEND_DOC_GITHUB_VERSION", "devel-2.0"), "conf_py_path": "/doc/rst/source/", - "blend_current_version": "devel-2.0", - "blend_versions": [ - ("devel-2.0", "https://bioye97.github.io/blend/"), - ], + "blend_current_version": os.environ.get("BLEND_DOC_CURRENT_VERSION", "devel-2.0"), + "blend_versions": _blend_versions(), } latex_documents = [