mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 10:14:41 +00:00
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:
parent
6ac304b673
commit
0b87d8d6c5
|
@ -150,12 +150,19 @@
|
|||
Alias: <xsl:value-of select="@alias"/>
|
||||
</para>
|
||||
</xsl:if>
|
||||
<para>
|
||||
<xsl:value-of select="@description"/>
|
||||
<xsl:if test="@type = 'NMSettingSecretFlags (uint32)'">
|
||||
See <xref linkend="secrets-flags"/> for flag values.
|
||||
</xsl:if>
|
||||
</para>
|
||||
<xsl:choose>
|
||||
<xsl:when test="description-docbook">
|
||||
<xsl:copy-of select="./description-docbook/*/."/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<para>
|
||||
<xsl:value-of select="@description"/>
|
||||
<xsl:if test="@type = 'NMSettingSecretFlags (uint32)'">
|
||||
See <xref linkend="secrets-flags"/> for flag values.
|
||||
</xsl:if>
|
||||
</para>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@type">
|
||||
<para>
|
||||
Format: <xsl:value-of select="@type"/>
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue