sphinx/doc
Robin Jarry ececc4dcfe ext: enhance autodoc_mock_imports
The autodoc_mock_imports option requires to explicitly declare *every*
external module and sub-module that are imported by the documented code.
This is not practical as the list can become very large and must be
maintained as the code changes.

Also, the mocking is minimal which causes errors when compiling the
docs. For example, if you declare:

    autodoc_mock_imports = ['django.template']

And try to document a module:

    .. automodule:: my.lib.util

Which contains this code:

    from django.template import Library
    register = Library()

The following error occurs:

    File ".../my/lib/util.py" line 2
        register = Library()
    TypeError: 'object' object is not callable

Other similar errors can occur such as "TypeError: 'object' object has
no len".

To address these limitations, only require to declare the top-level
module that should be mocked:

    autodoc_mock_imports = ['django']

Will mock "django" but also any sub-module: "django.template",
"django.contrib", etc.

Also, make the mocked modules yield more complete dummy objects to avoid
these TypeError problems.

Behind the scenes, it uses the python import hooks mechanism specified
in PEP 302.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2017-04-18 17:08:17 +02:00
..
_static Update conf.py.txt 2017-02-03 16:30:26 +01:00
_templates add link to Changes in toppage 2016-12-15 21:53:13 +09:00
_themes/sphinx13 Year++ 2017-03-26 11:49:34 +09:00
ext ext: enhance autodoc_mock_imports 2017-04-18 17:08:17 +02:00
extdev Rewrite and simplify stylesheet handling 2017-04-15 17:07:33 +02:00
man Fix #2892: Added `-a (--append-syspath) option to sphinx-apidoc` 2016-08-24 23:55:15 +09:00
markup doc: Add warning for only directive (refs: #3539) 2017-03-12 01:47:11 +09:00
themes Run *.png through zopflipng -m 2016-07-07 18:34:18 +03:00
web Fix typos #2122 (cherry-picked by hand) 2016-01-02 11:17:59 +09:00
authors.rst Fixup windows newlines. 2014-09-21 20:23:24 +02:00
builders.rst Update latex builder docs (latexmk requirement) 2017-03-10 19:11:06 +01:00
changes.rst Use "any" role in changelog. 2014-09-19 13:18:29 +02:00
conf.py Year++ 2017-03-26 11:49:34 +09:00
config.rst Fix #3558: Emit warnings if footnotes and citations are not referenced 2017-03-18 21:03:16 +09:00
contents.rst doc: Add guide on setuptool/distutils integration 2017-02-24 13:41:34 -05:00
develop.rst Fix link to Google Python Style. Small typofixes. 2017-02-08 11:10:37 +01:00
devguide.rst add devguide.rst as a file instead of symlink. 2016-12-18 10:06:30 +09:00
domains.rst Merge pull request #3475 from agjohnson/domain-js-add-nesting 2017-03-26 18:16:04 +09:00
examples.rst Add "who uses it" page. 2008-06-23 12:35:22 +00:00
extensions.rst Fix document for Kindle and add description about kindlegen 2016-09-01 12:46:12 +09:00
faq.rst Update faq epub link 2016-12-11 09:01:02 -05:00
glossary.rst Inprovement of warnings mechanism. Now support disabling emit warnings and add documentation. 2016-12-04 18:05:16 +09:00
install.rst Add py36 support 2016-12-25 12:19:15 +09:00
installpython.jpg Run *.jpg through jpegoptim -s 2016-07-07 18:34:18 +03:00
intl.rst Fix typos 2017-02-07 20:14:47 +01:00
intro.rst Fix #2919: Drop py26 support 2016-09-15 22:47:47 +09:00
invocation.rst Merge branch 'stable' 2017-03-01 15:04:28 +09:00
latex.rst Merge branch 'stable' 2017-03-18 18:25:50 +09:00
make.bat add make.bat for sphinx/doc 2015-04-06 14:18:28 +09:00
Makefile Add a comment to Makefile template for make-mode, update doc/Makefile 2016-10-23 10:45:23 +02:00
markdown.rst document markdown support: work in review comments #2303 #825 2017-02-02 14:42:48 +09:00
more.png Run *.png through zopflipng -m 2016-07-07 18:34:18 +03:00
pythonorg.png Run *.png through zopflipng -m 2016-07-07 18:34:18 +03:00
rest.rst Fix "documenting" typo in reST primer 2017-02-13 19:15:21 +01:00
setuptools.rst setuptools: Support multiple builders 2017-02-28 17:30:28 +00:00
templating.rst Rewrite and simplify stylesheet handling 2017-04-15 17:07:33 +02:00
theming.rst Merge branch 'stable' 2016-08-27 23:42:40 +09:00
translation.png Run *.png through zopflipng -m 2016-07-07 18:34:18 +03:00
tutorial.rst doc: Add guide on setuptool/distutils integration 2017-02-24 13:41:34 -05:00
websupport.rst Update versionadded for SoC projects. 2010-08-21 19:23:05 +02:00