mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
537 stars 344 forks source link

UML Plugin: Fix top-level uses statement being ignored #891

Open nkhancock opened 7 months ago

nkhancock commented 7 months ago

When rendering YANG modules with a 'uses' statement at the module level, such as can be found the YANG module openconfig-telemetry@2018-11-21, the top-level uses statement is ignored. This pull request fixes this issue.

The following examples illustrate what has been fixed.

The following YANG data models were used to test this fix:

test-groupings ``` module test-groupings { namespace "http://www.adtran.com/ns/yang/test-groupings"; prefix tst-grp; revision 2024-03-11 { description "Initial revision."; reference "None."; } grouping grouping-1 { description "A grouping with a top-level non-interior data node."; leaf a-top-level-leaf-in-a-grouping { type string; description "Bla bla bla."; } } grouping grouping-2 { description "A grouping with a top-level interior data node."; container a-top-level-container { leaf a-leaf-within-a-top-level-container-in-a-grouping { type string; description "Bla bla bla."; } } } } ```
test-uses-top-level ``` module test-uses-top-level { namespace "http://www.adtran.com/ns/yang/test-uses-top-level"; prefix tst-uses-top; import test-groupings { prefix tst-grp; } revision 2024-03-11 { description "Initial revision."; reference "None."; } uses tst-grp:grouping-1; uses tst-grp:grouping-2; } ```

Example 1: UML option --uml-inline-groupings not used

Before the fix:

image

After the fix:

image

Example 2: UML option --uml-inline-groupings used

Before the fix:

image

After the fix:

image