On Tuesday, October 15, 2013 10:11:26 AM UTC-5, Edward K. Ream wrote:
>
> This @button node saves a surprising amount of typing and futzing with 
> windows.
>

Rev 6151 contains a simpler, more powerful script in LeoDocs.leo: @button 
make-sphinx @key=Alt-.

It uses two new capabilities in Leo I added today:

1. g.execute_shell_commands, described at: 
https://groups.google.com/forum/#!topic/leo-editor/q7knota8KY0
2. The rst3 command (c.rstCommands.rst3) now returns a list of positions of 
the @rst nodes that it found.

Putting these two together, gives us::

    @language python
    import os
    trace = False
    g.cls()
    c.save()
    aList = c.rstCommands.rst3()
    if aList:
        path = g.os_path_finalize_join(g.app.loadDir,'..','doc','html')
        os.chdir(path)
        if len(aList) > 1: g.execute_shell_commands(['make 
clean'],trace=trace)
        g.execute_shell_commands(['make html'],trace=trace)
        fn = aList[0].h.strip() if len(aList) == 1 else 'leo_toc.html'
        fn = 
g.os_path_finalize_join(path,'_build','html',g.os_path_basename(fn))
        if g.os_path_exists(fn):
            # Don't wait for this command to exit!
            g.execute_shell_commands(['&%s' % (fn)])

Imo, this is a pretty good example of what Leo can do.  Of course, it 
helped to have been able to hack the rst3 command!

There are several notable improvements:

- The rst3 command now does all the work of discovering @rst nodes.
- If the rst3 command wrote multiple @rst nodes, the script does "make 
clean; make html" and opens the top-level TOC: leo_toc.html.
- Otherwise, the script just does "make html" and opens the single html 
file.
- Either way, Leo does not wait for the opened file to be closed.  That is, 
Leo does not hang.

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 http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to