How do you code sub-circuits? Is it a function that simply adds to a central (code) graph, it's parameters allowing customizations of some of the aspects it performs? Or is a function that builds a stand-alone (sub)circuit that then later gets added to the whole?
With my tool, sub-circuits can be, but are not necessarily built by functions. They are essentially objects. The basic "object" in Lua is a table, so I make heavy use of tables (which are pretty powerful).
So, a sub-circuit, that I called "module", is a structured table. You can manipulate it as any table, including making clones, etc. Essentially, a module is composed of: a list of ports, a list of nets, a list of sub-modules (interconnected by the nets at the module level), and additional attributes. What happens inside a module is completely local. Sub-modules can be any modules, so that's fully hierarchical. End-components are just modules that don't have sub-modules or nets.
Are you explicit in the input/output nets such a sub-circuit requires (hard params or properties on a class) -is this what you mean by ports?- or you just use a property-bag that contains named nets that need to be interfaced/connected?
Yes, each module has a list of "ports". A port is what can connect a module to other modules, has a name and can be a single-pin or a bus, and has properties such as direction (input, output, I/O, power in, power out, passive, ...) Those properties are used for ERC.
Sub-circuits as components is a very powerful abstraction, I feel lies the solution. I'm just looking for the correct code constructs to make that usable/feasible.
To me they are indeed. I suppose Skidl can allow that abstraction, but you should really ask the author now that maybe you have a clearer view of what you'd need.
Visualization: I know SKiDL has a (plugin/3rd party?) graph visualizer, but that does not read as a schematic. As with all auto generated diagrams, positioning and layout are the trickiest to automate correctly.
I'm curious what this plugin is using. I've tried using graphviz:
https://graphviz.org/ , but it's not very adapted to this task. It supports nodes with "ports", which would more or less allow to render views similar to block diagrams, but when using ports, it doesn't support orthogonal connections, so it basically draws connections with curves. Really not pretty.
One option would be ELK:
https://www.eclipse.org/elk/ , but I've never messed with Eclipse so far and am not skilled with Java. So I ruled that out for now.
Another option I found pretty interesting was netlistsvg:
https://github.com/nturley/netlistsvg , seemed pretty promising but I'v tried a few things with it and it still has too many bugs to be really usable for this. Neat stuff though. As it's javascript (and actually uses elkjs), I'm not too keen on helping/modifying it myself either.