Enhanced the document macro coverage info.

- Recycled the s.value Str as @Technologicat suggested
- Added line number info to the target Name as I learned from the
  experiments test,
This commit is contained in:
Salvador E. Tropea 2020-10-17 11:11:24 -03:00
parent 270816c97f
commit c29b5902c2
1 changed files with 5 additions and 1 deletions

View File

@ -77,8 +77,12 @@ def document(sentences, **kw):
target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store())
else: # pragma: no cover
target = Name(id=doc_id, ctx=Store())
sentences[n] = Assign(targets=[target], value=Str(s=type_hint+s.value.s.rstrip()+post_hint))
# Reuse the s.value Str
help_str = s.value
help_str.s = type_hint+s.value.s.rstrip()+post_hint
sentences[n] = Assign(targets=[target], value=help_str)
# Copy the line number from the original docstring
copy_location(target, s)
copy_location(sentences[n], s)
prev = s
# Return the modified AST