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.