On Wed, Oct 16, 2019 at 5:04 PM The Living Cosmos 
<[email protected]> wrote:

There was a comment somewhere on the Leo website about Ed's methodology to 
> understand a large code​ ​base. It said something like:
>
> "I create a new git repo and import all the files using @clean" or 
> something like that.
>
> If anyone could point me to this information, I would appreciate it.
>

​The general ideas are as you remember:

1. Use git to manage the code you want to study.  This is optional, but 
highly recommended if you want to change the code.  That way you sure what 
changes you made.

2. Use a recursive import script to import the files of interest into Leo.  
This will simply call c.recursiveImport.  The docstring is:

"""
Recursively import all python files in a directory and clean the results.

Parameters::
    dir_              The root directory or file to import.
    kind              One of ('@clean','@edit','@file','@nosent').
    add_path=True     True: add a full @path directive to @<file> nodes.
    recursive=True    True: recurse into subdirectories.
    safe_at_file=True True: produce @@file nodes instead of @file nodes.
    theTypes=None     A list of file extensions to import.
                      None is equivalent to ['.py']

This method cleans imported files as follows:

- Replace backslashes with forward slashes in headlines.
- Remove empty nodes.
- Add @path directives that reduce the needed path specifiers in descendant 
nodes.
- Add @file to nodes or replace @file with @@file.
"""

An example script is:

'''Recursively import all python files in a directory and clean the 
result.'''
@tabwidth -4 # For a better match.
dir_ = r'path-to-a-folder'
g.cls()
c.recursiveImport(
    dir_=dir_,
    kind = '@clean', # '@auto', '@clean', '@nosent','@file',
    add_path = True,
    recursive = False,
    safe_at_file = False,
    theTypes = ['.py',] #
)

If you set safe_at_file to True, the script will general @@clean instead of 
@clean, so you won't have to worry about changing the original sources.  
Having said that, it's very useful to be able to change the code you want 
to study!

HTH.

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/2a8ec22c-c690-4a36-ad4d-dc0e79263d6b%40googlegroups.com.

Reply via email to