goplantuml
goplantuml copied to clipboard
Better detection or prevention of invalid output
There have been a few issues in the past (e.g. #3, #50, #49) where the plantuml output contained invalid syntax/content. It might be a good idea to add some output filtering and/or monitoring to automatically detect and/or filter and/or comment out portions of the output that will prevent plantuml from rendering the rest of the output.
For example, from #50 (by @jfeliu007):
This is definitely a bug. {{packageName}} is use to to have a placeholder to later substitute the package name by the real name since many go file prefer to name imports using aliases.
Issues like those described in #49, #50 and #3 could be prevented from causing un-renderable output by filtering out (or commenting out) any lines that contain occurrences of certain known patterns.
For example:
goplantuml -recursive . | grep -v '{packageName}' | grep -F -v '<font color=blue>func</font>()' > goplantuml.recursive.puml
Such lines could alternatively be commented-out (instead of stripped) (e.g. using sed
).
Either of the above workarounds could be done manually by the user (using grep
and/or sed
or similar), except a novice user is unlikely to know what patterns to strip/convert. And (as issue #32 demonstrates) some users don't know enough about plantuml
to effectively identify and manually correct such errors in the output.
Instead, goplantuml
could internally perform equivalent filtering/commenting, so that users don't have to.
Also, it would be a better user experience if goplantuml
automatically prevented a handful of errors from making the entire output un-renderable. E.g. For the first project I used goplantuml
on, it generated >5000 lines of output that contained only 2 invalid lines. Simply removing or commenting-out those 2 lines made the rest of the diagram renderable and useful (though slightly incomplete due to the 2 missing edges/arrows).
Also, additional functional tests could be added to this repo (targeting a wider variety of OSS golang packages) and use similar pattern detection to detect whether goplantuml
generates any such invalid output is generated. Such tests would likely detect functional regressions in goplantuml
(e.g. when new versions of golang are released).