Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

g-ir-doc-tool: Add support for virtual functions

  • Loading branch information...
commit f9eb570c8b3dc34c2844e47c57b67146af48bedc 1 parent 0212b33
@tomeuv tomeuv authored
View
35 giscanner/mallard-C-vfunc.tmpl
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<page id="${page_id}"
+ type="topic"
+ style="vfunc"
+ 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}.${node.parent.name}" group="vfunc"/>
+ </info>
+ <title>${node.name}</title>
+<synopsis><code mime="text/x-csrc">
+</code></synopsis>
+${formatter.format(node.doc)}
+
+% if node.parameters or node.retval:
+<table>
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+<tr>
+<td><p>${arg.argname} :</p></td>
+<td>${formatter.format(arg.doc)}</td>
+</tr>
+% endfor
+% if node.retval:
+<tr>
+<td><p>Returns :</p></td>
+<td>${formatter.format(node.retval.doc)}</td>
+</tr>
+% endif
+</table>
+% endif
+% if node.version:
+<p>Since ${node.version}</p>
+% endif
+</page>
View
3  giscanner/mallard-Python-class.tmpl
@@ -57,6 +57,9 @@ ${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}(
<links type="topic" ui:expanded="yes" groups="signal" style="linklist">
<title>Signals</title>
</links>
+ <links type="topic" ui:expanded="yes" groups="vfunc" style="linklist">
+ <title>Virtual functions</title>
+ </links>
<links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist">
<title>Other</title>
</links>
View
56 giscanner/mallard-Python-vfunc.tmpl
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<page id="${page_id}"
+ type="topic"
+ style="vfunc"
+ 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}.${node.parent.name}" group="vfunc"/>
+ <title type="link" role="topic">${node.name}</title>
+ </info>
+ <title>${namespace.name}.${node.parent.name}.${node.name}</title>
+<synopsis><code mime="text/x-python">
+% if len(node.parameters) != 0:
+@accepts(\
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+${formatter.format_type(arg.type) | x}\
+% if ix != len(node.parameters) - 1:
+, \
+%endif
+% endfor
+)
+% endif
+@returns(${formatter.format_type(node.retval.type) | x})
+def \
+do_${node.name}(self, \
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+${arg.argname}\
+% if ix != len(node.parameters) - 1:
+, \
+%endif
+% endfor
+):
+</code></synopsis>
+${formatter.format(node.doc)}
+
+% if node.parameters or node.retval:
+<table>
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+<tr>
+<td><p>${arg.argname} :</p></td>
+<td>${formatter.format(arg.doc)}</td>
+</tr>
+% endfor
+% if node.retval and node.retval.type.ctype != 'void':
+<tr>
+<td><p>Returns :</p></td>
+<td>${formatter.format(node.retval.doc)}</td>
+</tr>
+% endif
+</table>
+% endif
+% if node.version:
+<p>Since ${node.version}</p>
+% endif
+</page>
View
3  giscanner/mallardwriter.py
@@ -220,6 +220,9 @@ def _render_node(self, node, output):
elif isinstance(node, ast.Signal) and node.parent is not None:
template_name = 'mallard-%s-signal.tmpl' % self._language
page_id = '%s.%s-%s' % (namespace.name, node.parent.name, node.name)
+ elif isinstance(node, ast.VFunction) and node.parent is not None:
+ template_name = 'mallard-%s-vfunc.tmpl' % self._language
+ page_id = '%s.%s-%s' % (namespace.name, node.parent.name, node.name)
else:
template_name = 'mallard-%s-default.tmpl' % self._language
page_id = '%s.%s' % (namespace.name, node.name)
View
27 tests/doctool/DocExamples-1.0-C-expected/DocExamples.Obj-vfunc.page
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj-vfunc"
+ type="topic"
+ style="vfunc"
+ 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="DocExamples.Obj" group="vfunc"/>
+ </info>
+ <title>vfunc</title>
+<synopsis><code mime="text/x-csrc">
+</code></synopsis>
+<p>This is an example of how to document a vfunc.</p>
+
+<table>
+<tr>
+<td><p>first_arg :</p></td>
+<td><p>first argument</p></td>
+</tr>
+<tr>
+<td><p>Returns :</p></td>
+<td></td>
+</tr>
+</table>
+<p>Since 0.99</p>
+</page>
View
27 tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj-vfunc.page
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj-vfunc"
+ type="topic"
+ style="vfunc"
+ 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="DocExamples.Obj" group="vfunc"/>
+ <title type="link" role="topic">vfunc</title>
+ </info>
+ <title>DocExamples.Obj.vfunc</title>
+<synopsis><code mime="text/x-python">
+@accepts(gint)
+@returns(none)
+def do_vfunc(self, first_arg):
+</code></synopsis>
+<p>This is an example of how to document a vfunc.</p>
+
+<table>
+<tr>
+<td><p>first_arg :</p></td>
+<td><p>first argument</p></td>
+</tr>
+</table>
+<p>Since 0.99</p>
+</page>
View
3  tests/doctool/DocExamples-1.0-Python-expected/DocExamples.Obj.page
@@ -44,6 +44,9 @@ obj = DocExamples.Obj(<link xref='DocExamples.Obj-property-example'>property_exa
<links type="topic" ui:expanded="yes" groups="signal" style="linklist">
<title>Signals</title>
</links>
+ <links type="topic" ui:expanded="yes" groups="vfunc" style="linklist">
+ <title>Virtual functions</title>
+ </links>
<links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist">
<title>Other</title>
</links>
View
11 tests/doctool/doc-examples-obj.h
@@ -40,6 +40,17 @@ struct _DocExamplesObj
struct _DocExamplesObjClass
{
GObjectClass parent_class;
+
+ /**
+ * DocExamplesObjClass::vfunc:
+ * @self:
+ * @first_arg: first argument
+ *
+ * This is an example of how to document a vfunc.
+ *
+ * Since: 0.99
+ */
+ void (*vfunc) (DocExamplesObj *self, gint first_arg);
};
GType doc_examples_obj_get_type (void) G_GNUC_CONST;
Please sign in to comment.
Something went wrong with that request. Please try again.