I'll watch this with interest, if only because one project for my 'copious free time' is adding an importer for a QnD note-taking format I use myself.
I started on this a while ago but got a bit bogged down in the details of the current mechanism, and have never got back to it (typical!) J^n On Sunday, November 14, 2021 at 1:17:02 PM UTC Edward K. Ream wrote: > #2327 <https://github.com/leo-editor/leo-editor/issues/2327> suggests > improving the python importer. This issue is scheduled for Leo 6.7, but it > may make it into 6.6. > > This Engineering Notebook post consists of notes to myself. Feel free to > ignore. > > *Defects* > > I've put up with the following defects of the python importer for way too > long: > > 1. Perfect import checks can fail due to underindented lines, especially > comment lines. > 2. Perfect import checks can fail due to misplaced (or missing?) decorator > lines. > 3. The python post-pass code is a bit of a mess. > 4. The python importer's main line, py_i.gen_lines, may be more complex > than necessary. > > *The causes of complexity* > > The python importer is *far* more complex than the python-to-typescript > command: > > - The importer must, without fail, handle strings and docstrings properly. > This requirement entails the entire token-state logic. > - Decorators complicate how the code recognizes the start and end of > classes and functions. > - Allocating "in-between" lines (lines between functions or methods) is > always going to be tricky. Presumably, the post pass will play a part. > > *The goals* > > The python importer must import *all* python files exactly, except for > *underindented > comment lines*. > > The python importer should be allowed to adjust underindented comment > lines by adding needed indentation. > > The python perfect import checks should warn about adjusted comment lines, > but the python importer should *not* insert @ignore directives merely due > to adjusted comment lines. > > > *Open questions* > > 1. Which code should handle decorators: the main line or the post pass? > > 2. Which code should handle in-between lines? > > *Summary* > > The python importer is shockingly inadequate: > > - The importer inserts @ignore directives for way too many files. > - The post pass does not account for the *indentation level* implied by > @others directives. Indented @others directives increase this level. > - The code that handles decorators is complex and buggy. > - The post-pass needs a redesign. > > The overall design and organization of Leo's importers will remain > completely unchanged. Only the Py_Importer class will change. > > I'll fix #2327 <https://github.com/leo-editor/leo-editor/issues/2327> for > Leo 6.6 if possible, but I shall not hurry this project. > > 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 view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/00fd955c-6689-4241-a0e2-8073a3de20bfn%40googlegroups.com.
