Support new attribute tag description-docbook

`description-docbook` is the alternative tag to `description`, the
difference is that `description-docbook` expects docbook XML but not
plaintext.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang
2021-05-23 21:52:18 -04:00
committed by Wen Liang
parent 6ac304b673
commit 0b87d8d6c5
3 changed files with 44 additions and 8 deletions

View File

@@ -111,6 +111,13 @@ def node_set_attr(dst_node, name, nodes):
dst_node.set(name, x)
def find_first_not_none(itr):
for i in itr:
if i is not None:
return i
return None
###############################################################################
gl_only_from_first = False
@@ -173,6 +180,11 @@ for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name):
dbg("> > > > property_name: %s" % (property_name))
properties_attrs = list([p.get(property_name) for p in properties])
description_docbook = find_first_not_none(
p_attr.find("description-docbook")
for p_attr in properties_attrs
if p_attr is not None
)
if gl_only_from_first and properties_attrs[0] is None:
dbg("> > > > skip (only-from-first")
@@ -193,5 +205,8 @@ for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name):
node_set_attr(property_node, "default", properties_attrs)
node_set_attr(property_node, "description", properties_attrs)
node_set_attr(property_node, "alias", properties_attrs)
if description_docbook is not None:
property_node.insert(0, description_docbook)
ET.ElementTree(root_node).write(gl_output_xml_file)