summaryrefslogtreecommitdiff
path: root/tools/generate-docs-nm-settings-docs-merge.py
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-05-17 12:19:34 +0200
committerThomas Haller <thaller@redhat.com>2023-05-17 13:03:34 +0200
commit56dbb4a5be5caaeda5655534b6c2b6127ccf8e86 (patch)
tree11112f7f4b53c3faef77434078c1992dfb978ff1 /tools/generate-docs-nm-settings-docs-merge.py
parent8a11fdcb919fd182e8f705a326e67f2f89c132f9 (diff)
downloadNetworkManager-th/generate-doc-fixes.tar.gz
docs: fix generate-docs-nm-settings-docs-merge.py to only take first descriptionth/generate-doc-fixes
When we generate the manual page for nm-settings-nmcli, we run: "/usr/bin/python" \ ./tools/generate-docs-nm-settings-docs-merge.py \ --only-from-first \ man/nm-settings-docs-nmcli.xml \ src/nmcli/gen-metadata-nm-settings-nmcli.xml \ src/libnm-client-impl/nm-property-infos-nmcli.xml \ src/libnm-client-impl/nm-settings-docs-gir.xml Note that gen-metadata-nm-settings-nmcli.xml contains no descriptions (anymore). "nm-property-infos-nmcli.xml" contains the desciptions from the "---nmcli---" tags. This can be either "describe:" or "describe-docbook:". In any case, that is the one that we want to use. Note that "nm-settings-docs-gir.xml" almost always contains a <describe-docbook> tag. Previously, "generate-docs-nm-settings-docs-merge.py" would take both the <describe> and <describe-docbook> tags, from whereever it finds it first. So it might take the <describe> tag from "nm-property-infos-nmcli.xml", and <describe-docbook> from "nm-settings-docs-gir.xml". Since the later XLS prefers the <describe-docbook> tag, it would use the wrong one. For example, `man nm-settings-nmcli.5` contained the gtk doc connection.uuid A universally unique identifier for the connection, for example generated with libuuid. ... when it should contain the nmcli override
Diffstat (limited to 'tools/generate-docs-nm-settings-docs-merge.py')
-rwxr-xr-xtools/generate-docs-nm-settings-docs-merge.py44
1 files changed, 32 insertions, 12 deletions
diff --git a/tools/generate-docs-nm-settings-docs-merge.py b/tools/generate-docs-nm-settings-docs-merge.py
index 0131a02488..1a6a7c24a5 100755
--- a/tools/generate-docs-nm-settings-docs-merge.py
+++ b/tools/generate-docs-nm-settings-docs-merge.py
@@ -113,12 +113,39 @@ def node_set_attr(dst_node, name, nodes):
def find_attr(properties_attrs, name):
for p_attr in properties_attrs:
- if p_attr is not None:
- p_attr = p_attr.find(name)
+ if p_attr is None:
+ continue
+ p_attr = p_attr.find(name)
if p_attr is not None:
return p_attr
+def find_attr_text(properties_attrs, name):
+ name_docbook = name + "-docbook"
+ for p_attr in properties_attrs:
+ if p_attr is None:
+ continue
+
+ x = p_attr.get(name, None)
+ if x is None:
+ x = p_attr.find(name)
+ if x is not None:
+ print(f">>>> [{x.text}]")
+ x = x.text
+
+ if x is not None:
+ p_normal = ET.Element("description")
+ p_normal.text = x
+ else:
+ p_normal = None
+
+ p_docbook = p_attr.find(name_docbook)
+
+ if p_normal is not None or p_docbook is not None:
+ return p_normal, p_docbook
+ return None, None
+
+
###############################################################################
gl_only_from_first = False
@@ -181,10 +208,8 @@ 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_attr(properties_attrs, "description-docbook")
- description = find_attr(properties_attrs, "description")
- deprecated_docbook = find_attr(properties_attrs, "deprecated-docbook")
- deprecated = find_attr(properties_attrs, "deprecated")
+ description, description_docbook = find_attr_text(properties_attrs, "description")
+ deprecated, deprecated_docbook = find_attr_text(properties_attrs, "deprecated")
if gl_only_from_first and properties_attrs[0] is None:
dbg("> > > > skip (only-from-first")
@@ -203,16 +228,11 @@ for setting_name in iter_keys_of_dicts(settings_roots, key_fcn_setting_name):
node_set_attr(property_node, "type", properties_attrs)
node_set_attr(property_node, "default", properties_attrs)
- desc_value = node_get_attr(properties_attrs, "description")
node_set_attr(property_node, "alias", properties_attrs)
if description_docbook is not None:
property_node.insert(0, description_docbook)
- if desc_value:
- description = ET.Element("description")
- description.text = desc_value
- property_node.append(description)
- elif description is not None:
+ if description is not None:
property_node.append(description)
if deprecated_docbook is not None: