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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pyang/plugins/uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

dest="uml_no_inline_groupings_from",
action="append",
default=[],
help="Skips given modules from inline groupings. \nExample --uml-no-inline-groupings-from=ietf-yang-push"),
optparse.make_option("--uml-inline-augments",
action="store_true",
dest="uml_inline_augments",
Expand Down Expand Up @@ -188,6 +193,7 @@ def __init__(self, ctx):
self.ctx_title = ctx.opts.uml_title

self.ctx_inline_augments = ctx.opts.uml_inline_augments
self.ctx_no_inline_groupings_from = set(ctx.opts.uml_no_inline_groupings_from)

no = ctx.opts.uml_no.split(",")
self.ctx_leafrefs = not "leafref" in no
Expand Down Expand Up @@ -255,6 +261,7 @@ def emit(self, modules, fd):

if not self.ctx_filterfile:
self.post_process_module(module, fd)

if not self.ctx_filterfile:
self.post_process_diagram(fd)

Expand Down Expand Up @@ -413,6 +420,11 @@ def emit_child_stmt(self, parent, node, fd, cont = True):
if hasattr(node, 'i_grouping') and (self._ctx.opts.uml_inline) and cont:
grouping_node = node.i_grouping
if grouping_node is not None:
# skip grouping modules if given
module = str(grouping_node.main_module()).split()[-1]
if module in self.ctx_no_inline_groupings_from:
fd.write('%s : %s {uses} \n' %(self.full_path(parent), node.arg))
return
# inline grouping here
# sys.stderr.write('Found target grouping to inline %s %s \n' %(grouping_node.keyword, grouping_node.arg))
for children in grouping_node.substmts:
Expand Down Expand Up @@ -591,8 +603,6 @@ 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_footer(self, module, fd):
if self._ctx.opts.uml_footer is not None:
fd.write('center footer\n <size:24> %s </size>\n endfooter \n' %self._ctx.opts.uml_footer)
Expand Down