Skip to content

Commit

Permalink
Simplify again, no need to tell the users the property is read-write …
Browse files Browse the repository at this point in the history
…if we show the .setter function. It must be writable.
  • Loading branch information
tristanlatr committed Nov 18, 2022
1 parent dbf0477 commit e7c73a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
26 changes: 1 addition & 25 deletions pydoctor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,32 +823,8 @@ def init_property(attr:'Attribute') -> Iterator['Function']:

# Set the new attribute parsed docstring
attr.parsed_docstring = pdoc

# We recognize 3 types of properties:
# - read-only
# - read-write
# - read-write-delete
# read-delete-only is not useful to be supported

def get_property_permission_text(write:bool, delete:bool) -> str:
if not write:
return "This property is *read-only*."
if delete:
return "This property is *readable*, *writable* and *deletable*."
else:
return "This property is *readable* and *writable*."

parsed_info = epydoc2stan.parse_docstring(
obj=info.declaration,
doc=get_property_permission_text(
write=setter is not None,
delete=deleter is not None),
source=info.declaration,
markup='restructuredtext',
section='property permission text',)


# TODO: Add inheritence info to getter/setter/deleters
attr.extra_info.append(parsed_info)

# Yield the objects to remove from the Documentable tree
yield getter
Expand Down
5 changes: 1 addition & 4 deletions pydoctor/test/test_twisted_python_deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ class stuff: ...
foom_deprecated_property = _class.contents['foom']
assert isinstance(foom_deprecated_property, model.Attribute)
info_text = [' '.join(node2stan.gettext(i.to_node())) for i in foom_deprecated_property.extra_info]
assert len(info_text) == 2, info_text
assert info_text == [
'Deprecated since version NEXT: foom was deprecated in Twisted NEXT; please use faam instead.',
'This property is read-only .', ]
assert 'Deprecated since version NEXT: foom was deprecated in Twisted NEXT; please use faam instead.' in info_text

assert re.match(_html_template_with_replacement.format(
name='foom', package='Twisted', version=r'NEXT', replacement='faam'
Expand Down

0 comments on commit e7c73a5

Please sign in to comment.