docs: generate docs for all stable versions

This generate the documentation of all versions from git tags

This uses a fresh database for running doc build and
don't hardcode the doc source directory.

Closes-Bug: #1566709
Change-Id: I9d0f1fcb2fe44177d95dee0915e849e48155f53d
This commit is contained in:
Mehdi Abaakouk 2017-02-03 18:25:49 +01:00
parent ba8c287c8a
commit c3793dd80d
3 changed files with 50 additions and 2 deletions

View File

@ -178,3 +178,10 @@ html_static_path = ['_static']
# Output file base name for HTML help builder.
htmlhelp_basename = 'gnocchidoc'
# Multiversion docs
scv_sort = ('semver',)
scv_greatest_tag = True
scv_priority = 'branches'
scv_whitelist_branches = ('master',)
scv_whitelist_tags = ('3.1.0', '3.0.4', '2.2.1')

View File

@ -15,6 +15,10 @@
# under the License.
from __future__ import absolute_import
import json
import os
import subprocess
import sys
import tempfile
import jinja2
import six
@ -24,7 +28,6 @@ import yaml
from gnocchi.tests import test_rest
# HACK(jd) Not sure why but Sphinx setup this multiple times, so we just avoid
# doing several times the requests by using this global variable :(
_RUN = False
@ -103,10 +106,44 @@ class ScenarioList(list):
return super(ScenarioList, self).__getitem__(key)
multiversion_hack = """
import sys
import os
srcdir = os.path.join("%s", "..", "..")
os.chdir(srcdir)
sys.path.insert(0, srcdir)
class FakeApp(object):
def info(self, *args, **kwasrgs):
pass
import gnocchi.gendoc
gnocchi.gendoc.setup(FakeApp())
"""
def setup(app):
global _RUN
if _RUN:
return
# NOTE(sileht): On gnocchi.xyz, we build a multiversion of the docs
# all versions are built with the master gnocchi.gendoc sphinx extension.
# So the hack here run an other python script to generate the rest.rst
# file of old version of the module.
# It also drop the database before each run.
if sys.argv[0].endswith("sphinx-versioning"):
subprocess.call(["dropdb", os.environ['PGDATABASE']])
subprocess.call(["createdb", os.environ['PGDATABASE']])
with tempfile.NamedTemporaryFile() as f:
f.write(multiversion_hack % app.confdir)
f.flush()
subprocess.call(['python', f.name])
_RUN = True
return
webapp = _setup_test_app()
# TODO(jd) Do not hardcode doc/source
with open("doc/source/rest.yaml") as f:

View File

@ -140,5 +140,9 @@ commands = doc8 --ignore-path doc/source/rest.rst doc/source
[testenv:docs-gnocchi.xyz]
deps = .[file,postgresql,test,doc]
sphinx_rtd_theme
sphinxcontrib-versioning
# for 2.x doc
pytimeparse
retrying
commands =
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- sphinx-build -D html_theme=sphinx_rtd_theme doc/source doc/build/html
pifpaf -g GNOCCHI_INDEXER_URL run postgresql -- sphinx-versioning build doc/source doc/build/html -- -D html_theme=sphinx_rtd_theme