Skip to main content

Sphinx mocking autodoc extension

Project description

Mock imports for build docs without install packages in environment.

This extension add :mockimport: and :mocktype: for standard automodule derictive from autodoc.

Main goal of extension is to solve task defined on question.


pip install sphinxcontrib-mockautodoc


Add mockautodoc to extensions list:

extenstion = ['sphinx.ext.autodoc', 'sphinxcontrib.mockautodoc', ]

The extension add two options to standard automodule:

  • :mockimport: list of name spaces to mock separated by ‘,’.
  • :mocktype: list of objects which must be mock as type object
    for right way subclass them in sources, separated by ‘,’.

If you have module for documenting:

from twisted.internet import protocol, defer

def my_func():
    """my function"""

class MyProtocol(protocol.Protocol):
    """my protocol"""

And twisted not installed you can document module like that:

.. automodule:: package
    :mockimport: twisted
    :mocktype: protocol.Protocol

Where on :mockimport: will be mocked all twisted.* imports in automodule building context. And :mocktype: means which instances must be object types to successful subclass them without loss target documentation.

mockatudoc settings may be defined on and all automodule directives with present :mockimport: will be mocked. Where data on mockatodoc settings will be summed with :mockimport: and :mocktype: options:

mockautodoc = {
    'mockimport': ['twisted',],
    'mocktype': ['protocol.Protocol'],

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sphinxcontrib-mockautodoc, version 0.0.1dev-20130518
Filename, size & hash File type Python version Upload date
sphinxcontrib-mockautodoc-0.0.1dev-20130518.tar.gz (7.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page