libnm: Override parts of nm-setting-docs.xml

Add "---dbus---" sections to the NMSetting property docs, in the same
style as the plugin docs, parse them out into a file
"nm-setting-docs-overrides.xml", and use them to override the GObject
property docs in nm-setting-docs.xml.

This lets us put more D-Bus-specific information in the setting docs,
without cluttering up the property docs, and it also lets us document
dbus-only properties.
This commit is contained in:
Dan Winship
2014-11-16 15:36:18 -05:00
committed by Dan Winship
parent 780d8bf2fe
commit 36156b70dc
12 changed files with 207 additions and 15 deletions

View File

@@ -152,6 +152,7 @@ def usage():
parser = argparse.ArgumentParser()
parser.add_argument('-g', '--gir', metavar='FILE', help='NM-1.0.gir file')
parser.add_argument('-x', '--overrides', metavar='FILE', help='documentation overrides file')
parser.add_argument('-o', '--output', metavar='FILE', help='output file')
args = parser.parse_args()
@@ -172,6 +173,8 @@ settings = sorted(settings, key=lambda setting: setting.attrib['{%s}symbol-prefi
init_constants(girxml, settings)
overrides = ET.parse(args.overrides).getroot()
outfile.write("""<?xml version=\"1.0\"?>
<!DOCTYPE nm-setting-docs [
<!ENTITY quot "&#34;">
@@ -188,24 +191,41 @@ for settingxml in settings:
outfile.write(" <setting name=\"%s\">\n" % setting.props.name)
properties = sorted(GObject.list_properties(setting), key=lambda prop: prop.name)
for pspec in properties:
propxml = settingxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
if propxml is None:
propxml = basexml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
if propxml is None:
propxml = ipxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) }
setting_overrides = { override.attrib['name']: override for override in overrides.findall('./setting[@name="%s"]/property' % setting.props.name) }
value_type = get_prop_type(setting, pspec, propxml)
value_desc = get_docs(setting, pspec, propxml)
default_value = get_default_value(setting, pspec, propxml)
properties = sorted(set.union(set(setting_properties.keys()), set(setting_overrides.keys())))
for prop in properties:
value_type = None
value_desc = None
default_value = None
if prop in setting_properties:
pspec = setting_properties[prop]
propxml = settingxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
if propxml is None:
propxml = basexml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
if propxml is None:
propxml = ipxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
value_type = get_prop_type(setting, pspec, propxml)
value_desc = get_docs(setting, pspec, propxml)
default_value = get_default_value(setting, pspec, propxml)
if prop in setting_overrides:
override = setting_overrides[prop]
if override.attrib['format'] != '':
value_type = override.attrib['format']
if override.attrib['description'] != '':
value_desc = override.attrib['description']
if default_value is not None:
outfile.write(" <property name=\"%s\" type=\"%s\" default=\"%s\" description=\"%s\" />\n" %
(pspec.name, value_type, escape(default_value), escape(value_desc)))
(prop, value_type, escape(default_value), escape(value_desc)))
else:
outfile.write(" <property name=\"%s\" type=\"%s\" description=\"%s\" />\n" %
(pspec.name, value_type, escape(value_desc)))
(prop, value_type, escape(value_desc)))
outfile.write(" </setting>\n")