Skip to content

Commit

Permalink
Merge pull request #154 from codingjoe/issues/146
Browse files Browse the repository at this point in the history
Fixes #146 -- Adds multiprocessing support for sphinx
  • Loading branch information
amureki committed Jun 14, 2016
2 parents 7701e86 + 9592356 commit 1c5bd06
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 9 deletions.
7 changes: 1 addition & 6 deletions configurations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 12 additions & 0 deletions configurations/sphinx.py
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 5 additions & 3 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 30 additions & 0 deletions tests/docs/conf.py
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions tests/docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Test Documentation
^^^^^^^^^^^^^^^^^^
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dj-email-url
dj-search-url
django-cache-url>=1.0.0
six
Sphinx>=1.4
1 change: 1 addition & 0 deletions tests/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class Test(Configuration):
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir))

ENV_LOADED = BooleanValue(False)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_sphinx.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
skipsdist = True
usedevelop = True
minversion = 1.8
whitelist_externals=sphinx-build
envlist =
flake8-py27,
flake8-py35,
Expand Down

0 comments on commit 1c5bd06

Please sign in to comment.