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

Schematic write formatting doesn't match KiCAD #5

Open
shreekumar3d opened this issue Jun 18, 2024 · 1 comment
Open

Schematic write formatting doesn't match KiCAD #5

shreekumar3d opened this issue Jun 18, 2024 · 1 comment

Comments

@shreekumar3d
Copy link

I found this library useful to automatically update schematics. Thanks for this!

I track my changes on git, and try to track changes like code. When skip write schematics, it writes split lines. This formatting differs from KiCAD, which uses nested indentation. This makes it difficult to use the output directly with git diff - primarily to see whether the script did exactly what was intended.

E.g. a file written by skip on my system has this as the first line

(kicad_sch (version 20231120) (generator "eeschema") (generator_version "8.0") (uuid "012bf1cf-e3e3-4b01-8e23-6b37d758d0e3") (paper "A1") (lib_symbols

When KiCAD saves the file, I get

(kicad_sch
    (version 20231120)
    (generator "eeschema")
    (generator_version "8.0")
    (uuid "012bf1cf-e3e3-4b01-8e23-6b37d758d0e3")
    (paper "A1")
    (lib_symbols

The order of elements saved by both KiCAD and skip library seems to be same, but the difference is in the indentation and line formatting. To get clean git diffs, I now open the file generated by skip, and save the file. Then commit the schematic. Fixing the schematic write seems useful.

Fixing schematic write - writeTree() in sexp/util.py I suppose would resolve this. I see some comments there that I don't understand :) Any guidance appreciated. I can submit a PR.

@shreekumar3d
Copy link
Author

shreekumar3d commented Jun 18, 2024

From KiCAD's output, there may be some formatting gotchas. "xy" lists are clearly handled differently. One place I saw custom logic was when it split up "xy" lists in "polyline" into two lines.

EDIT: Looking at the source code of KiCAD, it is clear that logic specific to the type of symbols is involved (arc, circle, polygon, bezier etc). So making this happen would require the writeTree functionality to mirror KiCAD logic,

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