cli: embed gtk-doc directly in property-info structure
Also mark them for translation.
This commit is contained in:
18
Makefile.am
18
Makefile.am
@@ -3188,7 +3188,7 @@ endif
|
|||||||
clients_cli_nmcli_LDFLAGS = \
|
clients_cli_nmcli_LDFLAGS = \
|
||||||
-Wl,--version-script="$(srcdir)/linker-script-binary.ver"
|
-Wl,--version-script="$(srcdir)/linker-script-binary.ver"
|
||||||
|
|
||||||
$(clients_cli_nmcli_OBJECTS): $(clients_cli_settings_doc_c)
|
$(clients_cli_nmcli_OBJECTS): $(clients_common_settings_doc_c)
|
||||||
$(clients_cli_nmcli_OBJECTS): clients/cli/.dirstamp
|
$(clients_cli_nmcli_OBJECTS): clients/cli/.dirstamp
|
||||||
|
|
||||||
install-data-hook-nmcli:
|
install-data-hook-nmcli:
|
||||||
@@ -3205,24 +3205,24 @@ uninstall_hook += uninstall-hook-nmcli
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
clients_cli_settings_doc_c = clients/cli/settings-docs.c
|
clients_common_settings_doc_c = clients/common/settings-docs.c
|
||||||
if HAVE_INTROSPECTION
|
if HAVE_INTROSPECTION
|
||||||
$(clients_cli_settings_doc_c): clients/cli/settings-docs.xsl libnm/nm-property-docs.xml
|
$(clients_common_settings_doc_c): clients/common/settings-docs.xsl libnm/nm-property-docs.xml
|
||||||
$(AM_V_GEN) $(XSLTPROC) --output $@ $< $(word 2,$^)
|
$(AM_V_GEN) $(XSLTPROC) --output $@ $< $(word 2,$^)
|
||||||
$(clients_cli_settings_doc_c): clients/cli/.dirstamp
|
$(clients_common_settings_doc_c): clients/common/.dirstamp
|
||||||
DISTCLEANFILES += $(clients_cli_settings_doc_c)
|
DISTCLEANFILES += $(clients_common_settings_doc_c)
|
||||||
else
|
else
|
||||||
$(clients_cli_settings_doc_c):
|
$(clients_common_settings_doc_c):
|
||||||
@echo "to generate $(clients_cli_settings_doc_c), configure with --enable-introspection"
|
@echo "to generate $(clients_common_settings_doc_c), configure with --enable-introspection"
|
||||||
@echo "alternatively, build --without-nmcli"
|
@echo "alternatively, build --without-nmcli"
|
||||||
@false
|
@false
|
||||||
endif
|
endif
|
||||||
EXTRA_DIST += $(clients_cli_settings_doc_c)
|
EXTRA_DIST += $(clients_common_settings_doc_c)
|
||||||
|
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
clients/cli/nmcli-completion \
|
clients/cli/nmcli-completion \
|
||||||
clients/cli/settings-docs.xsl
|
clients/common/settings-docs.xsl
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# clients/tui
|
# clients/tui
|
||||||
|
@@ -1,86 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<xsl:stylesheet version="1.0"
|
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
||||||
|
|
||||||
<xsl:output
|
|
||||||
method="text"
|
|
||||||
doctype-public="-//OASIS//DTD DocBook XML V4.3//EN"
|
|
||||||
doctype-system="http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<xsl:template match="nm-setting-docs">/* Generated file. Do not edit. */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *name;
|
|
||||||
const char *docs;
|
|
||||||
} NmcPropertyDesc;
|
|
||||||
<xsl:apply-templates select="setting" mode="properties"><xsl:sort select="@name"/></xsl:apply-templates>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *name;
|
|
||||||
NmcPropertyDesc *properties;
|
|
||||||
int n_properties;
|
|
||||||
} NmcSettingDesc;
|
|
||||||
|
|
||||||
NmcSettingDesc all_settings[] = {
|
|
||||||
<xsl:apply-templates select="setting" mode="settings"><xsl:sort select="@name"/></xsl:apply-templates>
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
|
||||||
find_by_name (gconstpointer keyv, gconstpointer cmpv)
|
|
||||||
{
|
|
||||||
const char *key = keyv;
|
|
||||||
struct { const char *name; gpointer data; } *cmp = (gpointer)cmpv;
|
|
||||||
|
|
||||||
return strcmp (key, cmp->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
nmc_setting_get_property_doc (NMSetting *setting, const char *prop)
|
|
||||||
{
|
|
||||||
NmcSettingDesc *setting_desc;
|
|
||||||
NmcPropertyDesc *property_desc;
|
|
||||||
|
|
||||||
setting_desc = bsearch (nm_setting_get_name (setting),
|
|
||||||
all_settings, G_N_ELEMENTS (all_settings),
|
|
||||||
sizeof (NmcSettingDesc), find_by_name);
|
|
||||||
if (!setting_desc)
|
|
||||||
return NULL;
|
|
||||||
property_desc = bsearch (prop,
|
|
||||||
setting_desc->properties, setting_desc->n_properties,
|
|
||||||
sizeof (NmcPropertyDesc), find_by_name);
|
|
||||||
if (!property_desc)
|
|
||||||
return NULL;
|
|
||||||
return property_desc->docs;
|
|
||||||
}
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template match="setting" mode="properties">
|
|
||||||
NmcPropertyDesc setting_<xsl:value-of select="translate(@name,'-','_')"/>[] = {<xsl:apply-templates select="property"><xsl:sort select="@name"/></xsl:apply-templates>
|
|
||||||
};
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template match="property">
|
|
||||||
<xsl:variable name="docs">
|
|
||||||
<xsl:call-template name="escape_quotes">
|
|
||||||
<xsl:with-param name="string" select="@description"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
</xsl:variable>
|
|
||||||
{ "<xsl:value-of select="@name"/>", "<xsl:value-of select="$docs"/>" },</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template match="setting" mode="settings">
|
|
||||||
{ "<xsl:value-of select="@name"/>", setting_<xsl:value-of select="translate(@name,'-','_')"/>, <xsl:value-of select="count(./property)"/> },</xsl:template>
|
|
||||||
|
|
||||||
<xsl:template name="escape_quotes">
|
|
||||||
<xsl:param name="string" />
|
|
||||||
<xsl:choose>
|
|
||||||
<xsl:when test="contains($string, '"')">
|
|
||||||
<xsl:value-of select="substring-before($string, '"')" />\"<xsl:call-template name="escape_quotes"><xsl:with-param name="string" select="substring-after($string, '"')" /></xsl:call-template>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="$string" />
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
|
||||||
|
|
||||||
</xsl:stylesheet>
|
|
@@ -763,8 +763,6 @@ nmc_setting_get_property_allowed_values (NMSetting *setting, const char *prop, c
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "settings-docs.c"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a description string for a property.
|
* Create a description string for a property.
|
||||||
*
|
*
|
||||||
@@ -787,13 +785,14 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
|
|||||||
|
|
||||||
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
g_return_val_if_fail (NM_IS_SETTING (setting), FALSE);
|
||||||
|
|
||||||
setting_desc = nmc_setting_get_property_doc (setting, prop);
|
|
||||||
if (setting_desc)
|
|
||||||
setting_desc_title = _("[NM property description]");
|
|
||||||
|
|
||||||
if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) {
|
if ((property_info = _meta_find_property_info_by_setting (setting, prop, &setting_info))) {
|
||||||
const char *desc = NULL;
|
const char *desc = NULL;
|
||||||
|
|
||||||
|
if (property_info->describe_doc) {
|
||||||
|
setting_desc = _(property_info->describe_doc);
|
||||||
|
setting_desc_title = _("[NM property description]");
|
||||||
|
}
|
||||||
|
|
||||||
if (property_info->is_name) {
|
if (property_info->is_name) {
|
||||||
/* Traditionally, the "name" property was not handled here.
|
/* Traditionally, the "name" property was not handled here.
|
||||||
* For the moment, skip it from get_property_val(). */
|
* For the moment, skip it from get_property_val(). */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -113,6 +113,8 @@ struct _NMMetaPropertyInfo {
|
|||||||
|
|
||||||
bool is_secret:1;
|
bool is_secret:1;
|
||||||
|
|
||||||
|
const char *describe_doc;
|
||||||
|
|
||||||
const char *describe_message;
|
const char *describe_message;
|
||||||
|
|
||||||
const NMMetaPropertyType *property_type;
|
const NMMetaPropertyType *property_type;
|
||||||
|
49
clients/common/settings-docs.xsl
Normal file
49
clients/common/settings-docs.xsl
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:output
|
||||||
|
method="text"
|
||||||
|
doctype-public="-//OASIS//DTD DocBook XML V4.3//EN"
|
||||||
|
doctype-system="http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<xsl:template match="nm-setting-docs">/* Generated file. Do not edit. */
|
||||||
|
|
||||||
|
<xsl:apply-templates select="setting" mode="properties"><xsl:sort select="@name"/></xsl:apply-templates>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:template match="setting" mode="properties">
|
||||||
|
<xsl:apply-templates select="property">
|
||||||
|
<xsl:sort select="@name"/>
|
||||||
|
<xsl:with-param name="setting_name_upper" select="@name_upper"/>
|
||||||
|
</xsl:apply-templates>
|
||||||
|
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="property">
|
||||||
|
<xsl:param name="setting_name_upper" />
|
||||||
|
<xsl:variable name="docs">
|
||||||
|
<xsl:call-template name="escape_quotes">
|
||||||
|
<xsl:with-param name="string" select="@description"/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:variable>#define DESCRIBE_DOC_NM_SETTING_<xsl:value-of select="$setting_name_upper"/>_<xsl:value-of select="@name_upper"/> "<xsl:value-of select="$docs"/>"
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="setting" mode="settings">
|
||||||
|
{ "<xsl:value-of select="@name"/>", setting_<xsl:value-of select="translate(@name,'-','_')"/>, <xsl:value-of select="count(./property)"/> },</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="escape_quotes">
|
||||||
|
<xsl:param name="string" />
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains($string, '"')">
|
||||||
|
<xsl:value-of select="substring-before($string, '"')" />\"<xsl:call-template name="escape_quotes"><xsl:with-param name="string" select="substring-after($string, '"')" /></xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$string" />
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
@@ -76,6 +76,12 @@ constants = {
|
|||||||
'NULL': 'NULL' }
|
'NULL': 'NULL' }
|
||||||
setting_names = {}
|
setting_names = {}
|
||||||
|
|
||||||
|
def get_setting_name_define(setting):
|
||||||
|
n = setting.attrib[symbol_prefix_key]
|
||||||
|
if n and n.startswith("setting_"):
|
||||||
|
return n[8:].upper()
|
||||||
|
raise Exception("Unexpected symbol_prefix_key \"%s\"" % (n))
|
||||||
|
|
||||||
def init_constants(girxml, settings):
|
def init_constants(girxml, settings):
|
||||||
for const in girxml.findall('./gi:namespace/gi:constant', ns_map):
|
for const in girxml.findall('./gi:namespace/gi:constant', ns_map):
|
||||||
cname = const.attrib['{%s}type' % ns_map['c']]
|
cname = const.attrib['{%s}type' % ns_map['c']]
|
||||||
@@ -98,7 +104,7 @@ def init_constants(girxml, settings):
|
|||||||
|
|
||||||
for setting in settings:
|
for setting in settings:
|
||||||
setting_type_name = 'NM' + setting.attrib['name'];
|
setting_type_name = 'NM' + setting.attrib['name'];
|
||||||
setting_name_symbol = 'NM_' + setting.attrib[symbol_prefix_key].upper() + '_SETTING_NAME'
|
setting_name_symbol = 'NM_SETTING_' + get_setting_name_define(setting) + '_SETTING_NAME'
|
||||||
if setting_name_symbol in constants:
|
if setting_name_symbol in constants:
|
||||||
setting_name = constants[setting_name_symbol]
|
setting_name = constants[setting_name_symbol]
|
||||||
setting_names[setting_type_name] = setting_name
|
setting_names[setting_type_name] = setting_name
|
||||||
@@ -215,7 +221,7 @@ for settingxml in settings:
|
|||||||
class_desc = get_docs(settingxml)
|
class_desc = get_docs(settingxml)
|
||||||
if class_desc is None:
|
if class_desc is None:
|
||||||
raise Exception("%s needs a gtk-doc block with one-line description" % setting.props.name)
|
raise Exception("%s needs a gtk-doc block with one-line description" % setting.props.name)
|
||||||
outfile.write(" <setting name=\"%s\" description=\"%s\">\n" % (setting.props.name, class_desc))
|
outfile.write(" <setting name=\"%s\" description=\"%s\" name_upper=\"%s\" >\n" % (setting.props.name, class_desc, get_setting_name_define (settingxml)))
|
||||||
|
|
||||||
setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) }
|
setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) }
|
||||||
if args.overrides is None:
|
if args.overrides is None:
|
||||||
@@ -249,12 +255,14 @@ for settingxml in settings:
|
|||||||
if override.attrib['description'] != '':
|
if override.attrib['description'] != '':
|
||||||
value_desc = override.attrib['description']
|
value_desc = override.attrib['description']
|
||||||
|
|
||||||
|
prop_upper = prop.upper().replace('-', '_')
|
||||||
|
|
||||||
if default_value is not None:
|
if default_value is not None:
|
||||||
outfile.write(" <property name=\"%s\" type=\"%s\" default=\"%s\" description=\"%s\" />\n" %
|
outfile.write(" <property name=\"%s\" name_upper=\"%s\" type=\"%s\" default=\"%s\" description=\"%s\" />\n" %
|
||||||
(prop, value_type, escape(default_value), escape(value_desc)))
|
(prop, prop_upper, value_type, escape(default_value), escape(value_desc)))
|
||||||
else:
|
else:
|
||||||
outfile.write(" <property name=\"%s\" type=\"%s\" description=\"%s\" />\n" %
|
outfile.write(" <property name=\"%s\" name_upper=\"%s\" type=\"%s\" description=\"%s\" />\n" %
|
||||||
(prop, value_type, escape(value_desc)))
|
(prop, prop_upper, value_type, escape(value_desc)))
|
||||||
|
|
||||||
outfile.write(" </setting>\n")
|
outfile.write(" </setting>\n")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user