diff --git a/configurations/__init__.py b/configurations/__init__.py index 6256779..eed8762 100644 --- a/configurations/__init__.py +++ b/configurations/__init__.py @@ -25,10 +25,5 @@ def load_ipython_extension(ipython): def setup(app=None): - """ - The callback for Sphinx that acts as a Sphinx extension. - - Add ``'configurations'`` to the ``extensions`` config variable - in your docs' ``conf.py``. - """ + """Function used to initialize configurations similar to :func:`.django.setup`.""" _setup() diff --git a/configurations/sphinx.py b/configurations/sphinx.py new file mode 100644 index 0000000..d999436 --- /dev/null +++ b/configurations/sphinx.py @@ -0,0 +1,12 @@ +from . import _setup, __version__ + + +def setup(app=None): + """ + The callback for Sphinx that acts as a Sphinx extension. + + Add ``'configurations'`` to the ``extensions`` config variable + in your docs' ``conf.py``. + """ + _setup() + return {'version': __version__, 'parallel_read_safe': True} diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 8d00133..206b5e9 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -224,8 +224,6 @@ As you can see django-configurations provides a helper module Sphinx ------ -.. versionadded: 0.9 - In case you would like to user the amazing `autodoc` feature of the documentation tool `Sphinx `_, you need add django-configurations to your ``extensions`` config variable and set @@ -245,7 +243,11 @@ the environment variable accordingly: 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode', # ... - 'configurations', + 'configurations.sphinx', ] # ... + +.. versionchanged:: 2.0 + +Please note that the sphinx callable has been moved from `configurations` to `configurations.sphinx`. diff --git a/tests/docs/conf.py b/tests/docs/conf.py new file mode 100644 index 0000000..4025988 --- /dev/null +++ b/tests/docs/conf.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import os +import sys + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir)) + +# setup Django +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.main") +os.environ.setdefault('DJANGO_CONFIGURATION', 'Test') + +extensions = [ + 'configurations.sphinx', +] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'django-configurations' +copyright = '2012-2014, Jannis Leidel and other contributors' + + +version = release = 'test' + +exclude_patterns = ['_build'] + +html_theme = 'default' diff --git a/tests/docs/index.rst b/tests/docs/index.rst new file mode 100644 index 0000000..7193334 --- /dev/null +++ b/tests/docs/index.rst @@ -0,0 +1,2 @@ +Test Documentation +^^^^^^^^^^^^^^^^^^ diff --git a/tests/requirements.txt b/tests/requirements.txt index 5eb9697..39e47b3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,3 +6,4 @@ dj-email-url dj-search-url django-cache-url>=1.0.0 six +Sphinx>=1.4 diff --git a/tests/settings/main.py b/tests/settings/main.py index f9d71d1..6a27de1 100644 --- a/tests/settings/main.py +++ b/tests/settings/main.py @@ -7,6 +7,7 @@ from configurations.values import BooleanValue class Test(Configuration): + BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)) ENV_LOADED = BooleanValue(False) diff --git a/tests/test_sphinx.py b/tests/test_sphinx.py new file mode 100644 index 0000000..2bfa22a --- /dev/null +++ b/tests/test_sphinx.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import subprocess +import os + +from django.test import TestCase +from django.conf import settings + + +class SphinxTests(TestCase): + docs_dir = os.path.join(settings.BASE_DIR, 'docs') + + def test_multiprocessing(self): + output = subprocess.check_output([ + 'sphinx-build', + '-b', + 'html', + '-j 2', + '.', + '_build/html', + ], cwd=self.docs_dir, stderr=subprocess.STDOUT) + self.assertIn(b'waiting for workers', output) + self.assertIn(b'build succeeded.', output) diff --git a/tox.ini b/tox.ini index b70eaf8..2bde8f2 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ skipsdist = True usedevelop = True minversion = 1.8 +whitelist_externals=sphinx-build envlist = flake8-py27, flake8-py35,