mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
528 stars 342 forks source link

UML Plugin: Fix dots in identifiers not being converted to underscore in PlantUML keywords #875

Closed nkhancock closed 8 months ago

nkhancock commented 11 months ago

PlantUML does not accept dots in keywords, but the current UML plugin does not convert dots in keywords (as permitted for YANG identifiers by RFC 7950 section 6.2) to underscores in the function make_plantuml_keyword().

This fix replaces dots with 2 underscores to ensure there is no chance of a clash of keywords where say both the identifiers 'a.b' and 'a-b' exist.

If PlantUML code is generated from the following test module (no specific UML-specific option specified), PlantUML brings an error.

module test-identifier-dots {
  yang-version 1.1;
  namespace "http://www.example.com/ns/yang/test-identifier-dots";
  prefix tst-id-dots;
  revision 2023-07-17 {
    description
      "Initial revision.";
    reference
      "None.";
  }
  identity base-identity {
    description
      "Base identity for identities.";
  }
  identity a {
    base base-identity;
    description
      "...";
  }
  identity a.1 {
    base a;
    description
      "...";
  }
  identity a-1 {
    base a;
    description
      "...";
  }
  identity a.2 {
    base a;
    description
      "...";
  }
  identity a-2 {
    base a;
    description
      "...";
  }
  identity a.2-b.1 {
    base a.2;
    description
      "...";
  }
}

With this fix, the following UML diagram is generated: image