From a8fff4f041ffc021788e9d5dda1d158cc19db0bb Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Thu, 12 Nov 2020 09:46:14 +0900 Subject: [PATCH 1/4] Implement multiversion building for the docs Use sphinx-multiversion instead of sphinx-build Configure multiversion builds in docs conf file Use RTD theme because it supports multiversion, remove msmb_theme Add sphinx-multiversion to requirements --- docs/Makefile | 8 ++++---- docs/conf.py | 28 +++++++++++++++++++--------- extra-requirements.txt | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index cf356e4f..61d93eff 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build +SPHINXBUILD ?= sphinx-multiversion SOURCEDIR = . BUILDDIR = _build @@ -17,18 +17,18 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @$(SPHINXBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) clean: rm -rf $(BUILDDIR)/* rm -rf auto_examples/ html-noplot: - $(SPHINXBUILD) -D plot_gallery=0 -b html $(SOURCEDIR) $(BUILDDIR)/html + $(SPHINXBUILD) -D plot_gallery=0 $(SOURCEDIR) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." html-examples-short: - $(SPHINXBUILD) -D reset_argv=1 -b html $(SOURCEDIR) $(BUILDDIR)/html + $(SPHINXBUILD) -D reset_argv=1 $(SOURCEDIR) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." diff --git a/docs/conf.py b/docs/conf.py index 749d0dcd..b444b4c2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,21 +10,21 @@ import os import sys -import msmb_theme +import sphinx_rtd_theme + +# -- Project information ----------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import cgp +rootdir = os.path.join(os.getenv("SPHINX_MULTIVERSION_SOURCEDIR", default="."), "../") +sys.path.insert(0, rootdir) -sys.path.insert(0, os.path.join(os.path.abspath("."), "../")) - - -# -- Project information ----------------------------------------------------- +import cgp # noqa: E402 isort:skip project = "hal-cgp" -copyright = "2020, Happy Algorithms League" +copyright = "2021, Happy Algorithms League" author = cgp.__author__ # The full version, including alpha/beta/rc tags @@ -40,7 +40,9 @@ "sphinx.ext.autodoc", "sphinx.ext.linkcode", "recommonmark", + "sphinx_rtd_theme", "sphinx_gallery.gen_gallery", + "sphinx_multiversion", ] # Add any paths that contain templates here, relative to this directory. @@ -57,9 +59,17 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = "msmb_theme" +html_theme = "sphinx_rtd_theme" + +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + -html_theme_path = [msmb_theme.get_html_theme_path()] +# Configuration for multiversion builds +smv_branch_whitelist = "master" # Only build master branch +smv_remote_whitelist = None +smv_tag_whitelist = "0.2.0" # Only release 0.2.0 has a sphinx documentation +smv_released_pattern = r".*" # Tags only +smv_outputdir_format = "{ref.name}" # Use the branch/tag name # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/extra-requirements.txt b/extra-requirements.txt index 24db559c..5d8bcd8f 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -12,7 +12,7 @@ isort ~=5.2.2 # doc requirements sphinx ~=3.1.2 recommonmark~=0.6.0 -msmb_theme~=1.2.0 sphinx-rtd-theme~=0.5.0 sphinx-gallery~=0.8.0 pillow~=8.1.1 +sphinx-multiversion~=0.2.4 From 6fc4dd524e4445177e4c1f26eed556f3de545832 Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Thu, 8 Apr 2021 13:46:56 +0900 Subject: [PATCH 2/4] Change branch pattern and get master of sphinx-multiversion --- docs/conf.py | 7 ++++--- extra-requirements.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b444b4c2..a99f8b4e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,11 +18,12 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -rootdir = os.path.join(os.getenv("SPHINX_MULTIVERSION_SOURCEDIR", default="."), "../") +rootdir = os.path.join(os.getenv("SPHINX_MULTIVERSION_SOURCEDIR", default=os.getcwd()), "../") sys.path.insert(0, rootdir) - +print(sys.path) import cgp # noqa: E402 isort:skip +print(cgp.__version__) project = "hal-cgp" copyright = "2021, Happy Algorithms League" author = cgp.__author__ @@ -66,7 +67,7 @@ # Configuration for multiversion builds smv_branch_whitelist = "master" # Only build master branch -smv_remote_whitelist = None +smv_remote_whitelist = r"^(origin)$" smv_tag_whitelist = "0.2.0" # Only release 0.2.0 has a sphinx documentation smv_released_pattern = r".*" # Tags only smv_outputdir_format = "{ref.name}" # Use the branch/tag name diff --git a/extra-requirements.txt b/extra-requirements.txt index 5d8bcd8f..77f40dd8 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -15,4 +15,4 @@ recommonmark~=0.6.0 sphinx-rtd-theme~=0.5.0 sphinx-gallery~=0.8.0 pillow~=8.1.1 -sphinx-multiversion~=0.2.4 +git+git://github.com/Holzhaus/sphinx-multiversion@master From 5a80744ee9af8e43cd17b940054a308c1a08bb24 Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Thu, 8 Apr 2021 22:14:13 +0900 Subject: [PATCH 3/4] Fix github dependency --- docs/conf.py | 2 +- extra-requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a99f8b4e..27cda803 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ # Configuration for multiversion builds smv_branch_whitelist = "master" # Only build master branch -smv_remote_whitelist = r"^(origin)$" +smv_remote_whitelist = r"^.*$" smv_tag_whitelist = "0.2.0" # Only release 0.2.0 has a sphinx documentation smv_released_pattern = r".*" # Tags only smv_outputdir_format = "{ref.name}" # Use the branch/tag name diff --git a/extra-requirements.txt b/extra-requirements.txt index 77f40dd8..cde669ce 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -15,4 +15,4 @@ recommonmark~=0.6.0 sphinx-rtd-theme~=0.5.0 sphinx-gallery~=0.8.0 pillow~=8.1.1 -git+git://github.com/Holzhaus/sphinx-multiversion@master +sphinx-multiversion@git+https://git@github.com/Holzhaus/sphinx-multiversion#master From a56279969c7f2f2c04373e2a66284095405bf5fa Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt Date: Thu, 8 Apr 2021 23:01:01 +0900 Subject: [PATCH 4/4] Fetch tags --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 83058fe4..99efa684 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -45,6 +45,7 @@ jobs: - name: Build Documentation run: | pip install gym || exit 1; + git fetch --all --tags; make -C docs/ html-examples-short || exit 1; if: matrix.python-version == 3.8 && matrix.dep == '[all]' - name: Coveralls