-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with ABC-derived classes having their members ignored
ABC-derived classes (i.e. those deriving from the `abc` and `collections.abc` modules) now include their members (as defined in `__dict__`) in generated `autosummary` RST. `__slots__` may still be used to override `__dict__`, but if an ABC-derived class has empty slots, its `__dict__` will be used instead. Fixes #52
- Loading branch information
1 parent
d46a0c1
commit 2d2547a
Showing
7 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This example is to make sure that classes derived from the `abc` module will | ||
have their members listed (https://github.com/astropy/sphinx-automodapi/issues/52). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. automodapi:: sphinx_automodapi.tests.example_module.abstract_classes |
27 changes: 27 additions & 0 deletions
27
...pi/sphinx_automodapi.tests.example_module.abstract_classes.SequenceSubclass.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
SequenceSubclass | ||
================ | ||
|
||
.. currentmodule:: sphinx_automodapi.tests.example_module.abstract_classes | ||
|
||
.. autoclass:: SequenceSubclass | ||
:show-inheritance: | ||
|
||
.. rubric:: Attributes Summary | ||
|
||
.. autosummary:: | ||
|
||
~SequenceSubclass.my_property | ||
|
||
.. rubric:: Methods Summary | ||
|
||
.. autosummary:: | ||
|
||
~SequenceSubclass.my_method | ||
|
||
.. rubric:: Attributes Documentation | ||
|
||
.. autoattribute:: my_property | ||
|
||
.. rubric:: Methods Documentation | ||
|
||
.. automethod:: my_method |
19 changes: 19 additions & 0 deletions
19
sphinx_automodapi/tests/cases/abstract_classes/output/index.rst.automodapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
sphinx_automodapi.tests.example_module.abstract_classes Module | ||
-------------------------------------------------------------- | ||
|
||
.. automodule:: sphinx_automodapi.tests.example_module.abstract_classes | ||
|
||
Classes | ||
^^^^^^^ | ||
|
||
.. automodsumm:: sphinx_automodapi.tests.example_module.abstract_classes | ||
:classes-only: | ||
:toctree: api | ||
|
||
Class Inheritance Diagram | ||
^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. automod-diagram:: sphinx_automodapi.tests.example_module.abstract_classes | ||
:private-bases: | ||
:parts: 1 |
6 changes: 6 additions & 0 deletions
6
sphinx_automodapi/tests/cases/abstract_classes/output/index.rst.automodsumm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. currentmodule:: sphinx_automodapi.tests.example_module.abstract_classes | ||
|
||
.. autosummary:: | ||
:toctree: api | ||
|
||
SequenceSubclass |
37 changes: 37 additions & 0 deletions
37
sphinx_automodapi/tests/example_module/abstract_classes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import collections.abc | ||
|
||
__all__ = ['SequenceSubclass'] | ||
|
||
|
||
class SequenceSubclass(collections.abc.Sequence): | ||
""" | ||
Inherits from an ABC. | ||
""" | ||
|
||
def __init__(self): | ||
self._items = [] | ||
|
||
def __len__(self): | ||
""" | ||
Must be defined for the collections.abc.Sequence base class. | ||
""" | ||
return len(self._items) | ||
|
||
def __getitem__(self, key): | ||
""" | ||
Must be defined for the collections.abc.Sequence base class. | ||
""" | ||
return self._items[key] | ||
|
||
def my_method(self, parameter): | ||
""" | ||
An example method. | ||
""" | ||
pass | ||
|
||
@property | ||
def my_property(self): | ||
""" | ||
An example property. | ||
""" | ||
return 42 |