Skip to content

Commit ef885cc

Browse files
samuel-gauthierrjarry
authored andcommitted
schema: use typedef description for type
When available, use the typedef's description for type. Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> Acked-by: Robin Jarry <robin@jarry.cc>
1 parent aaca4df commit ef885cc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

libyang/schema.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ def name(self) -> str:
516516
return self.basename()
517517

518518
def description(self) -> Optional[str]:
519+
typedef = self.typedef()
520+
if typedef:
521+
return typedef.description()
519522
return None
520523

521524
def base(self) -> int:

tests/test_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ def test_leaf_type_derived(self):
382382
self.assertEqual(mod.get_module_from_prefix("types").name(), "wtf-types")
383383
self.assertEqual(t.typedef().name(), "host")
384384
self.assertEqual(t.typedef().description(), "my host type.")
385+
self.assertEqual(t.description(), "my host type.")
385386

386387
def test_leaf_type_status(self):
387388
leaf = next(self.ctx.find_path("/yolo-system:conf/yolo-system:hostname"))

0 commit comments

Comments
 (0)