mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Rename :novalue: option to :no-value: option
According to the existing options of autodoc directives, `:novalue:` option is now renamed to `:no-value:` option.
This commit is contained in:
@@ -326,13 +326,13 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
||||
By default, without ``annotation`` option, Sphinx tries to obtain the value of
|
||||
the variable and print it after the name.
|
||||
|
||||
The ``novalue`` option can be used instead of a blank ``annotation`` to show the
|
||||
The ``no-value`` option can be used instead of a blank ``annotation`` to show the
|
||||
type hint but not the value::
|
||||
|
||||
.. autodata:: CD_DRIVE
|
||||
:novalue:
|
||||
:no-value:
|
||||
|
||||
If both the ``annotation`` and ``novalue`` options are used, ``novalue`` has no
|
||||
If both the ``annotation`` and ``no-value`` options are used, ``no-value`` has no
|
||||
effect.
|
||||
|
||||
For module data members and class attributes, documentation can either be put
|
||||
@@ -374,8 +374,8 @@ inserting them into the page source under a suitable :rst:dir:`py:module`,
|
||||
option.
|
||||
.. versionchanged:: 2.0
|
||||
:rst:dir:`autodecorator` added.
|
||||
.. versionchanged:: 3.3
|
||||
:rst:dir:`autodata` and :rst:dir:`autoattribute` now have a ``novalue``
|
||||
.. versionchanged:: 3.4
|
||||
:rst:dir:`autodata` and :rst:dir:`autoattribute` now have a ``no-value``
|
||||
option.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -1690,7 +1690,7 @@ class DataDocumenter(ModuleLevelDocumenter):
|
||||
priority = -10
|
||||
option_spec = dict(ModuleLevelDocumenter.option_spec)
|
||||
option_spec["annotation"] = annotation_option
|
||||
option_spec["novalue"] = bool_option
|
||||
option_spec["no-value"] = bool_option
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
@@ -1726,7 +1726,7 @@ class DataDocumenter(ModuleLevelDocumenter):
|
||||
sourcename)
|
||||
|
||||
try:
|
||||
if self.object is UNINITIALIZED_ATTR or self.options.novalue:
|
||||
if self.object is UNINITIALIZED_ATTR or self.options.no_value:
|
||||
pass
|
||||
else:
|
||||
objrepr = object_description(self.object)
|
||||
@@ -2022,7 +2022,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
||||
member_order = 60
|
||||
option_spec = dict(ModuleLevelDocumenter.option_spec)
|
||||
option_spec["annotation"] = annotation_option
|
||||
option_spec["novalue"] = bool_option
|
||||
option_spec["no-value"] = bool_option
|
||||
|
||||
# must be higher than the MethodDocumenter, else it will recognize
|
||||
# some non-data descriptors as methods
|
||||
|
||||
42
tests/test_ext_autodoc_autoattribute.py
Normal file
42
tests/test_ext_autodoc_autoattribute.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
test_ext_autodoc_autoattribute
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from test_ext_autodoc import do_autodoc
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute(app):
|
||||
actual = do_autodoc(app, 'attribute', 'target.Class.attr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: Class.attr',
|
||||
' :module: target',
|
||||
" :value: 'bar'",
|
||||
'',
|
||||
' should be documented -- süß',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autoattribute_novalue(app):
|
||||
options = {'no-value': True}
|
||||
actual = do_autodoc(app, 'attribute', 'target.Class.attr', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: Class.attr',
|
||||
' :module: target',
|
||||
" :value: 'bar'",
|
||||
'',
|
||||
' should be documented -- süß',
|
||||
'',
|
||||
]
|
||||
41
tests/test_ext_autodoc_autodata.py
Normal file
41
tests/test_ext_autodoc_autodata.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
test_ext_autodoc_autodata
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test the autodoc extension. This tests mainly the Documenters; the auto
|
||||
directives are tested in a test source file translated by test_build.
|
||||
|
||||
:copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from test_ext_autodoc import do_autodoc
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodata(app):
|
||||
actual = do_autodoc(app, 'data', 'target.integer')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:data:: integer',
|
||||
' :module: target',
|
||||
' :value: 1',
|
||||
'',
|
||||
' documentation for the integer',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodata_novalue(app):
|
||||
options = {'no-value': True}
|
||||
actual = do_autodoc(app, 'data', 'target.integer', options)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:data:: integer',
|
||||
' :module: target',
|
||||
'',
|
||||
' documentation for the integer',
|
||||
'',
|
||||
]
|
||||
Reference in New Issue
Block a user