2019-12-31 23:40:13 -06:00
|
|
|
"""
|
|
|
|
test_ext_autodoc_private_members
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the autodoc extension. This tests mainly for private-members option.
|
|
|
|
|
|
|
|
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2020-05-05 23:46:45 -05:00
|
|
|
from test_ext_autodoc import do_autodoc
|
2019-12-31 23:40:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
|
|
|
def test_private_field(app):
|
|
|
|
app.config.autoclass_content = 'class'
|
|
|
|
options = {"members": None}
|
|
|
|
actual = do_autodoc(app, 'module', 'target.private', options)
|
|
|
|
assert list(actual) == [
|
|
|
|
'',
|
|
|
|
'.. py:module:: target.private',
|
|
|
|
'',
|
2020-04-13 09:55:07 -05:00
|
|
|
'',
|
|
|
|
'.. py:function:: _public_function(name)',
|
|
|
|
' :module: target.private',
|
|
|
|
'',
|
|
|
|
' public_function is a docstring().',
|
|
|
|
'',
|
|
|
|
' :meta public:',
|
|
|
|
'',
|
2019-12-31 23:40:13 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
|
|
|
def test_private_field_and_private_members(app):
|
|
|
|
app.config.autoclass_content = 'class'
|
|
|
|
options = {"members": None,
|
|
|
|
"private-members": None}
|
|
|
|
actual = do_autodoc(app, 'module', 'target.private', options)
|
|
|
|
assert list(actual) == [
|
|
|
|
'',
|
|
|
|
'.. py:module:: target.private',
|
|
|
|
'',
|
|
|
|
'',
|
2020-04-13 09:55:07 -05:00
|
|
|
'.. py:function:: _public_function(name)',
|
|
|
|
' :module: target.private',
|
|
|
|
'',
|
|
|
|
' public_function is a docstring().',
|
|
|
|
'',
|
|
|
|
' :meta public:',
|
|
|
|
'',
|
|
|
|
'',
|
2019-12-31 23:40:13 -06:00
|
|
|
'.. py:function:: private_function(name)',
|
|
|
|
' :module: target.private',
|
|
|
|
'',
|
|
|
|
' private_function is a docstring().',
|
2020-03-08 00:31:14 -06:00
|
|
|
'',
|
2019-12-31 23:40:13 -06:00
|
|
|
' :meta private:',
|
2020-03-08 00:31:14 -06:00
|
|
|
'',
|
2019-12-31 23:40:13 -06:00
|
|
|
]
|