Skip to content
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
25 changes: 23 additions & 2 deletions pyang/plugins/uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def add_opts(self, optparser):
dest="uml_classes_only",
default = False,
help="Generate UML with classes only, no attributes "),
optparse.make_option("--uml-rpc-classes",
action="store_true",
dest="uml_rpc_classes",
default = False,
help="Generate UML with RCP as classes instead of operations "),
optparse.make_option("--uml-split-pages",
dest="uml_pages_layout",
help="Generate UML output split into pages (separate .png files), NxN, example 2x2 "),
Expand Down Expand Up @@ -138,6 +143,7 @@ class uml_emitter:
ctx_title = None
ctx_fullpath = False
ctx_classesonly = False
ctx_rpc_classes = False
ctx_description = False
ctx_leafrefs = True
ctx_uses = True
Expand All @@ -152,7 +158,7 @@ class uml_emitter:
ctx_truncate_augments = False
ctx_inline_augments = False
ctx_no_module = False

ctx_filterfile = False
ctx_usefilterfile = None
groupings = dict()
Expand All @@ -174,6 +180,7 @@ def __init__(self, ctx):
self.ctx_fullpath = ctx.opts.uml_longids
self.ctx_description = ctx.opts.uml_descr
self.ctx_classesonly = ctx.opts.uml_classes_only
self.ctx_rpc_classes = ctx.opts.uml_rpc_classes
# output dir from option -D or default img/
if ctx.opts.uml_outputdir is not None:
self.ctx_outputdir = ctx.opts.uml_outputdir
Expand Down Expand Up @@ -343,7 +350,10 @@ def emit_stmt(self, mod, stmt, fd):
if stmt.keyword == 'typedef':
self.emit_typedef(mod, stmt,fd)
elif stmt.keyword == 'rpc':
self.emit_action(mod, stmt,fd)
if self.ctx_rpc_classes:
self.emit_rpc(mod, stmt,fd)
else:
self.emit_action(mod, stmt,fd)
elif stmt.keyword == 'notification':
self.emit_notif(mod, stmt,fd)
elif stmt.keyword == 'feature':
Expand Down Expand Up @@ -736,6 +746,17 @@ def emit_notif(self, module, stmt,fd):
#for params in stmt.substmts:
# emit_child_stmt(stmt, params, fd)

def emit_rpc(self, module, stmt,fd):
fd.write('class \"%s\" as %s << (R,#00D1B2) rpc>> \n' %(self.full_display_path(stmt), self.full_path(stmt)))
fd.write('%s -- %s : rpc \n' %(self.make_plantuml_keyword(module.arg), self.full_path(stmt)))
for sub_stmt in stmt.substmts:
if sub_stmt.keyword == 'input' or sub_stmt.keyword == 'output':
parent = statements.Statement(stmt, stmt, None, sub_stmt.keyword, sub_stmt.keyword)
fd.write('class \"%s\" as %s <<%s>> \n' % (stmt.arg, self.full_path(parent), sub_stmt.keyword))
fd.write('%s -- %s : %s\n' % (self.full_path(stmt), self.full_path(parent), sub_stmt.keyword))
for params in sub_stmt.substmts:
self.emit_child_stmt(parent, params, fd)

def emit_uses(self, parent, node):
p = self.full_path(parent)
# MEF
Expand Down