-
Notifications
You must be signed in to change notification settings - Fork 64
GH-455: It should be possible to output a vehicle signal specificatio… #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ication to (Plant) UML - Add new PlantUML exporter - Add associated documentation Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
return s[0].lower() + s[1:] | ||
|
||
# variant of get_fqn that skips instance nodes (and the top-level one) | ||
def get_fqn2(node: VSSNode) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we see a benefit integrating it into the Node.get_fqn
and use a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You tell me, I would not mind if get_fqn in Node has this option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending whether we would like to try to implement this exporter on the non expanded tree we probably do not need this anymore?
src/vss_tools/exporters/plantuml.py
Outdated
fqn = node.name | ||
while node.parent: | ||
data = node.get_vss_data() | ||
if node.is_leaf or (not data.is_instance): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks a bit that you could benefit from not looking at the expanded tree instead of skipping instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The main reasons for not doing it were that I was looking at the other exporters, which didn't use the unexpanded API. Thus, I was not aware of such an API and its use.
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Dear Sebastien, thanks for all your suggestions. I took (hopefully) all into account with a new commit to my fork, except the ones already commented above. |
The pre-commit is still failing. I will look at the issues found. The build itself is also not running, which I cannot reproduce on my machine. Any suggestions on what to change for a successful compilation? |
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Here is the patch to fix the mypy findings ;-): diff --git c/src/vss_tools/exporters/plantuml.py i/src/vss_tools/exporters/plantuml.py
index 08198c9..e90b996 100644
--- c/src/vss_tools/exporters/plantuml.py
+++ i/src/vss_tools/exporters/plantuml.py
@@ -13,9 +13,10 @@ import rich_click as click
import vss_tools.cli_options as clo
from vss_tools import log
from vss_tools.main import get_trees
+from vss_tools.model import VSSDataBranch
from vss_tools.tree import VSSNode
-fqns: set[str] = {}
+fqns: set[str] = set()
# make first character lowercase
@@ -31,7 +32,7 @@ def get_fqn2(node: VSSNode) -> str:
fqn = node.name
while node.parent:
data = node.get_vss_data()
- if node.is_leaf or (not data.is_instance):
+ if node.is_leaf or not (isinstance(data, VSSDataBranch) and data.is_instance):
# generated classes are in a package carrying their own name, but enumerations are not
if not getattr(data, "allowed", None):
fqn = "P" + node.name + "." + fqn
@@ -52,7 +53,7 @@ def get_classname(node: VSSNode, qualify: bool) -> str:
data = node.get_vss_data()
if node.is_leaf:
return get_name(node, qualify)
- elif not data.is_instance:
+ elif not (isinstance(data, VSSDataBranch) and data.is_instance):
if has_nested_instance_child(node):
return get_name(node, qualify) + "IS0"
elif has_instance_child(node):
@@ -89,7 +90,7 @@ def get_enums(tree: VSSNode, fill: str, attributes: tuple[str]) -> str:
fqn = get_fqn2(node)
if allowed and (fqn not in fqns):
# use enumeration instead of datatype, use 2nd level package name
- fqns[fqn] = True
+ fqns.add(fqn)
# create Enumeration
tree_content_lines.append("")
tree_content_lines.append("%s' %s" % (fill, data.description))
@@ -152,7 +153,7 @@ def get_rendered_class(tree: VSSNode, fill, attributes: tuple[str]) -> str:
def get_rendered_tree(node: VSSNode, fill, attributes: tuple[str]) -> str:
tree_content_lines = []
data = node.get_vss_data()
- needPkg = node.parent and (node.is_leaf or (not data.is_instance))
+ needPkg = node.parent and (node.is_leaf or not (isinstance(data, VSSDataBranch) and data.is_instance))
if needPkg:
tree_content_lines.append("%s' %s" % (fill, data.description))
tree_content_lines.append("%spackage P%s {" % (fill, node.name))
@@ -171,7 +172,7 @@ def get_rendered_tree(node: VSSNode, fill, attributes: tuple[str]) -> str:
else:
result = get_rendered_tree(node, nFill, attributes)
tree_content_lines.append(result)
- if data.is_instance:
+ if isinstance(data, VSSDataBranch) and data.is_instance:
break
if needPkg:
|
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
I checked the builds and it seems to fail on the coverage requirement as stated here: https://github.com/COVESA/vss-tools/blob/master/noxfile.py An easy way to fix it would be (I think) to add an "expected.plantuml" file to any of the test cases, for example in https://github.com/COVESA/vss-tools/tree/master/tests/vspec/test_comment It should be possible to generate with something like
That way the plantuml generator would be run as part of unit test, giving a bit increased coverage and also making sure that it is still functional |
Dear Erik, I will have a look at your suggestions, thanks. |
MoM:
|
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Two things I forgot:
|
Add link to plantuml in exporter section of vspec documentation Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
…ally) Signed-off-by: aradermache <ansgar.radermacher@cea.fr>
Looks good from my perspective, great that unit tests were added, some unresolved discussions with @sschleemilch remains. |
…n to (Plant) UML