diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-06-17 02:19:33 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-06-17 02:19:33 +0900 |
commit | 4d7558e968d74f73e11c5460fe095b51a5a9f172 (patch) | |
tree | 2f67856b0b2022caec491c37766280b77c48ed2f /tests/test_ext_autodoc_configs.py | |
parent | 571b55328d401a6e1d50e37407df56586065a7be (diff) | |
parent | 949984c4e26671fdf5490c33cf90d4db118aaa86 (diff) | |
download | sphinx-git-4d7558e968d74f73e11c5460fe095b51a5a9f172.tar.gz |
Merge branch '5.0.x' into 5.x
Diffstat (limited to 'tests/test_ext_autodoc_configs.py')
-rw-r--r-- | tests/test_ext_autodoc_configs.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py index 0011f450b..f40f3354e 100644 --- a/tests/test_ext_autodoc_configs.py +++ b/tests/test_ext_autodoc_configs.py @@ -278,6 +278,72 @@ def test_autodoc_inherit_docstrings(app): @pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_autodoc_inherit_docstrings_for_inherited_members(app): + options = {"members": None, + "inherited-members": None} + + assert app.config.autodoc_inherit_docstrings is True # default + actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options) + assert list(actual) == [ + '', + '.. py:class:: Derived()', + ' :module: target.inheritance', + '', + '', + ' .. py:attribute:: Derived.inheritedattr', + ' :module: target.inheritance', + ' :value: None', + '', + ' docstring', + '', + '', + ' .. py:method:: Derived.inheritedclassmeth()', + ' :module: target.inheritance', + ' :classmethod:', + '', + ' Inherited class method.', + '', + '', + ' .. py:method:: Derived.inheritedmeth()', + ' :module: target.inheritance', + '', + ' Inherited function.', + '', + '', + ' .. py:method:: Derived.inheritedstaticmeth(cls)', + ' :module: target.inheritance', + ' :staticmethod:', + '', + ' Inherited static method.', + '', + ] + + # disable autodoc_inherit_docstrings + app.config.autodoc_inherit_docstrings = False + actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options) + assert list(actual) == [ + '', + '.. py:class:: Derived()', + ' :module: target.inheritance', + '', + '', + ' .. py:method:: Derived.inheritedclassmeth()', + ' :module: target.inheritance', + ' :classmethod:', + '', + ' Inherited class method.', + '', + '', + ' .. py:method:: Derived.inheritedstaticmeth(cls)', + ' :module: target.inheritance', + ' :staticmethod:', + '', + ' Inherited static method.', + '', + ] + + +@pytest.mark.sphinx('html', testroot='ext-autodoc') def test_autodoc_docstring_signature(app): options = {"members": None, "special-members": "__init__, __new__"} actual = do_autodoc(app, 'class', 'target.DocstringSig', options) |