Merged in Vladimirsson/sphinx (pull request #136)

Added ``imported-members`` option for ``automodule`` directive in autodoc
This commit is contained in:
Georg Brandl 2013-09-16 09:23:56 +02:00
commit d2b4f9a095
2 changed files with 14 additions and 5 deletions

View File

@ -184,12 +184,17 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
.. versionadded:: 0.6
.. note::
* In an :rst:dir:`automodule` directive with the ``members`` option set, only
module members whose ``__module__`` attribute is equal to the module name
as given to ``automodule`` will be documented. This is to prevent
documentation of imported classes or functions.
Set ``imported-members`` option if you want to preven this behavior and
document all available members.
Note that attributes from imported modules will not be documented,
because attribute documentation is discovered by parsing the source file
of the current module.
In an :rst:dir:`automodule` directive with the ``members`` option set, only
module members whose ``__module__`` attribute is equal to the module name
as given to ``automodule`` will be documented. This is to prevent
documentation of imported classes or functions.
.. versionadded:: 1.2
.. rst:directive:: autofunction

View File

@ -373,6 +373,9 @@ class Documenter(object):
"""Check if *self.object* is really defined in the module given by
*self.modname*.
"""
if self.options.imported_members:
return True
modname = self.get_attr(self.object, '__module__', None)
if modname and modname != self.modname:
return False
@ -779,6 +782,7 @@ class ModuleDocumenter(Documenter):
'platform': identity, 'deprecated': bool_option,
'member-order': identity, 'exclude-members': members_set_option,
'private-members': bool_option, 'special-members': members_option,
'imported-members': bool_option,
}
@classmethod