The new Importer class now *is* a pipeline

32 views
Skip to first unread message

Edward K. Ream

unread,
Nov 10, 2016, 6:27:48 PM11/10/16
to leo-e...@googlegroups.com
I've just added a longer version of this post at the end of #334.  I wanted to reference those remarks here as an acknowledgement of Tom F's contribution.

Tom's importer proposal was the first to suggest that the importers be organized as a pipeline. At first, I dismissed that suggestion. In fact Tom's suggestions have been marinating in the back of my mind ever since. Thank you, Tom! Leo's great new importers owe a lot to you...

The new Importer class now clearly is a pipeline:

Stage 1: i.run calls the first stage: i.v2_gen_lines. It generates, in a single, non-recursive pass, all the output nodes.

Stage 2: i.run then calls the second stage, i.post_pass, which runs a series of other passes:

def post_pass(self, parent):
    '''Clean up parent and all its descendants.'''
    self.clean_all_headlines(parent)
    self.clean_all_nodes(parent)
    self.unindent_all_nodes(parent)
    # These passes must follow unindent_all_nodes.
    self.promote_trailing_underindented_lines(parent)
    # This probably should be the last pass.
    self.delete_all_empty_nodes(parent)

This organization solves a number of technical problems, and makes it much easier to create custom importers.

Edward

Edward K. Ream

unread,
Dec 3, 2016, 6:15:37 PM12/3/16
to leo-editor
On Thu, Nov 10, 2016 at 5:27 PM, Edward K. Ream <edre...@gmail.com> wrote:

Tom's importer proposal was the first to suggest that the importers be organized as a pipeline.

​While writing the documentation, I realized that i.check could be considered the fourth pipeline stage.  It's a reasonable change in point of view.  i.run runs all four stages...

EKR

Edward K. Ream

unread,
Dec 3, 2016, 7:07:42 PM12/3/16
to leo-editor


On Saturday, December 3, 2016 at 5:15:37 PM UTC-6, Edward K. Ream wrote:
On Thu, Nov 10, 2016 at 5:27 PM, Edward K. Ream <edre...@gmail.com> wrote:

Tom's importer proposal was the first to suggest that the importers be organized as a pipeline.

​While writing the documentation, I realized that i.check could be considered the fourth pipeline stage.

And, hehe, i.check_blanks_and_tabs is stage zero.

EKR
Reply all
Reply to author
Forward
0 new messages