From a39a03faa171c1fa36b955c68db1ebfc17ad7813 Mon Sep 17 00:00:00 2001 From: David Hart Date: Mon, 7 Oct 2024 14:23:57 -0600 Subject: [PATCH] docs: build script failed to check out --- .github/workflows/gh-pages.yml | 13 +++++--- build_docs.py | 57 +++++++--------------------------- 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index e9548bb..60c8a93 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -54,17 +54,22 @@ jobs: - name: Install dependencies run: | sudo apt-get install -y doxygen graphviz - python3 -m pip install --upgrade pip - python3 -m pip install -r requirements.txt -r docs/requirements.txt + python -m pip install --upgrade pip + python -m pip install -r requirements.txt -r docs/requirements.txt - name: Build documentation run: | - python3 build_docs.py + python -m pip install -e .[formats] + sphinx-build -b html docs/ pages/ + + - name: Get previous documentation + run: | + python build_docs.py - name: Upload artifact uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: - path: 'docs/_build/html' + path: 'pages' deploy: name: Deploy documentation to GitHub Pages diff --git a/build_docs.py b/build_docs.py index a80c37f..f030790 100644 --- a/build_docs.py +++ b/build_docs.py @@ -8,6 +8,8 @@ import os import glob +my_env = os.environ.copy() + git_tag = subprocess.run( " ".join(["git", "tag", "--list", "v*.*.*", "--sort=version:refname"]), capture_output=True, @@ -15,14 +17,12 @@ shell=True, ) -my_env = os.environ.copy() - tags = git_tag.stdout.splitlines() versions = [ { - "name": "main", + "name": "main branch", "version": "main", - "url": "https://sandialabs.github.io/sansmic/main/", + "url": "https://sandialabs.github.io/sansmic/", "preferred": False, } ] @@ -33,14 +33,6 @@ if not found_stable and not "-" in tag: latest = True found_stable = tag - versions.append( - dict( - name=latest, - version=tag, - url="https://sandialabs.github.io/sansmic/", - preferred=True, - ) - ) else: latest = False versions.append( @@ -48,34 +40,15 @@ name=tag, version=tag, url="https://sandialabs.github.io/sansmic/" + tag + "/", - preferred=False, + preferred=latest, ) ) -if not found_stable: - found_stable = "main" -tag = found_stable -os.environ["VERSION_INFO"] = repr(tag) -my_env["SANSMIC_SPHINX_VERSION"] = tag -files = glob.glob("./docs/apidocs/*.rst") -for f in files: - os.remove(f) -subprocess.run("git checkout " + tag, shell=True) -subprocess.run( - " ".join( - [ - "sphinx-build", - "-b", - "html", - "docs/", - "docs/_build/html", - ] - ), - shell=True, - env=my_env, -) - -tags.append("main") +with open( + os.path.abspath(os.path.join(".", "pages", "_static", "switcher.json")), + "w", +) as fswitch: + json.dump(versions, fswitch) for tag in tags: os.environ["VERSION_INFO"] = repr(tag) @@ -91,17 +64,9 @@ "-b", "html", "docs/", - "docs/_build/html/" + tag, + "pages/" + tag, ] ), shell=True, env=my_env, ) - -with open( - os.path.abspath( - os.path.join(".", "docs", "_build", "html", "_static", "switcher.json") - ), - "w", -) as fswitch: - json.dump(versions, fswitch)