Skip to content

Commit

Permalink
docs: use sphinx's autodoc_mock_imports to mock
Browse files Browse the repository at this point in the history
.. out stuff whne building the docs instead of using homebrew methods.
http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_mock_imports
  • Loading branch information
pazz committed Nov 11, 2018
1 parent 8d03db4 commit a9e04e1
Showing 1 changed file with 11 additions and 39 deletions.
50 changes: 11 additions & 39 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,6 @@
# alot documentation build configuration file
import sys, os

###############################
# readthedocs.org hack,
# needed to use autodocs on their build-servers:
# http://readthedocs.org/docs/read-the-docs/en/latest/faq.html?highlight=autodocs#where-do-i-need-to-put-my-docs-for-rtd-to-find-it

class Mock(object):
def __init__(self, *args, **kwargs):
pass

def __call__(self, *args, **kwargs):
return Mock()

@classmethod
def __getattr__(cls, name):
return Mock() if name not in ('__file__', '__path__') else '/dev/null'

class MockModule(object):
@classmethod
def __getattr__(cls, name):
return Mock if name not in ('__file__', '__path__') else '/dev/null'

MOCK_MODULES = ['urwid',
'urwidtrees',
'magic',
'gpg',
'configobj',
'validate',
'argparse',
'alot.settings.const']
MOCK_DIRTY = ['notmuch']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = MockModule()
for mod_name in MOCK_DIRTY:
sys.modules[mod_name] = Mock()

# end of readthedocs.org hack
##############################

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -56,7 +18,17 @@ def __getattr__(cls, name):
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']

# autodoc tweaks

autodoc_mock_imports = [
'alot.settings.const',
'argparse',
'configobj',
'gpg',
'magic',
'notmuch',
'urwid',
'urwidtrees',
'validate',
]
# show classes' docstrings _and_ constructors docstrings/parameters
autoclass_content = 'both'

Expand Down

0 comments on commit a9e04e1

Please sign in to comment.