mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add test cases for #8180
The test checks, if ":meta private:" and ":meta public:" have an effect in attributes of a class. Currently the new test cases fail. The fix is in the next commit.
This commit is contained in:
parent
cab2d93076
commit
336885c4e2
@ -13,3 +13,15 @@ def _public_function(name):
|
||||
|
||||
PRIVATE_CONSTANT = None #: :meta private:
|
||||
_PUBLIC_CONSTANT = None #: :meta public:
|
||||
|
||||
|
||||
class Foo:
|
||||
#: A public class attribute whose name starts with an underscore.
|
||||
#:
|
||||
#: :meta public:
|
||||
_public_attribute = 47
|
||||
|
||||
#: A private class attribute whose name does not start with an underscore.
|
||||
#:
|
||||
#: :meta private:
|
||||
private_attribute = 11
|
||||
|
@ -102,3 +102,57 @@ def test_private_members(app):
|
||||
' :meta public:',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_attributes(app):
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {"members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.private.Foo', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:class:: Foo()',
|
||||
' :module: target.private',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Foo._public_attribute',
|
||||
' :module: target.private',
|
||||
' :value: 47',
|
||||
'',
|
||||
' A public class attribute whose name starts with an underscore.',
|
||||
'',
|
||||
' :meta public:',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_private_attributes_and_private_members(app):
|
||||
app.config.autoclass_content = 'class'
|
||||
options = {"members": None,
|
||||
"private-members": None}
|
||||
actual = do_autodoc(app, 'class', 'target.private.Foo', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:class:: Foo()',
|
||||
' :module: target.private',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Foo._public_attribute',
|
||||
' :module: target.private',
|
||||
' :value: 47',
|
||||
'',
|
||||
' A public class attribute whose name starts with an underscore.',
|
||||
'',
|
||||
' :meta public:',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Foo.private_attribute',
|
||||
' :module: target.private',
|
||||
' :value: 11',
|
||||
'',
|
||||
' A private class attribute whose name does not start with an underscore.',
|
||||
'',
|
||||
' :meta private:',
|
||||
'',
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user