Split yaml_node.py into modules by concern #148

Merged
Claude merged 1 commit from chore/split-yaml-node into feat/yaml-nodes 2026-10-18 06:50:44 +00:00
Collaborator

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, plus field_spec.
  • endpoint_parse.py: NodeError, fail and the require_* helpers, the pin helpers, parse_pin, parse_binds, parse_commands and parse_endpoint.
  • node_parse.py: parse_fixed_node, parse_node, check_unique and the cross-node resolution (find_endpoint, resolve_bind, resolve_command).
  • cpp_render.py: cpp_string, touch_calls, mode_mask, declare_endpoint, includes and render.
  • yaml_node.py keeps load_all, find_node, generate and the __main__ that build_yaml_nodes.sh runs.

No re-export shim: node_schema.py and test_yaml_node.py import from the module that owns each name. NodeError lives in endpoint_parse.py beside fail, since the parsing modules raise it and yaml_node.py imports them; gen_node.py imports it from there. node_schema.py no longer imports three names it never used (sys, sourceTypes, commandInputs). The sys.path insert in gen_node.py needed no change. I left the "Generated from ... by node_gen/yaml_node.py" header as it is: yaml_node.py is 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_c3 with NODE=node_gen/tests/fixtures/c3.yaml builds from a clean directory, and build_yaml_nodes.sh builds 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.

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, plus `field_spec`. - `endpoint_parse.py`: `NodeError`, `fail` and the `require_*` helpers, the pin helpers, `parse_pin`, `parse_binds`, `parse_commands` and `parse_endpoint`. - `node_parse.py`: `parse_fixed_node`, `parse_node`, `check_unique` and the cross-node resolution (`find_endpoint`, `resolve_bind`, `resolve_command`). - `cpp_render.py`: `cpp_string`, `touch_calls`, `mode_mask`, `declare_endpoint`, `includes` and `render`. - `yaml_node.py` keeps `load_all`, `find_node`, `generate` and the `__main__` that `build_yaml_nodes.sh` runs. No re-export shim: `node_schema.py` and `test_yaml_node.py` import from the module that owns each name. `NodeError` lives in `endpoint_parse.py` beside `fail`, since the parsing modules raise it and `yaml_node.py` imports them; `gen_node.py` imports it from there. `node_schema.py` no longer imports three names it never used (`sys`, `sourceTypes`, `commandInputs`). The `sys.path` insert in `gen_node.py` needed no change. I left the "Generated from ... by node_gen/yaml_node.py" header as it is: `yaml_node.py` is 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_c3` with `NODE=node_gen/tests/fixtures/c3.yaml` builds from a clean directory, and `build_yaml_nodes.sh` builds 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`.
Split yaml_node.py into modules by concern
All checks were successful
Build and test / build (pull_request) Successful in 5m25s
Build and test / release (pull_request) Has been skipped
ea90c02e88
Claude merged commit b7040a32ae into feat/yaml-nodes 2026-10-18 06:50:44 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
CamperCan/CampervanControlSystems!148
No description provided.