summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2011-08-23 09:12:02 -0400
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2012-02-17 10:27:40 +0100
commitf2ab70164e5e72369fb6591670d3214d06f451bd (patch)
tree07079cfadfbf79147653c7e42c5dc004881d73df
parent773d36876cfd5a23e32c506e78bdfc7383b05713 (diff)
downloadgobject-introspection-f2ab70164e5e72369fb6591670d3214d06f451bd.tar.gz
g-ir-doc-tool: More Mallard work, using experimantal api extension
-rw-r--r--giscanner/ast.py2
-rw-r--r--giscanner/girparser.py30
-rw-r--r--giscanner/mallard-C-class.tmpl11
-rw-r--r--giscanner/mallard-C-function.tmpl4
-rw-r--r--giscanner/mallard-C-method.tmpl46
-rw-r--r--giscanner/mallard-Python-method.tmpl5
6 files changed, 76 insertions, 22 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 91faff88..6df356dd 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -556,6 +556,7 @@ class Callable(Node):
self.parameters = parameters
self.throws = not not throws
self.instance_parameter = None # Parameter
+ self.parent = None # A Class or Interface
def get_parameter_index(self, name):
for i, parameter in enumerate(self.parameters):
@@ -1007,6 +1008,7 @@ class Property(Node):
self.transfer = PARAM_TRANSFER_NONE
else:
self.transfer = transfer
+ self.parent = None # A Class or Interface
class Callback(Callable):
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 5faaf197..a59037da 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -256,27 +256,27 @@ class GIRParser(object):
for iface in self._find_children(node, _corens('prerequisite')):
obj.prerequisites.append(self._namespace.type_from_name(iface.attrib['name']))
for func_node in self._find_children(node, _corens('function')):
- func = self._parse_function_common(func_node, ast.Function)
+ func = self._parse_function_common(func_node, ast.Function, obj)
obj.static_methods.append(func)
for method in self._find_children(node, _corens('method')):
- func = self._parse_function_common(method, ast.Function)
+ func = self._parse_function_common(method, ast.Function, obj)
func.is_method = True
obj.methods.append(func)
for method in self._find_children(node, _corens('virtual-method')):
- func = self._parse_function_common(method, ast.VFunction)
+ func = self._parse_function_common(method, ast.VFunction, obj)
self._parse_generic_attribs(method, func)
func.is_method = True
func.invoker = method.get('invoker')
obj.virtual_methods.append(func)
for ctor in self._find_children(node, _corens('constructor')):
- func = self._parse_function_common(ctor, ast.Function)
+ func = self._parse_function_common(ctor, ast.Function, obj)
func.is_constructor = True
obj.constructors.append(func)
obj.fields.extend(self._parse_fields(node))
for prop in self._find_children(node, _corens('property')):
- obj.properties.append(self._parse_property(prop))
+ obj.properties.append(self._parse_property(prop, obj))
for signal in self._find_children(node, _glibns('signal')):
- obj.signals.append(self._parse_function_common(signal, ast.Signal))
+ obj.signals.append(self._parse_function_common(signal, ast.Signal, obj))
def _parse_callback(self, node):
callback = self._parse_function_common(node, ast.Callback)
@@ -286,7 +286,7 @@ class GIRParser(object):
function = self._parse_function_common(node, ast.Function)
self._namespace.append(function)
- def _parse_function_common(self, node, klass):
+ def _parse_function_common(self, node, klass, parent=None):
name = node.attrib['name']
returnnode = node.find(_corens('return-value'))
if not returnnode:
@@ -319,6 +319,7 @@ class GIRParser(object):
func.shadows = node.attrib.get('shadows', None)
func.shadowed_by = node.attrib.get('shadowed-by', None)
func.moved_to = node.attrib.get('moved-to', None)
+ func.parent = parent
parameters_node = node.find(_corens('parameters'))
if (parameters_node is not None):
@@ -377,13 +378,13 @@ class GIRParser(object):
compound.fields.extend(self._parse_fields(node))
for method in self._find_children(node, _corens('method')):
compound.methods.append(
- self._parse_function_common(method, ast.Function))
+ self._parse_function_common(method, ast.Function, compound))
for func in self._find_children(node, _corens('function')):
compound.static_methods.append(
- self._parse_function_common(func, ast.Function))
+ self._parse_function_common(func, ast.Function, compound))
for ctor in self._find_children(node, _corens('constructor')):
compound.constructors.append(
- self._parse_function_common(ctor, ast.Function))
+ self._parse_function_common(ctor, ast.Function, compound))
return compound
def _parse_record(self, node, anonymous=False):
@@ -482,15 +483,15 @@ class GIRParser(object):
if self._types_only:
return
for method in self._find_children(node, _corens('method')):
- func = self._parse_function_common(method, ast.Function)
+ func = self._parse_function_common(method, ast.Function, obj)
func.is_method = True
obj.methods.append(func)
for ctor in self._find_children(node, _corens('constructor')):
obj.constructors.append(
- self._parse_function_common(ctor, ast.Function))
+ self._parse_function_common(ctor, ast.Function, obj))
for callback in self._find_children(node, _corens('callback')):
obj.fields.append(
- self._parse_function_common(callback, ast.Callback))
+ self._parse_function_common(callback, ast.Callback, obj))
def _parse_field(self, node):
type_node = None
@@ -521,7 +522,7 @@ class GIRParser(object):
self._parse_generic_attribs(node, field)
return field
- def _parse_property(self, node):
+ def _parse_property(self, node, parent):
prop = ast.Property(node.attrib['name'],
self._parse_type(node),
node.attrib.get('readable') != '0',
@@ -530,6 +531,7 @@ class GIRParser(object):
node.attrib.get('construct-only') == '1',
node.attrib.get('transfer-ownership'))
self._parse_generic_attribs(node, prop)
+ prop.parent = parent
return prop
def _parse_member(self, node):
diff --git a/giscanner/mallard-C-class.tmpl b/giscanner/mallard-C-class.tmpl
index 5dc59220..935146a5 100644
--- a/giscanner/mallard-C-class.tmpl
+++ b/giscanner/mallard-C-class.tmpl
@@ -3,11 +3,12 @@
type="guide"
style="class"
xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
xmlns:ui="http://projectmallard.org/experimental/ui/">
<info>
<link type="guide" xref="index" group="class"/>
</info>
- <title>${node.namespace.name}${node.name}</title>
+ <title>${node.ctype}</title>
${format(node.doc)}
<synopsis ui:expanded="no">
<title>Hierarchy</title>
@@ -17,10 +18,14 @@ ${format(node.doc)}
</item>
</tree>
</synopsis>
- <links type="topic" ui:expanded="yes" groups="constructor" style="linklist">
+ <links type="topic" ui:expanded="yes"
+ api:type="function" api:mime="text/x-csrc"
+ groups="constructor" style="linklist">
<title>Constructors</title>
</links>
- <links type="topic" ui:expanded="yes" groups="method" style="linklist">
+ <links type="topic" ui:expanded="yes"
+ api:type="function" api:mime="text/x-csrc"
+ groups="method" style="linklist">
<title>Methods</title>
</links>
<links type="topic" ui:expanded="yes" groups="property" style="linklist">
diff --git a/giscanner/mallard-C-function.tmpl b/giscanner/mallard-C-function.tmpl
index fabbe31a..8fcd30a4 100644
--- a/giscanner/mallard-C-function.tmpl
+++ b/giscanner/mallard-C-function.tmpl
@@ -3,9 +3,13 @@
type="topic"
style="function"
xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
xmlns:ui="http://projectmallard.org/experimental/ui/">
<info>
<link type="guide" xref="index" group="function"/>
+ <api:function>
+ <api:name>${node.symbol}</api:name>
+ </api:function>
</info>
<title>${node.symbol}</title>
${format(node.doc)}</page>
diff --git a/giscanner/mallard-C-method.tmpl b/giscanner/mallard-C-method.tmpl
index bf998ab0..47f1051f 100644
--- a/giscanner/mallard-C-method.tmpl
+++ b/giscanner/mallard-C-method.tmpl
@@ -1,11 +1,53 @@
<?xml version="1.0"?>
-<page id="${namespace.name}.${parent.name}.${node.name}"
+<page id="${namespace.name}.${node.parent.name}.${node.name}"
type="topic"
style="method"
xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
xmlns:ui="http://projectmallard.org/experimental/ui/">
<info>
- <link type="guide" xref="${namespace.name}.${parent.name}" group="method"/>
+ <link type="guide" xref="${namespace.name}.${node.parent.name}" group="method"/>
+ <api:function>
+ <api:returns>
+ <api:type>${node.retval.type.ctype}</api:type>
+ </api:returns>
+ <api:name>${node.symbol}</api:name>
+ <api:arg>
+ <api:type>${node.parent.ctype} *</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+% for arg in node.parameters:
+% if arg.type.ctype == '<varargs>':
+ <api:varargs/>
+% else:
+ <api:arg>
+ <api:type>${arg.type.ctype}</api:type>
+ <api:name>${arg.argname}</api:name>
+ </api:arg>
+% endif
+% endfor
+ </api:function>
</info>
<title>${node.symbol}</title>
+<synopsis><code>
+${node.retval.type.ctype} ${node.symbol} (${node.parent.ctype} *self\
+% if len(node.parameters) == 0:
+);
+% else:
+,
+% endif
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+${' ' * (len(node.retval.type.ctype) + len(node.symbol) + 3)}\
+% if arg.type.ctype == '<varargs>':
+...\
+% else:
+${arg.type.ctype} ${arg.argname}\
+% endif
+% if ix == len(node.parameters) - 1:
+);
+% else:
+,
+%endif
+% endfor
+</code></synopsis>
${format(node.doc)}</page>
diff --git a/giscanner/mallard-Python-method.tmpl b/giscanner/mallard-Python-method.tmpl
index 53e58f3c..45417251 100644
--- a/giscanner/mallard-Python-method.tmpl
+++ b/giscanner/mallard-Python-method.tmpl
@@ -1,13 +1,12 @@
<?xml version="1.0"?>
-<page id="${namespace.name}.${parent.name}.${node.name}"
+<page id="${namespace.name}.${node.parent.name}.${node.name}"
type="topic"
style="method"
xmlns="http://projectmallard.org/1.0/"
xmlns:ui="http://projectmallard.org/experimental/ui/"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<info>
- <link type="guide" xref="${namespace.name}.${parent.name}" group="method"/>
- <c:identifier>${node.symbol}</c:identifier>
+ <link type="guide" xref="${namespace.name}.${node.parent.name}" group="method"/>
</info>
<title>${node.symbol}</title>
${format(node.doc)}</page>