Re: @button make-md-heads

2016-11-24 Thread Edward K. Ream
On Thu, Nov 24, 2016 at 2:24 PM, Kent Tenney <kten...@gmail.com> wrote:

This sounds wonderful, like so many other things which fly
> by in this list, making me wish for a way for me to access it
> 6 months from now, when I have a need for it.
>
> Buttons and commands strike me as parallel to Python's
> libraries. Could they be handled in a similar way, the
> moral equivalent of
>
> @button make-md-heads
>  from leodoc.leo import make-md-heads
>

​Interesting comparison. Alas, there is a gotcha: if we *know* the name of
some @button or other script, we can surely find it.  The problem is that
we need to be reminded how to find it...

>
> I think that kind of pattern might be way to improve access
> to hundreds (thousands?) of snippets on this list I've been
> delighted by, only to lose track of.
>

​​Imo, documentation has to be a big part of the answer.  Your analogy with
the python libraries is apt.  How useful would they be without
documentation?

A few days pass, now a breakthrough on the testing front ...
>
> Leo needs a structure to standardize packaging, locating
> and exposing this kind of thing!!
>

​I agree, but ​
"clever" solutions are
​ likely to be​
faux solutions.

My interim approach is to document things on leo-editor as I go along, with
the understanding that this is pre-writing for better docs later.

Back to the analogy with the python library.  The library is organized by
module, with everything in a module being related somehow, and with strong
documentation for each module.

To really be useful, we must have the same for Leo's important snippets.
There aren't going to be great shortcuts.  Tagging isn't a substitute for
full-fledged module-like docs.

In short, there is plenty of work to do.

EKR

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: @button make-md-heads

2016-11-24 Thread Kent Tenney
This sounds wonderful, like so many other things which fly
by in this list, making me wish for a way for me to access it
6 months from now, when I have a need for it.

Buttons and commands strike me as parallel to Python's
libraries. Could they be handled in a similiar way, the
moral equivalent of

@button make-md-heads
 from leodoc.leo import make-md-heads

I think that kind of pattern might be way to improve access
to hundreds (thousands?) of snippets on this list I've been
delighted by, only to lose track of.
###

A few days pass, now a breakthrough on the testing front ...

Leo needs a structure to standardize packaging, locating
and exposing this kind of thing!!

Thanks,
Kent


On Sun, Nov 20, 2016 at 5:57 PM, Edward K. Ream <edream...@gmail.com> wrote:

> On Sun, Nov 20, 2016 at 12:08 PM, Edward K. Ream <edream...@gmail.com>
> wrote:
>
>> I have started the process of converting the lengthy documentation for
>> ​​
>> #334 <https://github.com/leo-editor/leo-editor/issues/334> to a .md file
>> on GitHub.
>>
>
>
>> The new @button make-md-headers script does this automatically.
>>
>
> ​This has gone through several revisions.  It now changes *all* @
> x.md trees.  Besides updating headings, it ensures that all nodes end
> with a blank line so as not to interfere with following headers.
>
> I have put this script through its paces while creating this page
> <https://github.com/leo-editor/leo-editor/blob/master/leo/doc/importers.md>.
> At present it is just a dump of the posts for
> ​
> #334 <https://github.com/leo-editor/leo-editor/issues/334>. It must be
> completely rewritten, but the workflow has been vindicated.
>
> EKR
>
> --
> 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 leo-editor+unsubscr...@googlegroups.com.
> To post to this group, send email to leo-editor@googlegroups.com.
> Visit this group at https://groups.google.com/group/leo-editor.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


Re: @button make-md-heads

2016-11-20 Thread Edward K. Ream
On Sun, Nov 20, 2016 at 12:08 PM, Edward K. Ream 
wrote:

> I have started the process of converting the lengthy documentation for
> ​​
> #334  to a .md file
> on GitHub.
>


> The new @button make-md-headers script does this automatically.
>

​This has gone through several revisions.  It now changes *all* @
x.md trees.  Besides updating headings, it ensures that all nodes end with
a blank line so as not to interfere with following headers.

I have put this script through its paces while creating this page
.
At present it is just a dump of the posts for
​
#334 . It must be
completely rewritten, but the workflow has been vindicated.

EKR

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.


@button make-md-heads

2016-11-20 Thread Edward K. Ream
I have started the process of converting the lengthy documentation for #334 
 to a .md file on 
GitHub.

LeoDocs.leo now contains this tree:

@nosent importers.md
<< intro >>
@others
@language md

However, the user is responsible for generate markdown headers, as 
described here 
. 
This will quickly become a chore, especially when rearranging the tree.

The new @button make-md-headers script does this automatically.  At 
present, it does this only for the "nearest" @ x.md trees, using the 
new p.nearest() generator.  However, it would also be possible to 
regenerate *all* .md trees, using another generator.

Anyway, the present driver code is:

def run(p1):
'''Run markup on all nearby trees.'''

def predicate(p):
return p.isAnyAtFileNode() and p.h.strip().endswith('.md')

for root in p1.nearest_roots(predicate):
for p in root.self_and_subtree():
markup(p, root)

And business end is:

pattern = re.compile(r'^(#+\s+)(.*)$')

def markup(p, root):
'''prepend p.b[0] with markdown section markup, if appriate.'''
# g.trace(p.h)
root_level = root.level()
lines = g.splitLines(p.b)
if len(lines) < 2: return
line0, line1 = lines[0], lines[1]
if (
not p.h.startswith('@md-ignore') and
not line0.isspace() and # A real first line.
not line0.startswith('@') and # Not a directive
line1.isspace() # the next line is blank
):
m = pattern.match(line0)
if m:
# g.trace('FOUND', repr(m.group(1)), repr(m.group(2)))
# Remove existing markup.
line0 = m.group(2) + '\n'
hashes = '#'*(p.level()-root_level+1)
lines[0] = '%s %s' % (hashes, line0)
# g.printList(lines)
s = ''.join(lines)
if p.b != s:
print('changed %s' % (p.h))
p.setDirty()
c.setChanged(True)
p.b = ''.join(lines)

As you can see, this is not undoable...

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 leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.