docs: rework generating property infos to use <description> element
The "generate-docs-nm-property-infos.py" script parses the tags like "---nmcli---" and generates an XML. Rework it: - don't put long text descriptions in a "description=" XML attribute. Instead, use an XML element. That is in line with what "generate-docs-nm-settings-docs-gir.py" does, which generates a similar file. - if there is no <description-docbook> element, generate one based on <description>. That is important, because we want to create paragraphs. It's also important because "generate-docs-nm-settings-docs-gir.py" tends to generate <description-docbook> from the libnm/gir data. However, if you specify a "---nmcli---" override, then that should automatically apply to <description> and <description-docbook>.
This commit is contained in:
@@ -116,7 +116,7 @@ def get_file_infos(source_files):
|
|||||||
|
|
||||||
|
|
||||||
KEYWORD_XML_TYPE_NESTED = "nested"
|
KEYWORD_XML_TYPE_NESTED = "nested"
|
||||||
KEYWORD_XML_TYPE_NODE = "node"
|
KEYWORD_XML_TYPE_ELEM = "elem"
|
||||||
KEYWORD_XML_TYPE_ATTR = "attr"
|
KEYWORD_XML_TYPE_ATTR = "attr"
|
||||||
|
|
||||||
keywords = collections.OrderedDict(
|
keywords = collections.OrderedDict(
|
||||||
@@ -127,12 +127,13 @@ keywords = collections.OrderedDict(
|
|||||||
("values", KEYWORD_XML_TYPE_ATTR),
|
("values", KEYWORD_XML_TYPE_ATTR),
|
||||||
("default", KEYWORD_XML_TYPE_ATTR),
|
("default", KEYWORD_XML_TYPE_ATTR),
|
||||||
("example", KEYWORD_XML_TYPE_ATTR),
|
("example", KEYWORD_XML_TYPE_ATTR),
|
||||||
("description", KEYWORD_XML_TYPE_ATTR),
|
("description", KEYWORD_XML_TYPE_ELEM),
|
||||||
("description-docbook", KEYWORD_XML_TYPE_NESTED),
|
("description-docbook", KEYWORD_XML_TYPE_NESTED),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def keywords_allowed(tag, keyword):
|
def keywords_allowed(tag, keyword):
|
||||||
# certain keywords might not be valid for some tags.
|
# certain keywords might not be valid for some tags.
|
||||||
# Currently, all of them are always valid.
|
# Currently, all of them are always valid.
|
||||||
@@ -163,7 +164,7 @@ def write_data(tag, setting_node, line_no, parsed_data):
|
|||||||
# Set as XML nodes. The input data is XML itself.
|
# Set as XML nodes. The input data is XML itself.
|
||||||
des = ET.fromstring("<%s>%s</%s>" % (k, v, k))
|
des = ET.fromstring("<%s>%s</%s>" % (k, v, k))
|
||||||
property_node.append(des)
|
property_node.append(des)
|
||||||
elif xmltype == KEYWORD_XML_TYPE_NODE:
|
elif xmltype == KEYWORD_XML_TYPE_ELEM:
|
||||||
node = ET.SubElement(property_node, k)
|
node = ET.SubElement(property_node, k)
|
||||||
node.text = v
|
node.text = v
|
||||||
elif xmltype == KEYWORD_XML_TYPE_ATTR:
|
elif xmltype == KEYWORD_XML_TYPE_ATTR:
|
||||||
@@ -171,6 +172,17 @@ def write_data(tag, setting_node, line_no, parsed_data):
|
|||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
if (
|
||||||
|
parsed_data.get("description", None) is not None
|
||||||
|
and parsed_data.get("description-docbook", None) is None
|
||||||
|
):
|
||||||
|
# we have a description, but no docbook. Generate one.
|
||||||
|
node = ET.SubElement(property_node, 'description-docbook')
|
||||||
|
for l in re.split("\n", parsed_data["description"]):
|
||||||
|
paragraph = ET.SubElement(node, "para")
|
||||||
|
paragraph.text = l
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kwd_first_line_re = re.compile(r"^ *\* ([-a-z0-9]+): (.*)$")
|
kwd_first_line_re = re.compile(r"^ *\* ([-a-z0-9]+): (.*)$")
|
||||||
kwd_more_line_re = re.compile(r"^ *\*( *)(.*?)\s*$")
|
kwd_more_line_re = re.compile(r"^ *\*( *)(.*?)\s*$")
|
||||||
|
Reference in New Issue
Block a user