Modified the macros examples to make them as similar as possible.

So a diff between them is minimal.
This commit is contained in:
Salvador E. Tropea 2020-06-23 11:16:58 -03:00
parent bcb35e90ef
commit a066887744
4 changed files with 7 additions and 8 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/python3
import macropy.activate # noqa: F401
import application # noqa: F401
import application # noqa: F401

View File

@ -1,6 +1,5 @@
from mymacros import macros, document # noqa: F401
with document:
# comentario a
a = "5.1"

View File

@ -1,15 +1,15 @@
from ast import (Assign, Name, Attribute, Expr, Num, Str, NameConstant, Load, Store)
def document(sentences, to_source, **kw):
def document(tree, **kw):
""" This macro takes literal strings and converts them into:
_help_ID = type_hint+STRING
where:
ID is the first target of the last assignment.
type_hint is the assigned type and default value (only works for a few types)
STRING is the literal string """
for n in range(len(sentences)):
s = sentences[n]
for n in range(len(tree)):
s = tree[n]
if not n:
prev = s
continue
@ -48,7 +48,7 @@ def document(sentences, to_source, **kw):
target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store())
else:
target = Name(id=doc_id, ctx=Store())
sentences[n] = Assign(targets=[target], value=Str(s=type_hint+s.value.s))
tree[n] = Assign(targets=[target], value=Str(s=type_hint+s.value.s))
prev = s
# Return the modified AST
return sentences
return tree

View File

@ -1,3 +1,3 @@
#!/usr/bin/python3
import mcpy.activate # noqa: F401
import application # noqa: F401
import application # noqa: F401