Skip to content
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

adding --uml-no-inline-groupings-from #872

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

kirankotari
Copy link

When we use --uml-inline-grouping flag we can expect to ignore base modules like tailf-ncs etc, in this PR we are added new flags.

Command:

pyang -f uml l3vpn.yang --path=/tmp/.ncs_uml --uml-inline-groupings --uml-skip-module=tailf-ncs --uml-output-directory=.  --uml-no=module,import,annotation  --uml-add-legend 2> /dev/null

--uml-add-legend adds filenames from shared grouping - Note: not skipping any module for this example
Here is the legend plantUML code generated.

legend
Grouping data pulled from
  l3vpn.yang
  tailf-ncs-services.yang
  tailf-ncs-log.yang
endlegend

--uml-skip-module=tailf-ncs with --uml-inline-groupings, inline grouping adds all the grouping uses in the yang including the base service-data, plan-date and more, in the new flag we can skip entire module from inline-grouping.
Here the skip modules are kept in the {uses} as before --uml-inline-groupings flag.

Image before the --uml-skip-module
image

Image with --uml-skip-module
image

@@ -1,4 +1,4 @@
"""The pyang library for parsing, validating, and converting YANG modules"""

__version__ = '2.5.3'
__version__ = '2.5.4'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that this decision is left to the repository owners.

dest="uml_skip_module",
action="append",
default=[],
metavar="SKIP MODULE",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the default metavar, i.e., UML_SKIP_MODULE to indicate the context of the UML plugin; or at least SKIP_MODULE.

Suggested change
metavar="SKIP MODULE",

@@ -93,6 +93,16 @@ def add_opts(self, optparser):
optparse.make_option("--uml-filter-file",
dest="uml_filter_file",
help="NOT IMPLEMENTED: Only paths in the filter file will be included in the diagram"),
optparse.make_option("--uml-skip-module",
Copy link
Contributor

@nkhancock nkhancock Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --uml-inline-groupings option is then not applied to those uses statements for groupings in the list of modules specified in --uml-skip-module? Correct?

Is this intended to only be applicable when the --uml-inline-groupings global option with the --uml-skip-module option is selected?

If so then the name of this option is too general and is thus misleading and should be improved to make it clearer, e.g., something like --uml-no-inline-groupings-from.

Also if --uml-inline-groupings and --uml-skip-module are not specified wouldn't it be expected that if a legend is specified, then the modules of the groupings should be listed as when --uml-inline-groupings=true and --uml-skip-module is not empty?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --uml-inline-groupings option is then not applied to those uses statements for groupings in the list of modules specified in --uml-skip-module? Correct?

No, and I agree to the 3 point to switch to --uml-no-inline-groupings-from

Is this intended to only be applicable when the --uml-inline-groupings global option with the --uml-skip-module option is selected?

Yes

If so then the name of this option is to general and is thus misleading and should be improved to make it clearer, e.g., something like --uml-no-inline-groupings-from.

I will adopt to this option

Also if --uml-inline-groupings and --uml-skip-module are not specified wouldn't it be expected that if a legend is specified, then the modules of the groupings should be listed as when --uml-inline-groupings=true and --uml-skip-module is not empty?

You point is true, but if I don't use --uml-inline-groupings the uml is not traversing to it's groupings (other modules) so far. Now I see based on your comment the legend can be improved to touch the submodule too to keep in generic not just for --uml-inline-groupings

action="append",
default=[],
metavar="SKIP MODULE",
help="skips given modules, i.e., --uml-skip-module=tailf-ncs"),
Copy link
Contributor

@nkhancock nkhancock Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text should be improved to make it clearer what the actual skipping of modules means. See my comment on line 96.

Also avoid referencing specific modules that may not be available to everyone, e.g., tailf-ncs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkhancock do you have any common example for this?

Copy link
Contributor

@nkhancock nkhancock Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkhancock do you have any common example for this?

A possible candidate could be ietf-yang-push. This has internal groupings and also uses an external grouping from ietf-yang-patch.

default=[],
metavar="SKIP MODULE",
help="skips given modules, i.e., --uml-skip-module=tailf-ncs"),
optparse.make_option("--uml-add-legend",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this option implies that the user could define or control the rendering of a legend in the diagram, whereas this legend is specific to the --uml-skip-module option.

It also needs to be considered how such an option could co-exist with a possible new option to render a user-specified legend going forward.

Maybe consider using a note instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I tried note, which is mapping to the last class (It needed more logic to map to right class etc) let me revisit and add the changes.

@nkhancock
QQ: Shall I pull out the changes of --uml-add-legend and open a new PR when it's ready?

Copy link
Contributor

@nkhancock nkhancock Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I pull out the changes of --uml-add-legend and open a new PR when it's ready?

That's up to you. If the changes are completely independent, maybe separate PRs would make it easier to review. It's basically up to you.

pyang/plugins/uml.py Outdated Show resolved Hide resolved
@@ -591,7 +615,12 @@ def emit_module_header(self, module, fd):
def emit_module_class(self, module, fd):
fd.write('class \"%s\" as %s << (M, #33CCFF) module>> \n' %(self.full_display_path(module), self.full_path(module)))


def emit_uml_legend(self, module, fd):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this function is too general for the function it performs. It is specific to the --uml-skip-modules option.

To allow possible future support for a user to define a legend with a given text, this function should just accept a text to be shown within the legend box and a new function specific to --uml-skip-modules, e.g., emit_uml_skip_modules_legend could be defined that creates the required text for the skip module legend and calls the general function.

pyang/plugins/uml.py Outdated Show resolved Hide resolved
pyang/plugins/uml.py Outdated Show resolved Hide resolved
@@ -591,7 +615,12 @@ def emit_module_header(self, module, fd):
def emit_module_class(self, module, fd):
fd.write('class \"%s\" as %s << (M, #33CCFF) module>> \n' %(self.full_display_path(module), self.full_path(module)))


def emit_uml_legend(self, module, fd):
fd.write('legend \n')
Copy link
Contributor

@nkhancock nkhancock Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a legend be written if there are no files/modules to list, i.e., only when self.ctx_grp_files is not empty? If I don't specify either --uml-inline-groupings or --uml-skip-module, but specify --uml-add-legend, then a legend is displayed without any files listed.

Also if --uml-inline-groupings and --uml-skip-module are not specified wouldn't it be expected that if a legend is specified, then the modules of the groupings should be listed as when --uml-inline-groupings=true and --uml-skip-module is not empty?

@kirankotari
Copy link
Author

@nkhancock Thanks for reviewing it. I will do update and improve the content.

kirankotari and others added 5 commits July 10, 2023 16:38
updating `--uml-add-legend` help

Co-authored-by: Nick Hancock <nick.hancock@adtran.com>
updating to module

Co-authored-by: Nick Hancock <nick.hancock@adtran.com>
legend msg update

Co-authored-by: Nick Hancock <nick.hancock@adtran.com>
@kirankotari kirankotari changed the title adding --uml-skip-module, --uml-add-legend adding --uml-no-inline-groupings-from Jul 11, 2023
@kirankotari kirankotari requested a review from nkhancock July 11, 2023 22:15
@@ -62,6 +62,11 @@ def add_opts(self, optparser):
dest="uml_inline",
default =False,
help="Inline groupings where they are used."),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a note could be added to this text to indicate that groupings from specific modules can be omitted from this option through use of the --uml-no-inline-groupings-from option.

@@ -62,6 +62,11 @@ def add_opts(self, optparser):
dest="uml_inline",
default =False,
help="Inline groupings where they are used."),
optparse.make_option("--uml-no-inline-groupings-from",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although suggested by myself, I am not totally convinced by this name.
Maybe others have better suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants