Merge pull request #154 from codingjoe/issues/146

Fixes #146 -- Adds multiprocessing support for sphinx
This commit is contained in:
Rustem Sayargaliev 2016-06-14 13:07:10 +02:00 committed by GitHub
commit 1c5bd06c68
9 changed files with 75 additions and 9 deletions

View file

@ -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()

12
configurations/sphinx.py Normal file
View file

@ -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}

View file

@ -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 <http://sphinx-doc.org/>`_, 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`.

30
tests/docs/conf.py Normal file
View file

@ -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'

2
tests/docs/index.rst Normal file
View file

@ -0,0 +1,2 @@
Test Documentation
^^^^^^^^^^^^^^^^^^

View file

@ -6,3 +6,4 @@ dj-email-url
dj-search-url
django-cache-url>=1.0.0
six
Sphinx>=1.4

View file

@ -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)

22
tests/test_sphinx.py Normal file
View file

@ -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)

View file

@ -2,6 +2,7 @@
skipsdist = True
usedevelop = True
minversion = 1.8
whitelist_externals=sphinx-build
envlist =
flake8-py27,
flake8-py35,