I want to publish an add-on and wonder what is the best structure of my git repository. Is there anything like a best practice or a starter project?
I have looked at existing add-ons. Some of them are named like “my-addon” (with a hyphen) and have the actual source code in “my-addon/my_addon” (with an underscore), some in “my-addon/src”, others in the top-level directory. Then I found repos with a “manifest.json”, others with an “addon.json”.
Are these files documented somewhere?
And where do I get the numerical id for my add-on from?
Different developers use different methods and the structure doesn’t matter most of the time, but some structures will prove more flexible depending on the add-on.
If you only have a basic add-on then just putting all files in a flat repo will work and is the simplest option. But it doesn’t hurt to be a bit more organized and put sources in a separate subdirectory. This will come useful when your add-on gets more complex and you start making use of code generation (most common case being building Qt forms using Qt Designer).
The “my-addon/my-addon” is a common way to structure Python projects and used by popular add-ons (e.g. add-ons of Glutanimate and the AnKing). I believe it’s the structure expected by Glutanimate’s add-on builder so it’s used by any add-on using that.
I personally use the “my-addon/src” structure where sources (and generated files) go to a src subdirectory. This directory can then be zipped and distributed as the add-on’s installation file.
I learned to use this structure from the LPCG add-on (LPG is an exemplary add-on) and used it for all my add-ons ever since and built tools around it.
Then I found repos with a “manifest.json”, others with an “addon.json”.