-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from gro-intelligence/jli-updatesphinx
Update Sphinx version and migrate to sphinx-multiversion CLEWS-33782
- Loading branch information
Showing
10 changed files
with
469 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# This script replicates basic `sphinx-versioning push` functionality for | ||
# sphinx-multiversion. It should be run from the base of the git repo. | ||
# It's largely based on sphinxcontrib-versioning's code: | ||
# https://github.com/sphinx-contrib/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/__main__.py#L332 | ||
|
||
set -e -u -o pipefail | ||
|
||
# Branch to push the generated docs to. | ||
PAGES_BRANCH=gh-pages | ||
# Which branch to store at the root of the docs. Analogous to scv_root_ref: | ||
# https://sphinxcontrib-versioning.readthedocs.io/en/latest/settings.html#cmdoption-r | ||
ROOT_REF=development | ||
# Files to keep in the repo. Analogous to scv_grm_exclude: | ||
# https://sphinxcontrib-versioning.readthedocs.io/en/latest/settings.html#cmdoption-e | ||
KEEP_FILES=(.nojekyll CNAME README.md shippable.yml) | ||
|
||
# get origin repo. assumes fetch and pull locations are the same. | ||
REPO=$(git remote -v | grep origin | awk 'NR==1 { print $2 }') | ||
TMPDIR=$(mktemp -d ./tmp-sphinx.XXX) | ||
|
||
|
||
## prepare helper repo | ||
|
||
# clone into temp dir | ||
echo -e "\n-> cloning $REPO to temp dir $TMPDIR..." | ||
cd "$TMPDIR" | ||
git clone "$REPO" --quiet --depth=1 --branch="${PAGES_BRANCH}" . | ||
# remove old files | ||
git rm -rf --quiet . | ||
# restore some files we want to keep. note: using bash array syntax. | ||
git reset --quiet HEAD -- "${KEEP_FILES[@]}" | ||
git checkout -- "${KEEP_FILES[@]}" | ||
|
||
|
||
## build docs | ||
|
||
echo -e "\n-> building docs..." | ||
# 'sphinx-multiversion ../docs .' fails, so we just cd back out for this step. | ||
cd .. | ||
sphinx-multiversion docs "$TMPDIR" | ||
cd "$TMPDIR" | ||
|
||
# With sphinxcontrib-versioning, we would generate a separate directory of docs | ||
# for each version tag and branch, but also have the 'development' branch's | ||
# docs at the top level. sphinx-multiversion only generates the separate | ||
# directories. To avoid breaking links, we copy the the root ref docs (i.e., | ||
# the development branch docs) to the parent directory containing all docs. | ||
echo -e "\n-> copying root ref ($ROOT_REF) to docs root..." | ||
cp -R "${ROOT_REF}/." . | ||
|
||
echo -e "\n-> checking for changes..." | ||
git add . | ||
# ignore trivial changes (.doctrees and .buildinfo files are always modified | ||
# when rebuilding the docs). Notes: | ||
# - '|| true' is needed because when grep fails to match something, it returns | ||
# a non-zero exit code, which causes the script to fail due to the 'pipefail' | ||
# setting. | ||
# - this logic differs from sphinxcontrib-versioning slightly. SCV ignores | ||
# searchindex.js but not .buildinfo. I didn't notice searchindex.js being | ||
# regenerated unnecessarily, but did see that happening with .buildinfo files. | ||
CHANGED=$(git diff HEAD --no-ext-diff --name-status | grep -v '^M.*\.doctrees/' | grep -v '^M.*\.buildinfo$' || true) | ||
if [ -z "$CHANGED" ]; then | ||
echo -e "\n-> no changes, done!" | ||
exit 0 | ||
else | ||
echo -e "\n-> found changed files:" | ||
echo "$CHANGED" | ||
fi | ||
|
||
echo -e "\n-> committing change..." | ||
git commit -m "sphinx_push_ghpages.sh: autocommit $(date '+%Y-%m-%d %H:%M:%S')" | ||
|
||
echo -e "\n-> pushing update..." | ||
git push origin "$PAGES_BRANCH" | ||
|
||
echo -e "\n-> done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
/* https://github.com/sphinx-contrib/sphinxcontrib-versioning/blob/master/sphinxcontrib/versioning/_static/banner.css */ | ||
|
||
.scv-banner { | ||
padding: 3px; | ||
border-radius: 2px; | ||
font-size: 80%; | ||
text-align: center; | ||
color: white; | ||
background: #2980B9; | ||
/* based on https://github.com/sphinx-contrib/sphinxcontrib-versioning/blob/master/sphinxcontrib/versioning/_static/banner.css */ | ||
|
||
.version-banner { | ||
padding: 3px; | ||
border-radius: 2px; | ||
font-size: 80%; | ||
text-align: center; | ||
color: white; | ||
background: #d40 linear-gradient(-45deg, | ||
rgba(255, 255, 255, 0.2) 0%, | ||
rgba(255, 255, 255, 0.2) 25%, | ||
transparent 25%, | ||
transparent 50%, | ||
rgba(255, 255, 255, 0.2) 50%, | ||
rgba(255, 255, 255, 0.2) 75%, | ||
transparent 75%, | ||
transparent | ||
); | ||
background-size: 28px 28px; | ||
/* from sphinx_rtd_theme selector: use bluish background */ | ||
background-color: #2980B9; | ||
} | ||
|
||
.scv-banner > a { | ||
color: white; | ||
.version-banner a, .version-banner a:visited { | ||
color: white; | ||
} | ||
|
||
|
||
.scv-bizstyle { | ||
background-color: #336699; | ||
} | ||
|
||
|
||
.scv-classic { | ||
text-align: center !important; | ||
} | ||
|
||
|
||
.scv-traditional { | ||
text-align: center !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{# | ||
See https://holzhaus.github.io/sphinx-multiversion/master/templates.html#version-banners | ||
|
||
TODO(jli): The example above nicely links to the latest *released* version, | ||
rather than development. That's probably the way to go, since almost all users | ||
should be using our PyPI package. However, the 'latest_version' variable seems | ||
to be hardcoded to "master". Would be great if it actually used the latest | ||
released tag instead. | ||
|
||
Also see: https://github.com/Holzhaus/sphinx-multiversion/issues/58 | ||
#} | ||
|
||
{% extends "!page.html" %} | ||
{% block body %} | ||
{% if current_version and current_version.name != 'development' %} | ||
<p class="version-banner"> | ||
<strong>Note:</strong> | ||
This document is for an older version of the Gro API Client. | ||
Please see the <a href="{{ vpathto('development') }}">latest documentation</a>. | ||
</p> | ||
{% endif %} | ||
{{ super() }} | ||
{% endblock %}% | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{# | ||
Based on https://holzhaus.github.io/sphinx-multiversion/master/templates.html#readthedocs-theme | ||
This is the template for the version-selector widget at the bottom left corner. | ||
We list the tags as "Releases", and we include the "development" branch at the | ||
end of the list. | ||
#} | ||
{%- if current_version %} | ||
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> | ||
<span class="rst-current-version" data-toggle="rst-current-version"> | ||
<span class="fa fa-book"> Other Versions</span> | ||
v: {{ current_version.name }} | ||
<span class="fa fa-caret-down"></span> | ||
</span> | ||
<div class="rst-other-versions"> | ||
{%- if versions.tags %} | ||
<dl> | ||
<dt>Releases</dt> | ||
{%- for item in versions.tags %} | ||
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd> | ||
{%- endfor %} | ||
|
||
{# we also list the development branch here so that it's always accessible. #} | ||
{%- if versions.branches %} | ||
{%- for item in versions.branches %} | ||
{%- if item.name == 'development' %} | ||
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd> | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- endif %} | ||
</dl> | ||
{%- endif %} | ||
</div> | ||
</div> | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.