Issue #1440 <https://github.com/leo-editor/leo-editor/issues/1440> has been 
closed. The fstrings branch has been merged into devel. A bit more 
documentation work remains.

The highlights of #1440 are:

- An improved beautify-files command, including the diff-beautify-files 
command.

- A new fstringify-files command, which is significantly better than the 
stand-alone 
fstringify tool <https://pypi.org/project/fstringify/>.

- New classes that insert two-way links between Python's tokens and 
corresponding parse tree nodes.

Testing reveals that Leo's beautify-files command must work differently 
from the external black tool <https://black.readthedocs.io/en/stable/>. The 
problems run "both ways"...

*Black is unsuitable for use with Leo's external files*

There are several problems.  First, and most importantly, black changes 
Leo's sentinels. This might make it impossible for Leo to read those 
external files. Sentinels do not exist for @clean files, but that doesn't 
really matter.  Within @clean files, black would insert blank lines before 
and after all classes, methods and functions. Those blank lines would then 
show up as annoying extra blank lines most nodes of the @clean tree.

*Leo's beautify-files command must work differently from black*

*beautify-files now leaves blank lines unchanged*. I experimented with 
making exceptions for blank lines at the start and end of nodes, but the 
code was ugly and mostly useless. The simplest thing that could possibly 
work is to leave blank lines as they are.

There are other differences, some based on settings that do not exist in 
black. These differences are worth having.

*Summary*

This project has been worthwhile, despite taking much longer than expected. 
Leo's beautify-files and fstringify-files are complete demonstrations of 
the classes that provide two-way links between tokens and parse-tree nodes. 
Having access to info in the parse trees simplifies Leo's fstringify-files 
and beautify-files commands in important ways.

Black and Leo's beautify commands are two separate worlds. There will be no 
stand-alone Orange tool:

- Black already is good enough for files created outside of Leo.
- A stand-alone Orange tool would add nothing to Leo's beautify-files 
command.

A stand-alone fstringify tool based on Leo's code would be conceivable, but 
I have no plans to do so.

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/b6395dcd-fda4-4aa8-a557-f4d60a0acaeb%40googlegroups.com.

Reply via email to