mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Close #2044: autodoc: Suppress default value for instance attributes
This commit is contained in:
parent
12cb90c3fa
commit
a42de07bcf
1
CHANGES
1
CHANGES
@ -24,6 +24,7 @@ Features added
|
||||
:confval:`suppress_warnings`
|
||||
* C, added scope control directives, :rst:dir:`c:namespace`,
|
||||
:rst:dir:`c:namespace-push`, and :rst:dir:`c:namespace-pop`.
|
||||
* #2044: autodoc: Suppress default value for instance attributes
|
||||
* #7466: autosummary: headings in generated documents are not translated
|
||||
* #7490: autosummary: Add ``:caption:`` option to autosummary directive to set a
|
||||
caption to the toctree
|
||||
|
@ -1600,8 +1600,11 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
||||
sourcename)
|
||||
|
||||
try:
|
||||
objrepr = object_description(self.object)
|
||||
self.add_line(' :value: ' + objrepr, sourcename)
|
||||
if self.object is INSTANCEATTR:
|
||||
pass
|
||||
else:
|
||||
objrepr = object_description(self.object)
|
||||
self.add_line(' :value: ' + objrepr, sourcename)
|
||||
except ValueError:
|
||||
pass
|
||||
elif self.options.annotation is SUPPRESS:
|
||||
@ -1672,6 +1675,7 @@ class InstanceAttributeDocumenter(AttributeDocumenter):
|
||||
"""Never import anything."""
|
||||
# disguise as an attribute
|
||||
self.objtype = 'attribute'
|
||||
self.object = INSTANCEATTR
|
||||
self._datadescriptor = False
|
||||
return True
|
||||
|
||||
|
@ -1032,14 +1032,12 @@ def test_instance_attributes(app):
|
||||
'',
|
||||
' .. py:attribute:: InstAttCls.ia1',
|
||||
' :module: target',
|
||||
' :value: None',
|
||||
'',
|
||||
' Doc comment for instance attribute InstAttCls.ia1',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: InstAttCls.ia2',
|
||||
' :module: target',
|
||||
' :value: None',
|
||||
'',
|
||||
' Docstring for instance attribute InstAttCls.ia2.',
|
||||
''
|
||||
@ -1066,7 +1064,6 @@ def test_instance_attributes(app):
|
||||
'',
|
||||
' .. py:attribute:: InstAttCls.ia1',
|
||||
' :module: target',
|
||||
' :value: None',
|
||||
'',
|
||||
' Doc comment for instance attribute InstAttCls.ia1',
|
||||
''
|
||||
@ -1485,7 +1482,6 @@ def test_autodoc_typed_instance_variables(app):
|
||||
' .. py:attribute:: Class.attr2',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
' :value: None',
|
||||
'',
|
||||
'',
|
||||
' .. py:attribute:: Class.attr3',
|
||||
@ -1497,7 +1493,6 @@ def test_autodoc_typed_instance_variables(app):
|
||||
' .. py:attribute:: Class.attr4',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
' :value: None',
|
||||
'',
|
||||
' attr4',
|
||||
'',
|
||||
@ -1505,7 +1500,6 @@ def test_autodoc_typed_instance_variables(app):
|
||||
' .. py:attribute:: Class.attr5',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
' :value: None',
|
||||
'',
|
||||
' attr5',
|
||||
'',
|
||||
@ -1513,7 +1507,6 @@ def test_autodoc_typed_instance_variables(app):
|
||||
' .. py:attribute:: Class.attr6',
|
||||
' :module: target.typed_vars',
|
||||
' :type: int',
|
||||
' :value: None',
|
||||
'',
|
||||
' attr6',
|
||||
'',
|
||||
|
Loading…
Reference in New Issue
Block a user