Update doc deploy to skip legacy docs

This commit is contained in:
Griatch 2022-11-14 20:42:10 +01:00
parent af4af1d0c3
commit a1cc39e165
3 changed files with 74 additions and 4 deletions

View file

@ -89,7 +89,8 @@ _multiversion-build:
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXMULTIVERSION) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS)
_multiversion-deploy:
@bash -e deploy.sh
@python deploy.py
# @bash -e deploy.sh
_latex-build:
@NOAUTODOC=1 EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)/latex" $(QUICKFILES)

63
docs/deploy.py Normal file
View file

@ -0,0 +1,63 @@
"""
Deploy to github, from github Action. This is run after the docs have finished building. All new
documentation branches will be available in build/html/* at this point. We need to copy those
contents to the root of the repo.
This is assumed to be executed from inside the docs/ folder.
"""
import glob
import os
import sys
# branches that should not be rebuilt anymore (all others are considered active)
legacy_branches = ["0.9.5"]
# the branch pointed to by the 'latest' symlink
latest_branch = "0.9.5"
def deploy():
if os.popen("git status --untracked=no --porcelain"):
print(
"There are uncommitted or untracked changes. Make sure "
"to commit everything in your current branch first."
)
sys.exit(1)
# get the deployment branch
os.popen("git fetch")
os.popen("git checkout gh-pages")
for file_path in glob.glob("*"):
# run from inside the docs/ dir
# delete old but active doc branches
_, filename = file_path.rsplit("/", 1).strip()
if filename in legacy_branches:
# skip deleting the legacy brancehs
continue
else:
# we want to delete both active branches and old symlinks
os.popen(f"rm -Rf {file_path}")
# copy built branches to current dir
os.popen("cp -Rf build/html/* .")
# symlink to latest and link its index to the root
os.popen(f"ln -s {latest_branch} latest")
os.popen(f"ln -s {latest_branch}/index.html .")
# docs/build is in .gitignore so will be skipped
os.popen("git add .")
os.popen('git commit -a -m "Updated HTML docs."')
os.popen("git push origin gh-pages")
# get back to previous branch
os.popen("git checkout .")
print("Deployed to https:// evennia.github.io/evennia/")
if __name__ == "__main__":
deploy()

View file

@ -14,7 +14,7 @@ from sphinx.util.osutil import cd
# -- Project information -----------------------------------------------------
project = "Evennia"
copyright = "2020, The Evennia developer community"
copyright = "2022, The Evennia developer community"
author = "The Evennia developer community"
# The full Evennia version covered by these docs, including alpha/beta/rc tags
@ -56,6 +56,8 @@ smv_branch_whitelist = r"^develop$|^v[0-9\.]+?$"
smv_outputdir_format = "{config.release}"
# don't make docs for tags
smv_tag_whitelist = r"^$"
# legacy branches are linked to in template, but not built (custom for Evennia)
smv_legacy_branches = ["0.9.5"]
# -- Options for HTML output -------------------------------------------------
@ -348,8 +350,12 @@ def setup(app):
# build toctree file
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from docs.pylib import (auto_link_remapper, contrib_readmes2docs,
update_default_cmd_index, update_dynamic_pages)
from docs.pylib import (
auto_link_remapper,
contrib_readmes2docs,
update_default_cmd_index,
update_dynamic_pages,
)
_no_autodoc = os.environ.get("NOAUTODOC")
update_default_cmd_index.run_update(no_autodoc=_no_autodoc)