mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Basic test for docstring inheritance
This commit is contained in:
parent
5148d6953b
commit
96ee24d7c1
@ -431,6 +431,13 @@ def test_get_doc():
|
||||
directive.env.config.autoclass_content = 'both'
|
||||
assert getdocl('class', I) == ['Class docstring', '', 'New docstring']
|
||||
|
||||
# NOTE: inspect.getdoc seems not to work with locally defined classes
|
||||
directive.env.config.autodoc_inherit_docstrings = False
|
||||
assert getdocl('method', Base.inheritedmeth) == ['Inherited function.']
|
||||
assert getdocl('method', Derived.inheritedmeth) == []
|
||||
directive.env.config.autodoc_inherit_docstrings = True
|
||||
assert getdocl('method', Derived.inheritedmeth) == ['Inherited function.']
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('setup_test')
|
||||
def test_docstring_processing():
|
||||
@ -941,6 +948,12 @@ class Base(object):
|
||||
"""Inherited function."""
|
||||
|
||||
|
||||
class Derived(Base):
|
||||
def inheritedmeth(self):
|
||||
# no docstring here
|
||||
pass
|
||||
|
||||
|
||||
class Class(Base):
|
||||
"""Class to document."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user