2014-06-13 11:07:02 -04:00
|
|
|
#!/usr/bin/env python
|
2020-12-23 22:21:36 +01:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2019-09-25 13:13:40 +02:00
|
|
|
#
|
2019-10-01 09:20:35 +02:00
|
|
|
# Copyright (C) 2009 - 2017 Red Hat, Inc.
|
2019-09-25 13:13:40 +02:00
|
|
|
#
|
2014-06-13 11:07:02 -04:00
|
|
|
|
2014-08-12 13:04:35 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
|
|
2017-01-18 19:55:17 +01:00
|
|
|
import os
|
2015-11-11 10:37:07 +01:00
|
|
|
import gi
|
2020-06-26 10:18:49 +02:00
|
|
|
import xml.sax.saxutils as saxutils
|
2020-06-09 16:28:32 -04:00
|
|
|
|
|
|
|
|
gi.require_version("GIRepository", "2.0")
|
2017-01-18 19:55:17 +01:00
|
|
|
from gi.repository import GIRepository
|
2020-05-06 23:16:34 +02:00
|
|
|
import argparse, re, sys
|
2014-06-13 11:07:02 -04:00
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
|
2017-01-18 19:55:17 +01:00
|
|
|
try:
|
2020-06-09 16:28:32 -04:00
|
|
|
libs = os.environ["LD_LIBRARY_PATH"].split(":")
|
2017-01-18 19:55:17 +01:00
|
|
|
libs.reverse()
|
|
|
|
|
for lib in libs:
|
|
|
|
|
GIRepository.Repository.prepend_library_path(lib)
|
2017-01-19 11:37:41 +01:00
|
|
|
except AttributeError:
|
2020-06-09 16:28:32 -04:00
|
|
|
# An old GI version, that has no prepend_library_path
|
|
|
|
|
# It's alright, it probably interprets LD_LIBRARY_PATH
|
|
|
|
|
# correctly.
|
|
|
|
|
pass
|
2017-01-18 19:55:17 +01:00
|
|
|
except KeyError:
|
2020-06-09 16:28:32 -04:00
|
|
|
pass
|
2017-01-18 19:55:17 +01:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
gi.require_version("NM", "1.0")
|
2017-01-18 19:55:17 +01:00
|
|
|
from gi.repository import NM, GObject
|
|
|
|
|
|
2014-11-16 16:13:06 -05:00
|
|
|
dbus_type_name_map = {
|
2020-06-09 16:28:32 -04:00
|
|
|
"b": "boolean",
|
|
|
|
|
"s": "string",
|
|
|
|
|
"i": "int32",
|
|
|
|
|
"u": "uint32",
|
|
|
|
|
"t": "uint64",
|
|
|
|
|
"x": "int64",
|
|
|
|
|
"y": "byte",
|
|
|
|
|
"as": "array of string",
|
|
|
|
|
"au": "array of uint32",
|
|
|
|
|
"ay": "byte array",
|
|
|
|
|
"a{ss}": "dict of string to string",
|
|
|
|
|
"a{sv}": "vardict",
|
|
|
|
|
"aa{sv}": "array of vardict",
|
|
|
|
|
"aau": "array of array of uint32",
|
|
|
|
|
"aay": "array of byte array",
|
|
|
|
|
"a(ayuay)": "array of legacy IPv6 address struct",
|
|
|
|
|
"a(ayuayu)": "array of legacy IPv6 route struct",
|
2014-06-13 11:07:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ns_map = {
|
2020-06-09 16:28:32 -04:00
|
|
|
"c": "http://www.gtk.org/introspection/c/1.0",
|
|
|
|
|
"gi": "http://www.gtk.org/introspection/core/1.0",
|
|
|
|
|
"glib": "http://www.gtk.org/introspection/glib/1.0",
|
2014-06-13 11:07:02 -04:00
|
|
|
}
|
2020-06-09 16:28:32 -04:00
|
|
|
identifier_key = "{%s}identifier" % ns_map["c"]
|
|
|
|
|
nick_key = "{%s}nick" % ns_map["glib"]
|
|
|
|
|
symbol_prefix_key = "{%s}symbol-prefix" % ns_map["c"]
|
2014-06-13 11:07:02 -04:00
|
|
|
|
2014-08-27 19:57:24 +02:00
|
|
|
constants = {
|
2020-06-09 16:28:32 -04:00
|
|
|
"TRUE": "TRUE",
|
|
|
|
|
"FALSE": "FALSE",
|
|
|
|
|
"G_MAXUINT32": "G_MAXUINT32",
|
|
|
|
|
"NULL": "NULL",
|
|
|
|
|
}
|
2014-06-13 11:07:02 -04:00
|
|
|
setting_names = {}
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2017-03-30 16:34:55 +02:00
|
|
|
def get_setting_name_define(setting):
|
|
|
|
|
n = setting.attrib[symbol_prefix_key]
|
|
|
|
|
if n and n.startswith("setting_"):
|
|
|
|
|
return n[8:].upper()
|
2020-06-09 16:28:32 -04:00
|
|
|
raise Exception('Unexpected symbol_prefix_key "%s"' % (n))
|
|
|
|
|
|
2017-03-30 16:34:55 +02:00
|
|
|
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
def init_constants(girxml, settings):
|
2020-06-09 16:28:32 -04:00
|
|
|
for const in girxml.findall("./gi:namespace/gi:constant", ns_map):
|
|
|
|
|
cname = const.attrib["{%s}type" % ns_map["c"]]
|
|
|
|
|
cvalue = const.attrib["value"]
|
2014-06-13 11:07:02 -04:00
|
|
|
if const.find('./gi:type[@name="utf8"]', ns_map) is not None:
|
|
|
|
|
cvalue = '"%s"' % cvalue
|
|
|
|
|
constants[cname] = cvalue
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
for enum in girxml.findall("./gi:namespace/gi:enumeration", ns_map):
|
|
|
|
|
for enumval in enum.findall("./gi:member", ns_map):
|
2014-06-13 11:07:02 -04:00
|
|
|
cname = enumval.attrib[identifier_key]
|
2020-06-09 16:28:32 -04:00
|
|
|
cvalue = "%s (%s)" % (cname, enumval.attrib["value"])
|
2014-06-13 11:07:02 -04:00
|
|
|
constants[cname] = cvalue
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
for enum in girxml.findall("./gi:namespace/gi:bitfield", ns_map):
|
|
|
|
|
for enumval in enum.findall("./gi:member", ns_map):
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
cname = enumval.attrib[identifier_key]
|
2020-06-09 16:28:32 -04:00
|
|
|
cvalue = "%s (0x%x)" % (cname, int(enumval.attrib["value"]))
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
constants[cname] = cvalue
|
|
|
|
|
|
|
|
|
|
for setting in settings:
|
2020-06-09 16:28:32 -04:00
|
|
|
setting_type_name = "NM" + setting.attrib["name"]
|
|
|
|
|
setting_name_symbol = (
|
|
|
|
|
"NM_SETTING_" + get_setting_name_define(setting) + "_SETTING_NAME"
|
|
|
|
|
)
|
2016-11-29 21:03:14 +01:00
|
|
|
if setting_name_symbol in constants:
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
setting_name = constants[setting_name_symbol]
|
|
|
|
|
setting_names[setting_type_name] = setting_name
|
2014-06-13 11:07:02 -04:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2018-07-11 08:16:25 +02:00
|
|
|
def get_prop_type(setting, pspec):
|
2014-11-16 16:13:06 -05:00
|
|
|
dbus_type = setting.get_dbus_property_type(pspec.name).dup_string()
|
|
|
|
|
prop_type = dbus_type_name_map[dbus_type]
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
if GObject.type_is_a(pspec.value_type, GObject.TYPE_ENUM) or GObject.type_is_a(
|
|
|
|
|
pspec.value_type, GObject.TYPE_FLAGS
|
|
|
|
|
):
|
2014-11-16 16:13:06 -05:00
|
|
|
prop_type = "%s (%s)" % (pspec.value_type.name, prop_type)
|
|
|
|
|
|
2014-06-13 11:07:02 -04:00
|
|
|
return prop_type
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2017-03-10 20:08:11 +01:00
|
|
|
def get_docs(propxml):
|
2020-06-09 16:28:32 -04:00
|
|
|
doc_xml = propxml.find("gi:doc", ns_map)
|
2014-06-13 11:07:02 -04:00
|
|
|
if doc_xml is None:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
doc = doc_xml.text
|
2020-06-09 16:28:32 -04:00
|
|
|
if "deprecated" in propxml.attrib:
|
|
|
|
|
doc = doc + " Deprecated: " + propxml.attrib["deprecated"]
|
2014-06-13 11:07:02 -04:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
doc = re.sub(r"\n\s*", r" ", doc)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
# Expand constants
|
2020-06-09 16:28:32 -04:00
|
|
|
doc = re.sub(r"%([^%]\w*)", lambda match: constants[match.group(1)], doc)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
# #NMSettingWired:mac-address -> "mac-address"
|
2020-06-09 16:28:32 -04:00
|
|
|
doc = re.sub(r"#[A-Za-z0-9_]*:([A-Za-z0-9_-]*)", r'"\1"', doc)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
# #NMSettingWired setting -> "802-3-ethernet" setting
|
2020-06-09 16:28:32 -04:00
|
|
|
doc = re.sub(
|
|
|
|
|
r"#([A-Z]\w*) setting",
|
|
|
|
|
lambda match: setting_names[match.group(1)] + " setting",
|
|
|
|
|
doc,
|
|
|
|
|
)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
# remaining gtk-doc cleanup
|
2020-06-09 16:28:32 -04:00
|
|
|
doc = doc.replace("%%", "%")
|
|
|
|
|
doc = doc.replace("<!-- -->", "")
|
|
|
|
|
doc = re.sub(r" Element-.ype:.*", "", doc)
|
|
|
|
|
doc = re.sub(r"#([A-Z]\w*)", r"\1", doc)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
# Remove sentences that refer to functions
|
2022-03-21 09:42:39 +01:00
|
|
|
if "FindProxyForURL()" in doc:
|
|
|
|
|
# FIXME: this would break the description for "proxy.pac-script"
|
|
|
|
|
# Work around. But really the entire approach here is flawed
|
|
|
|
|
# and needs improvement.
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
doc = re.sub(r"\.\s+[^.]*\w\(\)[^.]*\.", r".", doc)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
return doc
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2014-06-13 11:07:02 -04:00
|
|
|
def get_default_value(setting, pspec, propxml):
|
2020-06-09 16:28:32 -04:00
|
|
|
default_value = setting.get_property(pspec.name.replace("-", "_"))
|
2014-06-13 11:07:02 -04:00
|
|
|
if default_value is None:
|
|
|
|
|
return default_value
|
|
|
|
|
|
2018-07-11 08:16:25 +02:00
|
|
|
value_type = get_prop_type(setting, pspec)
|
2020-06-09 16:28:32 -04:00
|
|
|
if value_type == "string" and default_value != "" and pspec.name != "name":
|
2014-06-13 11:07:02 -04:00
|
|
|
default_value = '"%s"' % default_value
|
2020-06-09 16:28:32 -04:00
|
|
|
elif value_type == "boolean":
|
2014-06-13 11:07:02 -04:00
|
|
|
default_value = str(default_value).upper()
|
2020-06-09 16:28:32 -04:00
|
|
|
elif value_type == "byte array":
|
|
|
|
|
default_value = "[]"
|
|
|
|
|
elif str(default_value).startswith("<"):
|
2014-06-13 11:07:02 -04:00
|
|
|
default_value = None
|
2020-06-09 16:28:32 -04:00
|
|
|
elif str(default_value).startswith("["):
|
libnm: rework team handling of JSON config
Completely refactor the team/JSON handling in libnm's NMSettingTeam and
NMSettingTeamPort.
- team handling was added as rh#1398925. The goal is to have a more
convenient way to set properties than constructing JSON. This requires
libnm to implement the hard task of parsing JSON (and exposing well-understood
properties) and generating JSON (based on these "artificial" properties).
But not only libnm. In particular nmcli and the D-Bus API must make this
"simpler" API accessible.
- since NMSettingTeam and NMSettingTeamPort are conceptually the same,
add "libnm-core/nm-team-utils.h" and NMTeamSetting that tries to
handle the similar code side-by-sdie.
The setting classes now just delegate for everything to NMTeamSetting.
- Previously, there was a very fuzzy understanding of the provided
JSON config. Tighten that up, when setting a JSON config it
regenerates/parses all other properties and tries to make the
best of it. When modifying any abstraction property, the entire
JSON config gets regenerated. In particular, don't try to merge
existing JSON config with the new fields. If the user uses the
abstraction API, then the entire JSON gets replaced.
For example note that nm_setting_team_add_link_watcher() would not
be reflected in the JSON config (a bug). That only accidentally worked
because client would serializing the changed link watcher to
GVariant/D-Bus, then NetworkManager would set it via g_object_set(),
which would renerate the JSON, and finally persist it to disk. But
as far as libnm is concerned, nm_setting_team_add_link_watcher() would
bring the settings instance in an inconsistent state where JSON and
the link watcher property disagree. Setting any property must
immediately update both the JSON and the abstraction API.
- when constucting a team setting from D-Bus, we would previously parse
both "config" and abstraction properties. That is wrong. Since our
settings plugins only support JSON, all information must be present
in the JSON config anyway. So, when "config" is present, only the JSON
must be parsed. In the best case, the other information is redudant and
contributes nothing. In the worse case, they information differs
(which might happen if the client version differs from the server
version). As the settings plugin only supports JSON, it's wrong to
consider redundant, differing information from D-Bus.
- we now only convert string to JSON or back when needed. Previously,
setting a property resulted in parsing several JSON multiple times
(per property). All operations should now scale well and be reasonably
efficient.
- also the property-changed signals are now handled correctly. Since
NMTeamSetting knows the current state of all attributes, it can emit
the exact property changed signals for what changed.
- we no longer use libjansson to generate the JSON. JSON is supposed
to be a machine readable exchange format, hence a major goal is
to be easily handled by applications. While parsing JSON is not so
trivial, writing a well-known set of values to JSON is.
The advantage is that when you build libnm without libjansson support,
then we still can convert the artificial properties to JSON.
- Requiring libjansson in libnm is a burden, because most of the time
it is not needed (as most users don't create team configurations). With
this change we only require it to parse the team settings (no longer to
write them). It should be reasonably simple to use a more minimalistic
JSON parser that is sufficient for us, so that we can get rid of the
libjansson dependency (for libnm). This also avoids the pain that we have
due to the symbol collision of libjansson and libjson-glib.
https://bugzilla.redhat.com/show_bug.cgi?id=1691619
2019-05-06 12:36:41 +02:00
|
|
|
default_value = None
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
return default_value
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2017-03-20 11:05:04 +01:00
|
|
|
def settings_sort_key(x):
|
2020-06-09 16:28:32 -04:00
|
|
|
x_prefix = x.attrib["{%s}symbol-prefix" % ns_map["c"]]
|
2017-03-20 11:05:04 +01:00
|
|
|
# always sort NMSettingConnection first
|
2020-06-09 16:28:32 -04:00
|
|
|
return (x_prefix != "setting_connection", x_prefix)
|
|
|
|
|
|
2017-03-10 20:19:30 +01:00
|
|
|
|
2020-06-26 10:18:49 +02:00
|
|
|
def xml_quoteattr(val):
|
|
|
|
|
return saxutils.quoteattr(str(val))
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
def usage():
|
2014-08-12 13:04:35 +02:00
|
|
|
print("Usage: %s --gir FILE --output FILE" % sys.argv[0])
|
2014-06-13 11:07:02 -04:00
|
|
|
exit()
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
|
2014-06-13 11:07:02 -04:00
|
|
|
parser = argparse.ArgumentParser()
|
2020-06-09 16:28:32 -04:00
|
|
|
parser.add_argument(
|
|
|
|
|
"-l",
|
|
|
|
|
"--lib-path",
|
|
|
|
|
metavar="PATH",
|
|
|
|
|
action="append",
|
|
|
|
|
help="path to scan for shared libraries",
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument("-g", "--gir", metavar="FILE", help="NM-1.0.gir file")
|
|
|
|
|
parser.add_argument("-o", "--output", metavar="FILE", help="output file")
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
if args.gir is None or args.output is None:
|
|
|
|
|
usage()
|
|
|
|
|
|
2017-12-14 12:40:12 +01:00
|
|
|
if args.lib_path:
|
|
|
|
|
for lib in args.lib_path:
|
|
|
|
|
GIRepository.Repository.prepend_library_path(lib)
|
|
|
|
|
|
2014-06-13 11:07:02 -04:00
|
|
|
girxml = ET.parse(args.gir).getroot()
|
2020-06-09 16:28:32 -04:00
|
|
|
outfile = open(args.output, mode="w")
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
basexml = girxml.find('./gi:namespace/gi:class[@name="Setting"]', ns_map)
|
|
|
|
|
settings = girxml.findall('./gi:namespace/gi:class[@parent="Setting"]', ns_map)
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
# Hack. Need a better way to do this
|
|
|
|
|
ipxml = girxml.find('./gi:namespace/gi:class[@name="SettingIPConfig"]', ns_map)
|
2020-06-09 16:28:32 -04:00
|
|
|
settings.extend(
|
|
|
|
|
girxml.findall('./gi:namespace/gi:class[@parent="SettingIPConfig"]', ns_map)
|
|
|
|
|
)
|
2017-03-20 11:05:04 +01:00
|
|
|
settings = sorted(settings, key=settings_sort_key)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
init_constants(girxml, settings)
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
outfile.write(
|
|
|
|
|
"""<?xml version=\"1.0\"?>
|
2014-06-13 11:07:02 -04:00
|
|
|
<!DOCTYPE nm-setting-docs [
|
|
|
|
|
<!ENTITY quot """>
|
|
|
|
|
]>
|
|
|
|
|
<nm-setting-docs>
|
2020-06-09 16:28:32 -04:00
|
|
|
"""
|
|
|
|
|
)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
for settingxml in settings:
|
2020-06-09 16:28:32 -04:00
|
|
|
if "abstract" in settingxml.attrib:
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
continue
|
|
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
new_func = NM.__getattr__(settingxml.attrib["name"])
|
2014-06-13 11:07:02 -04:00
|
|
|
setting = new_func()
|
|
|
|
|
|
2017-03-10 20:08:11 +01:00
|
|
|
class_desc = get_docs(settingxml)
|
|
|
|
|
if class_desc is None:
|
2020-06-09 16:28:32 -04:00
|
|
|
raise Exception(
|
|
|
|
|
"%s needs a gtk-doc block with one-line description" % setting.props.name
|
|
|
|
|
)
|
|
|
|
|
outfile.write(
|
2020-09-08 17:15:30 +02:00
|
|
|
' <setting name="%s" description=%s name_upper="%s" >\n'
|
|
|
|
|
% (
|
|
|
|
|
setting.props.name,
|
|
|
|
|
xml_quoteattr(class_desc),
|
|
|
|
|
get_setting_name_define(settingxml),
|
|
|
|
|
)
|
2020-06-09 16:28:32 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
setting_properties = {
|
|
|
|
|
prop.name: prop
|
|
|
|
|
for prop in GObject.list_properties(setting)
|
|
|
|
|
if prop.name != "name"
|
|
|
|
|
}
|
2014-11-16 15:36:18 -05:00
|
|
|
|
docs: merge settings docs in a separate step
The script "libnm/generate-setting-docs.py" generates property info based
on GObject introspection data.
Optionally, when creating the manual for D-Bus documentation, it would accept
an argument "--override" to merge the generated information with the information
from an XML generated by "libnm/generate-plugin-docs.xml". Change this.
Instead, let "libnm/generate-setting-docs.py" just do one thing: generate
the XML based on GObject introspection data. Then, a second script
"libnm/generate-docs-nm-settings-docs-merge.py" can merge the XMLs.
Note that currently the manual for "nm-settings-keyfile" only contains
information about properties that are explicitly mentioned for keyfile.
It think that is not right. In NetworkManager there are multiple "aspects"
about connection profiles: D-Bus, libnm, nmcli, keyfile and ifcfg-rh.
When we generate a manual page for any of these aspects, we should always
detail all properties. At least for nmcli and D-Bus. That means, we will
do the merging multiple times. Hence, keep the steps for parsing GObject
introspection data and the merging separate.
Also, "generate-setting-docs.py" and "generate-plugin-docs.pl" should
generate the same XML scheme, so that merge doesn't need special hacks.
That is currently not the case, for example, the override XML contains a
"format" attribute, while the other one contains a "type". Merging these
is a special hack. This should be unified.
2020-05-28 10:19:21 +02:00
|
|
|
for prop in sorted(setting_properties):
|
|
|
|
|
pspec = setting_properties[prop]
|
2014-11-16 15:36:18 -05:00
|
|
|
|
docs: merge settings docs in a separate step
The script "libnm/generate-setting-docs.py" generates property info based
on GObject introspection data.
Optionally, when creating the manual for D-Bus documentation, it would accept
an argument "--override" to merge the generated information with the information
from an XML generated by "libnm/generate-plugin-docs.xml". Change this.
Instead, let "libnm/generate-setting-docs.py" just do one thing: generate
the XML based on GObject introspection data. Then, a second script
"libnm/generate-docs-nm-settings-docs-merge.py" can merge the XMLs.
Note that currently the manual for "nm-settings-keyfile" only contains
information about properties that are explicitly mentioned for keyfile.
It think that is not right. In NetworkManager there are multiple "aspects"
about connection profiles: D-Bus, libnm, nmcli, keyfile and ifcfg-rh.
When we generate a manual page for any of these aspects, we should always
detail all properties. At least for nmcli and D-Bus. That means, we will
do the merging multiple times. Hence, keep the steps for parsing GObject
introspection data and the merging separate.
Also, "generate-setting-docs.py" and "generate-plugin-docs.pl" should
generate the same XML scheme, so that merge doesn't need special hacks.
That is currently not the case, for example, the override XML contains a
"format" attribute, while the other one contains a "type". Merging these
is a special hack. This should be unified.
2020-05-28 10:19:21 +02:00
|
|
|
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)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
docs: merge settings docs in a separate step
The script "libnm/generate-setting-docs.py" generates property info based
on GObject introspection data.
Optionally, when creating the manual for D-Bus documentation, it would accept
an argument "--override" to merge the generated information with the information
from an XML generated by "libnm/generate-plugin-docs.xml". Change this.
Instead, let "libnm/generate-setting-docs.py" just do one thing: generate
the XML based on GObject introspection data. Then, a second script
"libnm/generate-docs-nm-settings-docs-merge.py" can merge the XMLs.
Note that currently the manual for "nm-settings-keyfile" only contains
information about properties that are explicitly mentioned for keyfile.
It think that is not right. In NetworkManager there are multiple "aspects"
about connection profiles: D-Bus, libnm, nmcli, keyfile and ifcfg-rh.
When we generate a manual page for any of these aspects, we should always
detail all properties. At least for nmcli and D-Bus. That means, we will
do the merging multiple times. Hence, keep the steps for parsing GObject
introspection data and the merging separate.
Also, "generate-setting-docs.py" and "generate-plugin-docs.pl" should
generate the same XML scheme, so that merge doesn't need special hacks.
That is currently not the case, for example, the override XML contains a
"format" attribute, while the other one contains a "type". Merging these
is a special hack. This should be unified.
2020-05-28 10:19:21 +02:00
|
|
|
value_type = get_prop_type(setting, pspec)
|
|
|
|
|
value_desc = get_docs(propxml)
|
|
|
|
|
default_value = get_default_value(setting, pspec, propxml)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
prop_upper = prop.upper().replace("-", "_")
|
2017-03-30 16:34:55 +02:00
|
|
|
|
2017-10-16 23:27:30 +02:00
|
|
|
if value_desc is None:
|
2020-06-09 16:28:32 -04:00
|
|
|
raise Exception(
|
|
|
|
|
"%s.%s needs a documentation description" % (setting.props.name, prop)
|
|
|
|
|
)
|
2017-10-16 23:27:30 +02:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
default_value_as_xml = ""
|
2014-06-13 11:07:02 -04:00
|
|
|
if default_value is not None:
|
2020-06-26 10:18:49 +02:00
|
|
|
default_value_as_xml = " default=%s" % (xml_quoteattr(default_value))
|
docs: merge settings docs in a separate step
The script "libnm/generate-setting-docs.py" generates property info based
on GObject introspection data.
Optionally, when creating the manual for D-Bus documentation, it would accept
an argument "--override" to merge the generated information with the information
from an XML generated by "libnm/generate-plugin-docs.xml". Change this.
Instead, let "libnm/generate-setting-docs.py" just do one thing: generate
the XML based on GObject introspection data. Then, a second script
"libnm/generate-docs-nm-settings-docs-merge.py" can merge the XMLs.
Note that currently the manual for "nm-settings-keyfile" only contains
information about properties that are explicitly mentioned for keyfile.
It think that is not right. In NetworkManager there are multiple "aspects"
about connection profiles: D-Bus, libnm, nmcli, keyfile and ifcfg-rh.
When we generate a manual page for any of these aspects, we should always
detail all properties. At least for nmcli and D-Bus. That means, we will
do the merging multiple times. Hence, keep the steps for parsing GObject
introspection data and the merging separate.
Also, "generate-setting-docs.py" and "generate-plugin-docs.pl" should
generate the same XML scheme, so that merge doesn't need special hacks.
That is currently not the case, for example, the override XML contains a
"format" attribute, while the other one contains a "type". Merging these
is a special hack. This should be unified.
2020-05-28 10:19:21 +02:00
|
|
|
|
2020-06-09 16:28:32 -04:00
|
|
|
outfile.write(
|
2020-06-26 10:18:49 +02:00
|
|
|
' <property name="%s" name_upper="%s" type="%s"%s description=%s />\n'
|
|
|
|
|
% (
|
|
|
|
|
prop,
|
|
|
|
|
prop_upper,
|
|
|
|
|
value_type,
|
|
|
|
|
default_value_as_xml,
|
|
|
|
|
xml_quoteattr(value_desc),
|
|
|
|
|
)
|
2020-06-09 16:28:32 -04:00
|
|
|
)
|
2014-06-13 11:07:02 -04:00
|
|
|
|
|
|
|
|
outfile.write(" </setting>\n")
|
|
|
|
|
|
|
|
|
|
outfile.write("</nm-setting-docs>\n")
|
|
|
|
|
outfile.close()
|