The leo-editor-contrib <http://editor/leo-editor-contrib> repo now contains 
ruff-study.leo 
<https://github.com/leo-editor/leo-editor-contrib/blob/master/StudyOutlines/ruff-study.leo>,
 
a study outline for ruff <https://github.com/astral-sh/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 
<https://github.com/leo-editor/leo-editor/pull/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

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/a8e84eb4-ed83-4229-9467-f3df5913e82fn%40googlegroups.com.

Reply via email to