Better comments, also left the Python 3.7 code and no 3.8.
This commit is contained in:
parent
abbf100d17
commit
1c95a44d58
|
|
@ -77,13 +77,8 @@ def document(sentences, to_source, **kw):
|
|||
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))
|
||||
# Copy the line number from the original docstring
|
||||
copy_location(sentences[n], s)
|
||||
# else:
|
||||
# if isinstance(s, Expr):
|
||||
# print(s.__dict__)
|
||||
# print(s.value.__dict__)
|
||||
# print(s.value.func.__dict__)
|
||||
# print(s.value.args[0].__dict__)
|
||||
prev = s
|
||||
# Return the modified AST
|
||||
return sentences
|
||||
|
|
@ -94,10 +89,10 @@ def _do_wrap_class_register(tree, mod, base_class):
|
|||
# Create the register call
|
||||
name = tree.name
|
||||
l_start = tree.lineno
|
||||
if hasattr(tree, 'end_lineno'):
|
||||
l_end = tree.end_lineno
|
||||
else:
|
||||
l_end = l_start + 1
|
||||
# Python 3.8:
|
||||
# l_end = tree.end_lineno
|
||||
# Python 3.7, this is good enough for our needs:
|
||||
l_end = l_start + 1
|
||||
reg_name = name.lower()
|
||||
# BaseOutput.register member:
|
||||
attr = Attribute(value=Name(id=base_class, ctx=Load()), attr='register', ctx=Load())
|
||||
|
|
|
|||
|
|
@ -33,15 +33,18 @@ class BaseMacroExpander(NodeTransformer):
|
|||
expansion = _apply_macro(macro, tree, kw)
|
||||
|
||||
if syntax == 'block':
|
||||
# pass
|
||||
# The best I can do
|
||||
# If I keep the real line numbers the "with ..." isn't "covered"
|
||||
# copy_location(expansion[-1], target) # Esto cubre la 1ra pero nunca la última
|
||||
# I'm not sure why is all this mess
|
||||
#
|
||||
# Strategy 1: Make the last line cover the whole block.
|
||||
# Result: Covers the "with document" line, but not the last one.
|
||||
# copy_location(expansion[-1], target)
|
||||
#
|
||||
# Strategy 2: Make the second line cover the whole block.
|
||||
# Result: Covers all, unless the block is just 2 lines.
|
||||
# copy_location(expansion[1], target) # Lo mejor para largo > 2
|
||||
# Esto parece funcionar, pero puede tener efectos secundarios
|
||||
# dummy = deepcopy(expansion[1])
|
||||
# copy_location(dummy, target)
|
||||
# expansion.insert(1, dummy)
|
||||
#
|
||||
# Strategy 3: Insert a second dummy line covering the whole block.
|
||||
# Result: Works
|
||||
dummy = Expr(value=Call(func=Name(id="id", ctx=Load()), args=[Constant(value="bogus", kind=None)], keywords=[]),
|
||||
lineno=target.lineno)
|
||||
copy_location(dummy, target)
|
||||
|
|
|
|||
Loading…
Reference in New Issue