Split yaml_node.py into modules by concern #148
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/split-yaml-node"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
YN-32.
node_gen/yaml_node.py(1,105 lines) is split along its four seams, one module per concern:node_tables.py: constants, boards, type tables, field specs and the other module-level dicts, plusfield_spec.endpoint_parse.py:NodeError,failand therequire_*helpers, the pin helpers,parse_pin,parse_binds,parse_commandsandparse_endpoint.node_parse.py:parse_fixed_node,parse_node,check_uniqueand the cross-node resolution (find_endpoint,resolve_bind,resolve_command).cpp_render.py:cpp_string,touch_calls,mode_mask,declare_endpoint,includesandrender.yaml_node.pykeepsload_all,find_node,generateand the__main__thatbuild_yaml_nodes.shruns.No re-export shim:
node_schema.pyandtest_yaml_node.pyimport from the module that owns each name.NodeErrorlives inendpoint_parse.pybesidefail, since the parsing modules raise it andyaml_node.pyimports them;gen_node.pyimports it from there.node_schema.pyno longer imports three names it never used (sys,sourceTypes,commandInputs). Thesys.pathinsert ingen_node.pyneeded no change. I left the "Generated from ... by node_gen/yaml_node.py" header as it is:yaml_node.pyis the entry point a reader would run, and it keeps the generated output byte-identical.No behaviour change. Before and after the split I ran the generator over every fixture for its environment, and the generated C++ and the stderr warnings are byte-identical (diff of the two output folders is empty). The schema regenerates unchanged,
pio run -e gen_xiao_c3withNODE=node_gen/tests/fixtures/c3.yamlbuilds from a clean directory, andbuild_yaml_nodes.shbuilds every fixture. No tests added or changed beyond their imports.Tested: Python 163, none skipped locally, with
python3 -m unittest discover -s node_gen/tests -t node_gen.