Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mofosyne opened this issue Sep 20, 2024 · 1 comment
Open

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

mofosyne opened this issue Sep 20, 2024 · 1 comment

Comments

@mofosyne
Copy link

mofosyne commented Sep 20, 2024

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 mofosyne changed the title You may want to put your output through an s-expression linter You may want to put your output through an s-expression formatter Sep 20, 2024
@mofosyne
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant