Modified the macros examples to make them as similar as possible.
So a diff between them is minimal.
This commit is contained in:
parent
bcb35e90ef
commit
a066887744
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import macropy.activate # noqa: F401
|
import macropy.activate # noqa: F401
|
||||||
import application # noqa: F401
|
import application # noqa: F401
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from mymacros import macros, document # noqa: F401
|
from mymacros import macros, document # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
with document:
|
with document:
|
||||||
# comentario a
|
# comentario a
|
||||||
a = "5.1"
|
a = "5.1"
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
from ast import (Assign, Name, Attribute, Expr, Num, Str, NameConstant, Load, Store)
|
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:
|
""" This macro takes literal strings and converts them into:
|
||||||
_help_ID = type_hint+STRING
|
_help_ID = type_hint+STRING
|
||||||
where:
|
where:
|
||||||
ID is the first target of the last assignment.
|
ID is the first target of the last assignment.
|
||||||
type_hint is the assigned type and default value (only works for a few types)
|
type_hint is the assigned type and default value (only works for a few types)
|
||||||
STRING is the literal string """
|
STRING is the literal string """
|
||||||
for n in range(len(sentences)):
|
for n in range(len(tree)):
|
||||||
s = sentences[n]
|
s = tree[n]
|
||||||
if not n:
|
if not n:
|
||||||
prev = s
|
prev = s
|
||||||
continue
|
continue
|
||||||
|
|
@ -48,7 +48,7 @@ def document(sentences, to_source, **kw):
|
||||||
target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store())
|
target = Attribute(value=Name(id='self', ctx=Load()), attr=doc_id, ctx=Store())
|
||||||
else:
|
else:
|
||||||
target = Name(id=doc_id, ctx=Store())
|
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
|
prev = s
|
||||||
# Return the modified AST
|
# Return the modified AST
|
||||||
return sentences
|
return tree
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import mcpy.activate # noqa: F401
|
import mcpy.activate # noqa: F401
|
||||||
import application # noqa: F401
|
import application # noqa: F401
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue