2011-04-08 22:57:31 +02:00
|
|
|
# -*- Mode: Python -*-
|
|
|
|
|
2011-04-15 14:33:30 +02:00
|
|
|
# GDBus - GLib D-Bus Library
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008-2011 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
2017-01-05 14:44:41 +01:00
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
2011-04-15 14:33:30 +02:00
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General
|
2014-01-23 12:58:29 +01:00
|
|
|
# Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2011-04-15 14:33:30 +02:00
|
|
|
#
|
|
|
|
# Author: David Zeuthen <davidz@redhat.com>
|
|
|
|
|
2011-05-24 06:27:43 +02:00
|
|
|
import re
|
2017-05-29 00:38:19 +02:00
|
|
|
from os import path
|
2011-04-08 22:57:31 +02:00
|
|
|
|
2011-08-23 07:35:01 +02:00
|
|
|
from . import utils
|
2020-11-17 16:32:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Disable line length warnings as wrapping the Docbook templates would be hard
|
|
|
|
# flake8: noqa: E501
|
|
|
|
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
|
|
|
|
2020-11-17 16:07:09 +01:00
|
|
|
|
2011-04-08 22:57:31 +02:00
|
|
|
class DocbookCodeGenerator:
|
2018-01-12 11:47:40 +01:00
|
|
|
def __init__(self, ifaces):
|
2011-04-08 22:57:31 +02:00
|
|
|
self.ifaces = ifaces
|
2011-04-18 20:23:19 +02:00
|
|
|
self.generate_expand_dicts()
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_method_prototype(self, i, m, in_synopsis):
|
|
|
|
max_method_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _m in i.methods:
|
|
|
|
max_method_len = max(len(_m.name), max_method_len)
|
|
|
|
else:
|
|
|
|
max_method_len = max(len(m.name), max_method_len)
|
|
|
|
|
|
|
|
max_signature_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _m in i.methods:
|
|
|
|
for a in _m.in_args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
for a in _m.out_args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
else:
|
|
|
|
for a in m.in_args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
for a in m.out_args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
|
|
|
|
if in_synopsis:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<link linkend="gdbus-method-%s.%s">%s</link>%*s ('
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
m.name,
|
|
|
|
m.name,
|
|
|
|
max_method_len - len(m.name),
|
|
|
|
"",
|
|
|
|
)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
else:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("%s%*s (" % (m.name, max_method_len - len(m.name), ""))
|
2011-04-08 22:57:31 +02:00
|
|
|
count = 0
|
|
|
|
for a in m.in_args:
|
2020-11-17 16:07:09 +01:00
|
|
|
if count > 0:
|
|
|
|
self.out.write(",\n%*s" % (max_method_len + 2, ""))
|
|
|
|
self.out.write(
|
|
|
|
"IN %s%*s %s"
|
|
|
|
% (a.signature, max_signature_len - len(a.signature), "", a.name)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
count = count + 1
|
|
|
|
for a in m.out_args:
|
2020-11-17 16:07:09 +01:00
|
|
|
if count > 0:
|
|
|
|
self.out.write(",\n%*s" % (max_method_len + 2, ""))
|
|
|
|
self.out.write(
|
|
|
|
"OUT %s%*s %s"
|
|
|
|
% (a.signature, max_signature_len - len(a.signature), "", a.name)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
count = count + 1
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(");\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_signal_prototype(self, i, s, in_synopsis):
|
|
|
|
max_signal_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _s in i.signals:
|
|
|
|
max_signal_len = max(len(_s.name), max_signal_len)
|
|
|
|
else:
|
|
|
|
max_signal_len = max(len(s.name), max_signal_len)
|
|
|
|
|
|
|
|
max_signature_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _s in i.signals:
|
|
|
|
for a in _s.args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
else:
|
|
|
|
for a in s.args:
|
|
|
|
max_signature_len = max(len(a.signature), max_signature_len)
|
|
|
|
|
|
|
|
if in_synopsis:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<link linkend="gdbus-signal-%s.%s">%s</link>%*s ('
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
s.name,
|
|
|
|
s.name,
|
|
|
|
max_signal_len - len(s.name),
|
|
|
|
"",
|
|
|
|
)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
else:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("%s%*s (" % (s.name, max_signal_len - len(s.name), ""))
|
2011-04-08 22:57:31 +02:00
|
|
|
count = 0
|
|
|
|
for a in s.args:
|
2020-11-17 16:07:09 +01:00
|
|
|
if count > 0:
|
|
|
|
self.out.write(",\n%*s" % (max_signal_len + 2, ""))
|
|
|
|
self.out.write(
|
|
|
|
"%s%*s %s"
|
|
|
|
% (a.signature, max_signature_len - len(a.signature), "", a.name)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
count = count + 1
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(");\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_property_prototype(self, i, p, in_synopsis):
|
|
|
|
max_property_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _p in i.properties:
|
|
|
|
max_property_len = max(len(_p.name), max_property_len)
|
|
|
|
else:
|
|
|
|
max_property_len = max(len(p.name), max_property_len)
|
|
|
|
|
|
|
|
max_signature_len = 0
|
|
|
|
if in_synopsis:
|
|
|
|
for _p in i.properties:
|
|
|
|
max_signature_len = max(len(_p.signature), max_signature_len)
|
|
|
|
else:
|
|
|
|
max_signature_len = max(len(p.signature), max_signature_len)
|
|
|
|
|
|
|
|
if in_synopsis:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<link linkend="gdbus-property-%s.%s">%s</link>%*s'
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
p.name,
|
|
|
|
p.name,
|
|
|
|
max_property_len - len(p.name),
|
|
|
|
"",
|
|
|
|
)
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
else:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("%s%*s" % (p.name, max_property_len - len(p.name), ""))
|
2011-04-08 22:57:31 +02:00
|
|
|
if p.readable and p.writable:
|
2020-11-17 16:07:09 +01:00
|
|
|
access = "readwrite"
|
2011-04-08 22:57:31 +02:00
|
|
|
elif p.readable:
|
2020-11-17 16:07:09 +01:00
|
|
|
access = "readable "
|
2011-04-08 22:57:31 +02:00
|
|
|
else:
|
2020-11-17 16:07:09 +01:00
|
|
|
access = "writable "
|
|
|
|
self.out.write(" %s %s\n" % (access, p.signature))
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_synopsis_methods(self, i):
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <refsynopsisdiv role="synopsis">\n')
|
|
|
|
self.out.write(' <title role="synopsis.title">Methods</title>\n')
|
|
|
|
self.out.write(" <synopsis>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
for m in i.methods:
|
|
|
|
self.print_method_prototype(i, m, in_synopsis=True)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</synopsis>\n")
|
|
|
|
self.out.write(" </refsynopsisdiv>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_synopsis_signals(self, i):
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <refsect1 role="signal_proto">\n')
|
|
|
|
self.out.write(' <title role="signal_proto.title">Signals</title>\n')
|
|
|
|
self.out.write(" <synopsis>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
for s in i.signals:
|
|
|
|
self.print_signal_prototype(i, s, in_synopsis=True)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</synopsis>\n")
|
|
|
|
self.out.write(" </refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_synopsis_properties(self, i):
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <refsect1 role="properties">\n')
|
|
|
|
self.out.write(' <title role="properties.title">Properties</title>\n')
|
|
|
|
self.out.write(" <synopsis>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
for p in i.properties:
|
|
|
|
self.print_property_prototype(i, p, in_synopsis=True)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</synopsis>\n")
|
|
|
|
self.out.write(" </refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_method(self, i, m):
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect2 role="method" id="gdbus-method-%s.%s">\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name), m.name)
|
|
|
|
)
|
|
|
|
self.out.write(" <title>The %s() method</title>\n" % (m.name))
|
|
|
|
self.out.write(
|
|
|
|
' <indexterm zone="gdbus-method-%s.%s"><primary sortas="%s.%s">%s.%s()</primary></indexterm>\n'
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
m.name,
|
|
|
|
i.name_without_prefix,
|
|
|
|
m.name,
|
|
|
|
i.name,
|
|
|
|
m.name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.out.write("<programlisting>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
self.print_method_prototype(i, m, in_synopsis=False)
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</programlisting>\n")
|
|
|
|
self.out.write("%s\n" % (self.expand_paras(m.doc_string, True)))
|
2013-01-30 11:07:52 +01:00
|
|
|
if m.in_args or m.out_args:
|
|
|
|
self.out.write('<variablelist role="params">\n')
|
|
|
|
for a in m.in_args:
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("<varlistentry>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
" <term><literal>IN %s <parameter>%s</parameter></literal>:</term>\n"
|
|
|
|
% (a.signature, a.name)
|
|
|
|
)
|
|
|
|
self.out.write(
|
|
|
|
" <listitem>%s</listitem>\n"
|
|
|
|
% (self.expand_paras(a.doc_string, True))
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</varlistentry>\n")
|
2013-01-30 11:07:52 +01:00
|
|
|
for a in m.out_args:
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("<varlistentry>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
" <term><literal>OUT %s <parameter>%s</parameter></literal>:</term>\n"
|
|
|
|
% (a.signature, a.name)
|
|
|
|
)
|
|
|
|
self.out.write(
|
|
|
|
" <listitem>%s</listitem>\n"
|
|
|
|
% (self.expand_paras(a.doc_string, True))
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</varlistentry>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</variablelist>\n")
|
2011-04-12 22:17:28 +02:00
|
|
|
if len(m.since) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write('<para role="since">Since %s</para>\n' % (m.since))
|
2011-04-15 18:56:07 +02:00
|
|
|
if m.deprecated:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
"<warning><para>The %s() method is deprecated.</para></warning>"
|
|
|
|
% (m.name)
|
|
|
|
)
|
|
|
|
self.out.write("</refsect2>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_signal(self, i, s):
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect2 role="signal" id="gdbus-signal-%s.%s">\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name), s.name)
|
|
|
|
)
|
|
|
|
self.out.write(' <title>The "%s" signal</title>\n' % (s.name))
|
|
|
|
self.out.write(
|
|
|
|
' <indexterm zone="gdbus-signal-%s.%s"><primary sortas="%s::%s">%s::%s</primary></indexterm>\n'
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
s.name,
|
|
|
|
i.name_without_prefix,
|
|
|
|
s.name,
|
|
|
|
i.name,
|
|
|
|
s.name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.out.write("<programlisting>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
self.print_signal_prototype(i, s, in_synopsis=False)
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</programlisting>\n")
|
|
|
|
self.out.write("%s\n" % (self.expand_paras(s.doc_string, True)))
|
2013-01-30 11:07:52 +01:00
|
|
|
if s.args:
|
|
|
|
self.out.write('<variablelist role="params">\n')
|
|
|
|
for a in s.args:
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("<varlistentry>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
" <term><literal>%s <parameter>%s</parameter></literal>:</term>\n"
|
|
|
|
% (a.signature, a.name)
|
|
|
|
)
|
|
|
|
self.out.write(
|
|
|
|
" <listitem>%s</listitem>\n"
|
|
|
|
% (self.expand_paras(a.doc_string, True))
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</varlistentry>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</variablelist>\n")
|
2011-04-12 22:17:28 +02:00
|
|
|
if len(s.since) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write('<para role="since">Since %s</para>\n' % (s.since))
|
2011-04-15 18:56:07 +02:00
|
|
|
if s.deprecated:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<warning><para>The "%s" signal is deprecated.</para></warning>'
|
|
|
|
% (s.name)
|
|
|
|
)
|
|
|
|
self.out.write("</refsect2>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
def print_property(self, i, p):
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect2 role="property" id="gdbus-property-%s.%s">\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name), p.name)
|
|
|
|
)
|
|
|
|
self.out.write(' <title>The "%s" property</title>\n' % (p.name))
|
|
|
|
self.out.write(
|
|
|
|
' <indexterm zone="gdbus-property-%s.%s"><primary sortas="%s:%s">%s:%s</primary></indexterm>\n'
|
|
|
|
% (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
p.name,
|
|
|
|
i.name_without_prefix,
|
|
|
|
p.name,
|
|
|
|
i.name,
|
|
|
|
p.name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.out.write("<programlisting>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
self.print_property_prototype(i, p, in_synopsis=False)
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</programlisting>\n")
|
|
|
|
self.out.write("%s\n" % (self.expand_paras(p.doc_string, True)))
|
2011-04-12 22:17:28 +02:00
|
|
|
if len(p.since) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write('<para role="since">Since %s</para>\n' % (p.since))
|
2011-04-15 18:56:07 +02:00
|
|
|
if p.deprecated:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<warning><para>The "%s" property is deprecated.</para></warning>'
|
|
|
|
% (p.name)
|
|
|
|
)
|
|
|
|
self.out.write("</refsect2>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
2011-05-24 06:27:43 +02:00
|
|
|
def expand(self, s, expandParamsAndConstants):
|
2011-04-08 22:57:31 +02:00
|
|
|
for key in self.expand_member_dict_keys:
|
|
|
|
s = s.replace(key, self.expand_member_dict[key])
|
|
|
|
for key in self.expand_iface_dict_keys:
|
|
|
|
s = s.replace(key, self.expand_iface_dict[key])
|
2011-05-24 06:27:43 +02:00
|
|
|
if expandParamsAndConstants:
|
|
|
|
# replace @foo with <parameter>foo</parameter>
|
2020-11-17 16:07:09 +01:00
|
|
|
s = re.sub(
|
|
|
|
"@[a-zA-Z0-9_]*",
|
|
|
|
lambda m: "<parameter>" + m.group(0)[1:] + "</parameter>",
|
|
|
|
s,
|
|
|
|
)
|
2011-05-24 06:27:43 +02:00
|
|
|
# replace e.g. %TRUE with <constant>TRUE</constant>
|
2020-11-17 16:07:09 +01:00
|
|
|
s = re.sub(
|
|
|
|
"%[a-zA-Z0-9_]*",
|
|
|
|
lambda m: "<constant>" + m.group(0)[1:] + "</constant>",
|
|
|
|
s,
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
return s
|
|
|
|
|
2013-01-30 11:13:38 +01:00
|
|
|
def expand_paras(self, s, expandParamsAndConstants):
|
|
|
|
s = self.expand(s, expandParamsAndConstants).strip()
|
|
|
|
if not s.startswith("<para"):
|
|
|
|
s = "<para>%s</para>" % s
|
|
|
|
return s
|
|
|
|
|
2011-04-08 22:57:31 +02:00
|
|
|
def generate_expand_dicts(self):
|
|
|
|
self.expand_member_dict = {}
|
|
|
|
self.expand_iface_dict = {}
|
|
|
|
for i in self.ifaces:
|
2020-11-17 16:07:09 +01:00
|
|
|
key = "#%s" % (i.name)
|
|
|
|
value = '<link linkend="gdbus-interface-%s.top_of_page">%s</link>' % (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
i.name,
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
self.expand_iface_dict[key] = value
|
|
|
|
for m in i.methods:
|
2020-11-17 16:07:09 +01:00
|
|
|
key = "%s.%s()" % (i.name, m.name)
|
|
|
|
value = '<link linkend="gdbus-method-%s.%s">%s()</link>' % (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
m.name,
|
|
|
|
m.name,
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
self.expand_member_dict[key] = value
|
|
|
|
for s in i.signals:
|
2020-11-17 16:07:09 +01:00
|
|
|
key = "#%s::%s" % (i.name, s.name)
|
|
|
|
value = '<link linkend="gdbus-signal-%s.%s">"%s"</link>' % (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
s.name,
|
|
|
|
s.name,
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
self.expand_member_dict[key] = value
|
|
|
|
for p in i.properties:
|
2020-11-17 16:07:09 +01:00
|
|
|
key = "#%s:%s" % (i.name, p.name)
|
|
|
|
value = '<link linkend="gdbus-property-%s.%s">"%s"</link>' % (
|
|
|
|
utils.dots_to_hyphens(i.name),
|
|
|
|
p.name,
|
|
|
|
p.name,
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
self.expand_member_dict[key] = value
|
|
|
|
# Make sure to expand the keys in reverse order so e.g. #org.foo.Iface:MediaCompat
|
|
|
|
# is evaluated before #org.foo.Iface:Media ...
|
2020-11-17 16:07:09 +01:00
|
|
|
self.expand_member_dict_keys = sorted(
|
|
|
|
self.expand_member_dict.keys(), reverse=True
|
|
|
|
)
|
|
|
|
self.expand_iface_dict_keys = sorted(
|
|
|
|
self.expand_iface_dict.keys(), reverse=True
|
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
|
2018-01-12 11:47:40 +01:00
|
|
|
def generate(self, docbook, outdir):
|
2011-04-08 22:57:31 +02:00
|
|
|
for i in self.ifaces:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out = open(path.join(outdir, "%s-%s.xml" % (docbook, i.name)), "w")
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("")
|
|
|
|
self.out.write('<?xml version="1.0" encoding="utf-8"?>\n')
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"\n'
|
|
|
|
)
|
|
|
|
self.out.write(
|
|
|
|
' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [\n'
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("]>\n")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write('<refentry id="gdbus-%s">\n' % (i.name))
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(" <refmeta>")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
' <refentrytitle role="top_of_page" id="gdbus-interface-%s.top_of_page">%s</refentrytitle>\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name), i.name)
|
|
|
|
)
|
|
|
|
self.out.write(
|
|
|
|
' <indexterm zone="gdbus-interface-%s.top_of_page"><primary sortas="%s">%s</primary></indexterm>\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name), i.name_without_prefix, i.name)
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(" </refmeta>")
|
2020-11-17 16:07:09 +01:00
|
|
|
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(" <refnamediv>")
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(" <refname>%s</refname>" % (i.name))
|
|
|
|
self.out.write(" <refpurpose>%s</refpurpose>" % (i.doc_string_brief))
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(" </refnamediv>")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
if len(i.methods) > 0:
|
|
|
|
self.print_synopsis_methods(i)
|
|
|
|
if len(i.signals) > 0:
|
|
|
|
self.print_synopsis_signals(i)
|
|
|
|
if len(i.properties) > 0:
|
|
|
|
self.print_synopsis_properties(i)
|
|
|
|
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect1 role="desc" id="gdbus-interface-%s">\n'
|
|
|
|
% (utils.dots_to_hyphens(i.name))
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <title role="desc.title">Description</title>\n')
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(" %s\n" % (self.expand_paras(i.doc_string, True)))
|
2011-04-12 22:17:28 +02:00
|
|
|
if len(i.since) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(' <para role="since">Since %s</para>\n' % (i.since))
|
2011-04-15 18:56:07 +02:00
|
|
|
if i.deprecated:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
"<warning><para>The %s interface is deprecated.</para></warning>"
|
|
|
|
% (i.name)
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
if len(i.methods) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect1 role="details" id="gdbus-methods-%s">\n' % (i.name)
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <title role="details.title">Method Details</title>\n')
|
2011-04-08 22:57:31 +02:00
|
|
|
for m in i.methods:
|
|
|
|
self.print_method(i, m)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
if len(i.signals) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect1 role="details" id="gdbus-signals-%s">\n' % (i.name)
|
|
|
|
)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write(' <title role="details.title">Signal Details</title>\n')
|
2011-04-08 22:57:31 +02:00
|
|
|
for s in i.signals:
|
|
|
|
self.print_signal(i, s)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
|
|
|
if len(i.properties) > 0:
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write(
|
|
|
|
'<refsect1 role="details" id="gdbus-properties-%s">\n' % (i.name)
|
|
|
|
)
|
|
|
|
self.out.write(
|
2020-11-17 16:32:10 +01:00
|
|
|
' <title role="details.title">Property Details</title>\n'
|
2020-11-17 16:07:09 +01:00
|
|
|
)
|
2011-04-08 22:57:31 +02:00
|
|
|
for s in i.properties:
|
|
|
|
self.print_property(i, s)
|
2020-11-17 16:32:10 +01:00
|
|
|
self.out.write("</refsect1>\n")
|
2011-04-08 22:57:31 +02:00
|
|
|
|
2020-11-17 16:07:09 +01:00
|
|
|
self.out.write("</refentry>\n")
|
|
|
|
self.out.write("\n")
|