In another thread
<https://groups.google.com/forum/#!topic/leo-editor/x2hBEuiCLgY> I said
that a breakthrough in documentation is lurking. And it probably is.
Here, I'd like to report *another*, completely unexpected breakthrough.
*Aha*: Let each node in a demo script tree contain *multiple *demo scripts.
So simple, so useful.
*Docstrings are not needed*. Syntax coloring is useful again!
Demos need far fewer script nodes. It's a huge win.
This Aha suggests how to add org-mode-like features to Leo. Adding this
feature took exactly three new lines of code in the demo startup logic.
Edward
P. S. The obvious place for the script tree is as a child of the top-level
script. To make this work, *the top-level script node must not contain
@others*. This allows the script tree to be executed only by the demo code,
not by the top-level script itself.
So top-level scripts should contain only section references: Like this:
if c.isChanged(): c.save()
<< imports >>
<< class MyDemo >>
# The *same* command/key binding calls both demo-start and demo.next.
try:
if getattr(g.app, 'demo', None):
g.app.demo.next()
else:
g.cls()
c.frame.log.clearTab('Log')
g.es_print('Starting MyDemo')
demo = MyDemo(c, trace=False)
demo.start(p=g.findNodeInTree(c, p, 'demo-script')) # <----------
except Exception:
g.app.demo = None
raise
The dog that isn't barking is the missing @others.
scripts.leo now contains a copy of this node and its children.
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.