From 164d29526e047c7b9f8acd61e154b5e5d42ab3b2 Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Tue, 27 Jun 2017 17:17:17 +0900 Subject: [PATCH] Improve docs build Starting in Django 1.7, standalone scripts, such as a sphinx build require that django.setup() be called first. See: https://docs.djangoproject.com/en/1.8/releases/1.7/#standalone-scripts It does not always necessary, but it is needed to avoid warnings when creating autoindex. Note that horizon no longer generates the autoindex to avoid warnings. Drops setenv DJANGO_SETTINGS_MODULE in docs env in tox.ini. DJANGO_SETTINGS_MODULE is configured in doc/source/conf.py, so there is no need to pass envvar. Add warning-is-error sphinx setting to avoid doc build warnings. Change-Id: I4c036e264c7dd28463c3d52d73fcbbd3abeacb2b --- doc/source/conf.py | 12 +++++++++--- setup.cfg | 1 + tox.ini | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 5d55c44..0033bbf 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -28,6 +28,8 @@ import os import subprocess import sys +import django + BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) @@ -37,8 +39,12 @@ sys.path.insert(0, ROOT) os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'zun_ui.test.settings') -from zun_ui \ - import version as zunui_ver +# Starting in Django 1.7, standalone scripts, such as a sphinx build +# require that django.setup() be called first. +# https://docs.djangoproject.com/en/1.8/releases/1.7/#standalone-scripts +django.setup() + +from zun_ui import version as zunui_ver def write_autodoc_index(): @@ -270,7 +276,7 @@ html_theme_options = { # 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, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = [''] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff --git a/setup.cfg b/setup.cfg index c0d4ec6..ef9c59b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,3 +26,4 @@ packages = all_files = 1 build-dir = doc/build source-dir = doc/source +warning-is-error = 1 diff --git a/tox.ini b/tox.ini index 19ed0ac..7141733 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,6 @@ commands = python manage.py test {posargs} --settings=zun_ui.test.settings [testenv:docs] -setenv = DJANGO_SETTINGS_MODULE=zun_ui.test.settings commands = python setup.py build_sphinx [testenv:releasenotes]