mirror of
https://github.com/readthedocs/sphinx-autoapi
synced 2024-11-10 01:10:27 +00:00
parent
24109875e1
commit
471c870a53
@ -12,6 +12,9 @@ Features
|
||||
* The fully qualified path of objects are included type annotations
|
||||
so that Sphinx can link to them.
|
||||
* Added support for Sphinx 3.3. and 3.4.
|
||||
* `#240 <https://github.com/readthedocs/sphinx-autoapi/issues/240>`:
|
||||
The docstrings of ``object.__init__``, ``object.__new__``,
|
||||
``type.__init__``, and ``type.__new__`` are not inherited.
|
||||
|
||||
Bug Fixes
|
||||
^^^^^^^^^
|
||||
|
@ -599,6 +599,12 @@ def get_func_docstring(node):
|
||||
|
||||
if doc is None and isinstance(node.parent, astroid.nodes.ClassDef):
|
||||
for base in node.parent.ancestors():
|
||||
if node.name in ("__init__", "__new__") and base.qname() in (
|
||||
"__builtins__.object",
|
||||
"builtins.object",
|
||||
"builtins.type",
|
||||
):
|
||||
continue
|
||||
for child in base.get_children():
|
||||
if (
|
||||
isinstance(child, node.__class__)
|
||||
@ -620,7 +626,11 @@ def get_class_docstring(node):
|
||||
|
||||
if doc is None:
|
||||
for base in node.ancestors():
|
||||
if base.qname() in ("__builtins__.object", "builtins.object"):
|
||||
if base.qname() in (
|
||||
"__builtins__.object",
|
||||
"builtins.object",
|
||||
"builtins.type",
|
||||
):
|
||||
continue
|
||||
if base.doc is not None:
|
||||
return base.doc
|
||||
|
@ -5,7 +5,7 @@ Python
|
||||
------
|
||||
|
||||
When choosing what to document,
|
||||
AutoAPI aims to document anything that is accessible through the actual package
|
||||
AutoAPI aims to document anything that is publicly accessible through the actual package
|
||||
when loaded in Python.
|
||||
For example if a function is imported from a submodule into a package,
|
||||
that function is documented in both the submodule and the package.
|
||||
@ -15,6 +15,20 @@ There are some exceptions to this rule:
|
||||
Usually a module is where implementations exist.
|
||||
Therefore an import of something is usually for the usage of the implementation,
|
||||
and not as something to be accessed publicly.
|
||||
* When the module or package defines an ``__all__``,
|
||||
only the members named in ``__all__`` are documented.
|
||||
* When a configuration option indicates that private
|
||||
or special members should also be documented.
|
||||
|
||||
Furthermore, AutoAPI follows the same docstring inheritance rules as :func:`inspect.getdoc`,
|
||||
with some exceptions:
|
||||
|
||||
* The docstrings of the following methods are not inherited because they are usually redundant:
|
||||
|
||||
* :meth:`object.__init__`
|
||||
* :meth:`object.__new__`
|
||||
* :meth:`type.__init__`
|
||||
* :meth:`type.__new__`
|
||||
|
||||
|
||||
.NET
|
||||
|
@ -163,6 +163,14 @@ class TestPy3Module(object):
|
||||
def built(self, builder):
|
||||
builder("py3example")
|
||||
|
||||
def test_integration(self):
|
||||
example_path = "_build/text/autoapi/example/index.txt"
|
||||
with io.open(example_path, encoding="utf8") as example_handle:
|
||||
example_file = example_handle.read()
|
||||
|
||||
assert "Initialize self" not in example_file
|
||||
assert "a new type" not in example_file
|
||||
|
||||
def test_annotations(self):
|
||||
example_path = "_build/text/autoapi/example/index.txt"
|
||||
with io.open(example_path, encoding="utf8") as example_handle:
|
||||
|
Loading…
Reference in New Issue
Block a user