On Wed, Aug 11, 2010 at 2:10 PM, Edward K. Ream <[email protected]> wrote:

> The script, temporarily in leo\core\format-code.py, is a test bed for
> simplifications.

The present script, in leo/core/format-code.py, presently does all the
formatting that I want in a prototype.  The code is indeed
substantially simpler than before.  The only even vaguely complicated
code is in writeBody and its helper, split_parts.  Split parts parses
body text into a list of code and body parts.  It recognizes @
@rst-markup and @ @rst-options parts and treats them as it should.

This is the simplest code possible, imo.  But is this script good
enough?  I think so, because the target is rST/Sphinx, **not** .html
or .pdf or .tex.   This meas that the script can pretty much ignore a
lot of details.  If that's not good enough, there is no easy way to
improve the present script.

Now we come to an interesting design questions.  The present code
*formats* code properly, but it lacks the "environmental" features of
the rst3 command.  At present, it doesn't pass code directly to
docutils or Sphinx, it doesn't deal with @path, etc. So the choice is
either:

1. To duplicate lots of rst3 code in the script or

2. To fold the new code back into the rst3 command.

Neither options is totally pleasing.  In particular, option 2 invites
me to put back the code_mode option!! I had better resist this and go
for option 1.

Edward

P.S.  It is amazing how even a single formatting option complicates
the code.  At present, there is only one such option,
show_doc_parts_as_paragraphs.  This is the option that complicates the
interactions between writeBody and split_parts.  At present, all other
options are benign: they affect at most one method.  In particular, at
present handling headline text is completely separate from handling
body text.

At present, the code does not handle doc_parts_only, but it could do
so easily enough.

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to