From e39e194f585dd1aaaf56313660a8b56984bd3f77 Mon Sep 17 00:00:00 2001 From: David Hart Date: Wed, 20 Nov 2024 14:30:57 -0700 Subject: [PATCH] docs: Move multi-site build configuration to helper repo --- .github/workflows/gh-pages.yml | 34 ++++++++++++++------ docs/conf.py | 57 ++-------------------------------- 2 files changed, 27 insertions(+), 64 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1571301..181e546 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -34,6 +34,8 @@ jobs: build: name: Build the documentation with Sphinx runs-on: ubuntu-latest + environment: + name: github-pages steps: - name: Harden Runner uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 @@ -61,29 +63,43 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt -r docs/requirements.txt + - name: Checkout docs root + run: + git clone https://github.com/sandialabs/sansmic-ci.git + python -m pip install -r sansmic-ci/docs/requirements.txt + - name: Build documentation run: | python -m pip install -e .[formats] git config set versionsort.suffix -rc - export SANSMIC_SPHINX_VERSION=${{ github.ref_name }}@`git rev-parse --short HEAD` - python build_docs.py + export SANSMIC_SPHINX_VERSION=dev + python sansmic-ci/build_switcher.py + export SANSMIC_STABLE_VERSION=`cat stable.txt` + mkdir sansmic-ci/docs/$SANSMIC_STABLE_VERSION + touch sansmic-ci/docs/$SANSMIC_STABLE_VERSION/userman.rst + touch sansmic-ci/docs/$SANSMIC_STABLE_VERSION/refman.rst + cat sansmic-ci/docs/index.tpl | sed s/BUILD_SCRIPT_REPLACE/$SANSMIC_STABLE_VERSION/g > sansmic-ci/docs/index.rst + + sphinx-build -b html -d doctrees/root/ sansmic-ci/docs/ html/ mkdir docs/_build mkdir docs/_build/doxyxml - sphinx-build -b html docs/ out/ - git clone https://github.com/sandialabs/sansmic-docs.git release-docs + mkdir html/ + sphinx-build -b html -d doctrees/latest docs/ html/latest for TAG in `git tag --list "v*.*.*" --sort=-version:refname` do - pushd release-docs - git checkout $TAG - cp -rf html ../out/$TAG - popd + rm -rf docs + git checkout -f $TAG + export SANSMIC_SPHINX_VERSION=$TAG + cp -f sansmic-ci/docs/_static/* docs/_static/ + cp -f sansmic-ci/docs/conf.py docs/conf.py + sphinx-build -q -b html -d doctrees/$TAG docs html/$TAG done - name: Upload artifact uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 if: success() || failure() with: - path: 'out/' + path: 'html/' deploy: name: Deploy documentation to GitHub Pages diff --git a/docs/conf.py b/docs/conf.py index bc4e469..03b205c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,8 +22,7 @@ project = "sansmic" copyright = "2024 National Technology and Engineering Solutions of Sandia, LLC. Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software." author = "See AUTHORS.md" -version = os.environ.get("SANSMIC_SPHINX_VERSION", sansmic.__version__) -release = version +version = sansmic.__version__ # -- Extensions to load ------------------------------------------------------- extensions = [ @@ -212,6 +211,7 @@ # -- Options for HTML output ------------------------------------------------- html_theme = "pydata_sphinx_theme" html_static_path = ["_static"] +html_title = "Sansmic" html_js_files = [ "pypi-icon.js", ] @@ -241,65 +241,12 @@ "use_edit_page_button": False, "primary_sidebar_end": ["indices.html"], "show_toc_level": 2, - "switcher": { - "json_url": "https://sandialabs.github.io/sansmic/_static/switcher.json", - "version_match": "v" + version - if len(version) > 0 and version[0].isdigit() - else version, - }, # "secondary_sidebar_items": ["page-toc"], #["page-toc", "edit-this-page", "sourcelink"], "navbar_start": [ "navbar-logo", - "version-switcher", ], "navbar_end": [ "theme-switcher", "navbar-icon-links", ], - "analytics": {"google_analytics_id": "G-23TNKN36XM"}, -} - - -# -- Options for LaTeX output ------------------------------------------------- -latex_engine = "xelatex" -latex_use_xindy = False -latex_documents = [ - ("userman", "sansmic.tex", "User Guide for sansmic", "David Hart", "manual"), -] -latex_toplevel_sectioning = "chapter" -latex_domain_indices = False -latex_elements = { - "papersize": r"letterpaper", - "pointsize": r"10pt", - "passoptionstopackages": r""" -\PassOptionsToPackage{svgnames}{xcolor} -""", - "fontpkg": r""" -\usepackage{nimbussans} -\usepackage[nosf,nott]{kpfonts} -\usepackage[scaled=0.85]{sourcecodepro} -\usepackage[utf8x]{inputenc} -\usepackage[T1]{fontenc} -""", - "preamble": r""" -\usepackage[titles]{tocloft} -\usepackage[ - range-units=single, - per-mode=symbol, - group-digits=decimal, - group-minimum-digits=3, - group-separator={,}, - range-phrase={\,--\,}, - quotient-mode=fraction, - ]{siunitx}\cftsetpnumwidth {1.25cm} -\cftsetrmarg{1.5cm} -\setlength{\cftchapnumwidth}{0.75cm} -\setlength{\cftsecindent}{\cftchapnumwidth} -\setlength{\cftsecnumwidth}{1.25cm} -\renewcommand\sphinxcrossref[1]{#1} -\renewcommand\sphinxtermref[1]{#1} -""", - "sphinxsetup": "TitleColor=DarkGoldenrod", - "fncychap": r"\usepackage[Bjornstrup]{fncychap}", - "printindex": r"\footnotesize\raggedright\printindex", }