summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWen Liang <liangwen12year@gmail.com>2021-05-23 21:52:18 -0400
committerWen Liang <wenliang@redhat.com>2021-06-23 08:59:45 -0400
commit0b87d8d6c50b4e2d68384d1122b3d75dfa5de3fd (patch)
tree471b8d111ffcedc5220a1e3b5dd29aa7502a8ca8 /tools
parent6ac304b67303980b579153e113ec4285a758def4 (diff)
downloadNetworkManager-0b87d8d6c50b4e2d68384d1122b3d75dfa5de3fd.tar.gz
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>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/generate-docs-nm-property-infos.py18
-rwxr-xr-xtools/generate-docs-nm-settings-docs-merge.py15
2 files changed, 31 insertions, 2 deletions
diff --git a/tools/generate-docs-nm-property-infos.py b/tools/generate-docs-nm-property-infos.py
index 238469c66c..74e88d6ad1 100755
--- a/tools/generate-docs-nm-property-infos.py
+++ b/tools/generate-docs-nm-property-infos.py
@@ -66,6 +66,7 @@ def process_data(data):
"default",
"example",
"description",
+ "description-docbook",
]
kwd_pat = "|".join(keywords)
keyword = ""
@@ -76,14 +77,20 @@ def process_data(data):
kwd_more_line_found = re.search(r"^\s*\**\s+(.*?)\s*$", line)
if kwd_first_line_found:
keyword = kwd_first_line_found.group(1)
- value = kwd_first_line_found.group(2) + " "
+ if keyword == "description-docbook":
+ value = kwd_first_line_found.group(2) + "\n"
+ else:
+ value = kwd_first_line_found.group(2) + " "
parsed_data[keyword] = value
elif kwd_more_line_found:
if not keyword:
print("Extra mess in a comment: %s" % (line))
exit(1)
else:
- value = kwd_more_line_found.group(1) + " "
+ if keyword == "description-docbook":
+ value = kwd_more_line_found.group(1) + "\n"
+ else:
+ value = kwd_more_line_found.group(1) + " "
parsed_data[keyword] += value
for keyword in keywords:
if keyword == "variable" and keyword not in parsed_data:
@@ -104,6 +111,13 @@ def write_data(setting_node, parsed_data):
property_node.set("default", parsed_data["default"])
property_node.set("example", parsed_data["example"])
property_node.set("description", parsed_data["description"])
+ if parsed_data["description-docbook"]:
+ des = ET.fromstring(
+ "<description-docbook>"
+ + parsed_data["description-docbook"]
+ + "</description-docbook>"
+ )
+ property_node.append(des)
def pretty_xml(element, newline, level=0):
diff --git a/tools/generate-docs-nm-settings-docs-merge.py b/tools/generate-docs-nm-settings-docs-merge.py
index 33c8eff0df..0f0f181bdb 100755
--- a/tools/generate-docs-nm-settings-docs-merge.py
+++ b/tools/generate-docs-nm-settings-docs-merge.py
@@ -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)