generate-docs-nm-settings-docs-gir: move deprecation info to a separate tag

Previously, the deprecation data was included in <description*>, in form
of an integer. E.g.:

  /**
   * NMSettingLala:hello:
   *
   * Does this and that.
   *
   * Deprecated: 1.12: Be sad instead.
   **/

Results in:

  <property name="hello">
    <description>Does this and that. Deprecated: 1</description>
  </property>

Let's make it do this instead:

  <property name="hello">
    <description>Does this and that.</description>
    <deprecated since="1.12">Be sad instead.</description>
  </property>
This commit is contained in:
Lubomir Rintel
2022-09-06 17:18:58 +02:00
parent d71f0aac39
commit 4d42b81d2a
3 changed files with 42 additions and 17 deletions

View File

@@ -120,14 +120,8 @@ def remove_prefix(line, prefix):
return line[len(prefix) :] if line.startswith(prefix) else line
def get_docs(propxml):
doc_xml = propxml.find("gi:doc", ns_map)
if doc_xml is None:
return None
def format_docs(doc_xml):
doc = doc_xml.text
if "deprecated" in propxml.attrib:
doc = doc + " Deprecated: " + propxml.attrib["deprecated"]
# split docs into lines
lines = re.split("\n", doc)
@@ -173,6 +167,14 @@ def get_docs(propxml):
return doc
def get_docs(propxml):
doc_xml = propxml.find("gi:doc", ns_map)
if doc_xml is None:
return None
else:
return format_docs(doc_xml)
def get_default_value(setting, pspec, propxml):
default_value = setting.get_property(pspec.name.replace("-", "_"))
if default_value is None:
@@ -274,6 +276,13 @@ def main(gir_path_str, output_path_str):
value_desc = get_docs(propxml)
default_value = get_default_value(setting, pspec, propxml)
if "deprecated" in propxml.attrib:
deprecated = True
deprecated_since = propxml.attrib["deprecated-version"]
deprecated_desc = format_docs(propxml.find("gi:doc-deprecated", ns_map))
else:
deprecated = False
prop_upper = prop.upper().replace("-", "_")
if value_desc is None:
@@ -310,6 +319,22 @@ def main(gir_path_str, output_path_str):
create_desc_docbook(description_docbook, value_desc)
if deprecated:
ET.SubElement(
property_element,
"deprecated",
attrib={
"since": deprecated_since,
},
).text = deprecated_desc
deprecated_docbook = ET.SubElement(
property_element,
"deprecated-docbook",
)
create_desc_docbook(deprecated_docbook, deprecated_desc)
docs_gir.write(
output_path_str,
xml_declaration=True,