https://github.com/sphinx-contrib/mockautodoc
https://github.com/sphinx-contrib/mockautodoc
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sphinx-contrib/mockautodoc
- Owner: sphinx-contrib
- Created: 2017-09-28T14:49:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-28T14:49:20.000Z (over 7 years ago)
- Last Synced: 2025-01-12T01:26:34.238Z (4 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
mockautodoc
===========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_.
Install
-------::
pip install sphinxcontrib-mockautodoc
Usage
-----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
@defer.inlineCallbacks
def my_func():
"""my function"""
passclass MyProtocol(protocol.Protocol):
"""my protocol"""
passAnd twisted_ not installed you can document module like that::
.. automodule:: package
:mockimport: twisted
:mocktype: protocol.ProtocolWhere 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 conf.py 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'],
}.. _twisted: http://twistedmatrix.com/
.. _autodoc: http://sphinx-doc.org/ext/autodoc.html
.. _question: http://stackoverflow.com/questions/15587305/any-ways-build-docs-by-sphinx-with-both-python2-x-and-python3-x-ecosystems