kiutils icon indicating copy to clipboard operation
kiutils copied to clipboard

You may want to put your output through an s-expression formatter

Open mofosyne opened this issue 1 year ago • 1 comments

While debugging a bug in kiutils. I've written up a https://gist.github.com/mofosyne/93ad8d64fb40ef80f6af3b09dc755414 s-expression formatter for it.

It mostly matches the current KiCADv8 s-expression styling but diverges from KiCADv8's output style in that the 'xy' element inside 'pts' is also indented on a new line. This is because KiCADv8's styling rule is not consistent specifically regarding the 'pts' element.

But aside from that, it matches close enough to be useful as a 'output' cleaner for your utility, so you may want to consider piping your output though this at least.


This also provides an additional opportunity for testing your function. If you get a valid KiCADv8 document and you then lint it and also formatter the output of your kiutils then you will be able to do an automated diff to make sure there is no regression introduced.

This is because if I do not make any changes to a document then opening/saving the document should emit the same output.

mofosyne avatar Sep 20 '24 07:09 mofosyne

Made further cleanup of the script and placed it in this repo now https://github.com/mofosyne/sexp_formatter so reference this when you want to port it over.

mofosyne avatar Sep 22 '24 15:09 mofosyne