Closed klauer closed 1 year ago
Merging #64 (04c98d5) into master (4ea1ea0) will increase coverage by
4.9%
. The diff coverage is77.6%
.
Functionally, I think this has most of what I want from the solution parser, reformatting tools and such.
I'll claim that the API is subject to change if/when I look to adding more input/output formats. For now, it's probably fine.
I'll look back into some TODO items and aim to merge this in the nearish future.
This is too big of a refactor to ask for a real review of anyone (well, blark's one contributor...).
As noted above, comments/complaints/requests on this change are welcome - just make an issue. All API introduced here subject to change at my own whim otherwise
If this breaks your usage of blark, let me know!
This is a pretty large refactor/enhancement, comments/ideas/complaints are welcome.
Goals
Primarily: to close https://github.com/klauer/blark/issues/53
More specifically (caveat: some goals may be walked back; some may not be written here yet) -
.st
files, and TwinCAT source code files)lxml
for project parsing.blark format --write my_pou.TcPOU
)blark.parse()
and similar API functions to return a consistentdataclass
type. This will group together the source code, a map of line numbers, thelark.Tree
, and an option to easily transform it intoblark.transform.SourceCode
dataclasses.blark parse
CLI as it's pretty bad inmaster
blark format
CLI to support these input/output formats and more closely mirror howblark parse
will workAt some point after this PR, I might consider:
blark scrape
- a tool to scrape codebases and dump out the requested information.pytmc pragmalint
(a tool for linting a specific set of pragmas in our TwinCAT projects) around the above. Piping results fromblark scrape --rule PRAGMA
intopytmc pragmalint
could help refer back to actual line numbers in files. Our current linting method (as exhibited here is off by a few lines due to pytmc throwing away line number information)Status
GlobalTextList
items are causing some failures (example)Example
Take, for example, a TwinCAT POU like FB_DummyHA.TcPOU. It's broken up into multiple XML sections, which we have no interest in adding grammar for.
In blark master:
FB_DummyHA blark-parse-able source
pytmc code lcls-twincat-pmps/PMPS/HelperFunctions/FB_DummyHA.TcPOU
and you should be able to get the same output.After this PR is finished
blark.input
)blark.solution
)BlarkSourceItem
(orBlarkCompositeSourceItem
).BlarkSourceItem
s may contain:In our above example:
blark parse FB_DummyHA.TcPOU
would be routed throughblark.solution
due to its TwinCAT file extensionTcPOU
would generateBlarkSourceItems
for each part, which may be wrapped into aBlarkCompositeSourceItem
with identifierFB_DummyHA
:What about other input/output formats?
I haven't decided, maybe one or more of the following paths forward: