Skip to content
Browse files

g-ir-doc-tool: More Mallard work, using experimantal api extension

  • Loading branch information...
1 parent 773d368 commit f2ab70164e5e72369fb6591670d3214d06f451bd @shaunix shaunix committed with tomeuv Aug 23, 2011
View
2 giscanner/ast.py
@@ -556,6 +556,7 @@ def __init__(self, name, retval, parameters, throws):
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 @@ def __init__(self, name, typeobj, readable, writable,
self.transfer = PARAM_TRANSFER_NONE
else:
self.transfer = transfer
+ self.parent = None # A Class or Interface
class Callback(Callable):
View
30 giscanner/girparser.py
@@ -256,27 +256,27 @@ def _parse_object_interface(self, node):
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 @@ def _parse_function(self, node):
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 @@ def _parse_function_common(self, node, klass):
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 @@ def _parse_compound(self, cls, node):
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 @@ def _parse_boxed(self, node):
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 @@ def _parse_field(self, node):
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 @@ def _parse_property(self, node):
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):
View
11 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">
View
4 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>
View
46 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>
View
5 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>

0 comments on commit f2ab701

Please sign in to comment.
Something went wrong with that request. Please try again.