On Sat, Mar 25, 2017 at 9:33 PM, Eric S. Johansson <[email protected]>
wrote:
> Like Ed's engineering notebook posts, it's a public declaration of
> thoughts with an invitation a comment if I'm going to far off the rails
>
I'm glad to help.
> In my simplistic use of Leo, I will have at most one document directive
> followed by a code directive.
>
I assume you mean:
@doc
...
@c
> I don't know if it's possible or even a good idea to have multiple
> document and code directives. Somewhere I picked up the idea that one
> thought per node is a good idea.
>
It's possible to have more than one @doc/@c (or simply @/@c) directive
pairs.
It's a moot point in python programming because docstrings are considered
better style.
Keeping things simple, I need to figure out how to select everything in a
> code directive region and replace it with a new body of text.
>
Exactly as stated, this might indeed be "full of hairballs". There are at
leas two preliminary questions that may help you make this simpler.
1. Whenever dealing with sections (<< whatever >> ) and their expansions,
you should think first of top-level code in leoAtFile.py that "pretends" to
write the file, but instead writes the file to a string:
def write(self, root,
kind='@unknown', # Should not happen.
nosentinels=False,
perfectImportFlag=False,
scriptWrite=False,
thinFile=False,
toString=False,
):
This method really should have a better docstring. In particular, the
docstring should mention that at.stringOutput contains the resulting string
when toString is True.
The following is tested code (in an @button node):
at = c.atFileCommands
at.write(
p,
kind='@file',
nosentinels=True,
toString=True,
)
print(at.stringOutput)
2. I wouldn't try to *replace *the parts of an outline unless there is
absolutely no other way. Instead, I would write the result of point 1
somewhere, say in an @toggle-name tree:
@toggle-name
@toggle-@file-a
@toggle-@clean-b
...
Something like this should save you from having to touch actual code.
HTH.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.