Skip to content

Commit

Permalink
docs: make autodoc play well with Mock
Browse files Browse the repository at this point in the history
  • Loading branch information
pazz committed Dec 26, 2016
1 parent cbce105 commit bbe6ffb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
42 changes: 26 additions & 16 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
import sys
import os

# 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.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath(os.path.join('..','..')))
from urwidtrees.version import __version__


###############################
# readthedocs.org hack,
Expand All @@ -25,22 +32,25 @@
except ImportError:
from mock import Mock as MagicMock


class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return MagicMock()

MOCK_MODULES = ['urwid',]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

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

# 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.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath(os.path.join('..','..')))
from urwidtrees.version import __version__
MOCK_MODULES = ['urwid']

#for mod_name in MOCK_MODULES:
# sys.modules[mod_name] = MockModule()
sys.modules.update((mod_name, MockModule()) for mod_name in MOCK_MODULES)

##################################

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -155,7 +165,7 @@ def __getattr__(cls, name):
# 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 = ['_static']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -210,14 +220,14 @@ def __getattr__(cls, name):
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
7 changes: 5 additions & 2 deletions docs/source/containers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ to use tree-based focus movement or key bindings for collapsing subtrees.
API
===

.. automodule:: urwidtrees.widgets
:members:
.. autoclass:: urwidtrees.widgets.TreeBox
:members:

.. autoclass:: urwidtrees.widgets.TreeListWalker
:members:
2 changes: 0 additions & 2 deletions docs/source/decoration.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Decoration
----------

.. module:: urwidtrees.decoration

Is done by using (subclasses of) :class:`DecoratedTree`. Objects of this type
wrap around a given `Tree` and themselves behave like a (possibly altered) tree.
Per default, `DecoratedTree` just passes every method on to its underlying tree.
Expand Down

0 comments on commit bbe6ffb

Please sign in to comment.