The leo-editor-contrib repo now contains ruff-study.leo, a study outline for ruff's formatter. The study outline shows a new importer pattern, as this post will now explain.
This study outline contains the result of running the recursive import script using the improved rust importer per PR #3628. This PR significantly improves the Rust importer found in Leo's devel branch. I'll merge the PR soon.
The Rust importer faces two puzzling choices:
- How to simplify headlines?
- When to generate @others?
Aha
I experimented with several schemes (in the rust importer itself) before realizing (Aha!) the importer need not aim for perfection. Instead, undoable scripts in the study outline can tweak the imported code (or even parts of the imported code).
The @button clean-rust script in ruff-study.leo is the first such script. It removes some @others directives and simplifies headlines.
Summary
Importers for syntactically complex languages such as Rust can't generate optimal outlines in all situations. Such importers should refrain from making dubious choices.
Instead, outlines can define scripts to tweak the resulting code. These scripts should be undoable. That way, we can experiment freely without reimporting the files.
Edward