summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Opanchuk <bogdan@opanchuk.net>2013-04-20 21:58:18 +1000
committerBogdan Opanchuk <bogdan@opanchuk.net>2013-04-20 21:58:18 +1000
commit91c3dd4541dee0e22a5e2223c33e0bfd93ffdba9 (patch)
treecd043276da777b356dc247f2350591c696839d4f
parent1d963f7e655d45975362b7e4fec1878537970301 (diff)
downloadsphinx-91c3dd4541dee0e22a5e2223c33e0bfd93ffdba9.tar.gz
Added ``imported-members`` option for ``automodule`` directive in autodoc
-rw-r--r--doc/ext/autodoc.rst17
-rw-r--r--sphinx/ext/autodoc.py4
2 files changed, 15 insertions, 6 deletions
diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst
index 7f9a6c61..c76fb086 100644
--- a/doc/ext/autodoc.rst
+++ b/doc/ext/autodoc.rst
@@ -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.
+ * 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.
+
+ .. versionadded:: 1.2
.. rst:directive:: autofunction
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 555a3106..432b9ec2 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -364,6 +364,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
@@ -770,6 +773,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