[gobject-introspection] doctool: Initial import of a Gjs language that we support
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] doctool: Initial import of a Gjs language that we support
- Date: Sat, 2 Feb 2013 02:22:38 +0000 (UTC)
commit 7169562133632e11fb4f564211a1db1aa61bab5c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jan 31 23:40:20 2013 -0500
doctool: Initial import of a Gjs language that we support
Copy/pasted from Python.
Makefile-giscanner.am | 13 +++-
giscanner/doctemplates/Gjs/class.tmpl | 17 +++++
giscanner/doctemplates/Gjs/constructor.tmpl | 1 +
giscanner/doctemplates/Gjs/default.tmpl | 1 +
giscanner/doctemplates/Gjs/enum.tmpl | 11 +++
giscanner/doctemplates/Gjs/function.tmpl | 54 ++++++++++++++
giscanner/doctemplates/Gjs/method.tmpl | 1 +
giscanner/doctemplates/Gjs/namespace.tmpl | 2 +
giscanner/doctemplates/Gjs/property.tmpl | 10 +++
giscanner/doctemplates/Gjs/record.tmpl | 2 +
giscanner/doctemplates/Gjs/signal.tmpl | 35 +++++++++
giscanner/doctemplates/Gjs/vfunc.tmpl | 23 ++++++
giscanner/mallardwriter.py | 71 ++++++++++++++++++
.../DocExamples.Callback.page | 25 +++++++
.../DocExamples.Enum.page | 31 ++++++++
.../DocExamples.Obj-property-example.page | 30 ++++++++
.../DocExamples.Obj-signal-example.page | 44 +++++++++++
.../DocExamples.Obj-vfunc.page | 35 +++++++++
.../DocExamples.Obj.method.page | 77 ++++++++++++++++++++
.../DocExamples.Obj.new.page | 40 ++++++++++
.../DocExamples.Obj.page | 63 ++++++++++++++++
.../DocExamples.Obj.static_method.page | 48 ++++++++++++
.../DocExamples.array_function.page | 48 ++++++++++++
.../DocExamples.callback_function.page | 61 ++++++++++++++++
.../DocExamples-1.0-Gjs-expected/index.page | 33 +++++++++
tests/doctool/Makefile.am | 13 +++-
26 files changed, 786 insertions(+), 3 deletions(-)
---
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am
index d5402f6..728ff10 100644
--- a/Makefile-giscanner.am
+++ b/Makefile-giscanner.am
@@ -78,7 +78,18 @@ nobase_template_DATA = \
giscanner/doctemplates/Python/property.tmpl \
giscanner/doctemplates/Python/record.tmpl \
giscanner/doctemplates/Python/signal.tmpl \
- giscanner/doctemplates/Python/vfunc.tmpl
+ giscanner/doctemplates/Python/vfunc.tmpl \
+ giscanner/doctemplates/Gjs/class.tmpl \
+ giscanner/doctemplates/Gjs/constructor.tmpl \
+ giscanner/doctemplates/Gjs/default.tmpl \
+ giscanner/doctemplates/Gjs/enum.tmpl \
+ giscanner/doctemplates/Gjs/function.tmpl \
+ giscanner/doctemplates/Gjs/method.tmpl \
+ giscanner/doctemplates/Gjs/namespace.tmpl \
+ giscanner/doctemplates/Gjs/property.tmpl \
+ giscanner/doctemplates/Gjs/record.tmpl \
+ giscanner/doctemplates/Gjs/signal.tmpl \
+ giscanner/doctemplates/Gjs/vfunc.tmpl
_giscanner_la_CFLAGS = \
$(PYTHON_INCLUDES) \
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/Gjs/class.tmpl
new file mode 100644
index 0000000..3991ff3
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/class.tmpl
@@ -0,0 +1,17 @@
+<%inherit file="/class.tmpl"/>
+<%block name="synopsis">
+ <synopsis><code>
+from gi.repository import ${namespace.name}
+
+${formatter.to_underscores(node.name).lower()} = ${namespace.name}.${node.name}(\
+% for property_, ix in zip(node.properties, range(len(node.properties))):
+% if property_.construct or property_.construct_only or property_.writable:
+<link xref='${namespace.name}.${node.name}-${property_.name}'>${property_.name.replace('-', '_')}</link>=value\
+% if ix != len(node.properties) - 1:
+, \
+% endif
+% endif
+% endfor
+)\
+ </code></synopsis>
+</%block>
diff --git a/giscanner/doctemplates/Gjs/constructor.tmpl b/giscanner/doctemplates/Gjs/constructor.tmpl
new file mode 100644
index 0000000..a03d282
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/constructor.tmpl
@@ -0,0 +1 @@
+<%inherit file="./function.tmpl"/>
diff --git a/giscanner/doctemplates/Gjs/default.tmpl b/giscanner/doctemplates/Gjs/default.tmpl
new file mode 100644
index 0000000..b66ae92
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/default.tmpl
@@ -0,0 +1 @@
+<%inherit file="/base.tmpl"/>
diff --git a/giscanner/doctemplates/Gjs/enum.tmpl b/giscanner/doctemplates/Gjs/enum.tmpl
new file mode 100644
index 0000000..840f79f
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/enum.tmpl
@@ -0,0 +1,11 @@
+<%inherit file="/base.tmpl"/>
+<%block name="details">
+% if node.members:
+<dl>
+% for member, ix in zip(node.members, range(len(node.members))):
+<dt><p>${node.name}.${member.name.upper()} :</p></dt>
+<dd>${formatter.format(node, member.doc)}</dd>
+% endfor
+</dl>
+% endif
+</%block>
diff --git a/giscanner/doctemplates/Gjs/function.tmpl b/giscanner/doctemplates/Gjs/function.tmpl
new file mode 100644
index 0000000..92bfb3a
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/function.tmpl
@@ -0,0 +1,54 @@
+<%inherit file="/base.tmpl"/>
+<%block name="info">
+% if node.parent is not None:
+ <link type="guide" xref="${namespace.name}.${node.parent.name}" group="${page_style}"/>
+% else:
+ <link type="guide" xref="index" group="${page_style}"/>
+% endif
+ <api:function>
+ <api:returns>
+ <api:type>${formatter.format_type(node.retval.type) | x}</api:type>
+ </api:returns>
+ <api:name>${node.symbol}</api:name>
+% if node.is_method:
+ <api:arg>
+ <api:type>${node.parent.ctype} *</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+% endif
+% for arg in node.parameters:
+% if arg.type.ctype == '<varargs>':
+ <api:varargs/>
+% else:
+ <api:arg>
+ <api:type>${formatter.format_type(arg.type) | x}</api:type>
+ <api:name>${arg.argname}</api:name>
+ </api:arg>
+% endif
+% endfor
+ </api:function>
+</%block>
+<%block name="synopsis">
+<synopsis><code mime="text/x-gjs">
+function \
+${node.name}(\
+${', '.join('%s:%s' % (arg.argname, formatter.format_type(arg.type)) for arg in node.parameters)}\
+):${formatter.format_type(node.retval.type)} {
+ // Gjs wrapper for ${node.symbol}()
+}
+</code></synopsis>
+</%block>
+<%block name="details">
+% if node.parameters or node.retval:
+<dl>
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+<dt><p>${arg.argname} :</p></dt>
+<dd>${formatter.format(node, arg.doc)}</dd>
+% endfor
+% if node.retval and node.retval.type.ctype != 'void':
+<dt><p>Returns :</p></dt>
+<dd>${formatter.format(node, node.retval.doc)}</dd>
+% endif
+</dl>
+% endif
+</%block>
diff --git a/giscanner/doctemplates/Gjs/method.tmpl b/giscanner/doctemplates/Gjs/method.tmpl
new file mode 100644
index 0000000..a03d282
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/method.tmpl
@@ -0,0 +1 @@
+<%inherit file="./function.tmpl"/>
diff --git a/giscanner/doctemplates/Gjs/namespace.tmpl b/giscanner/doctemplates/Gjs/namespace.tmpl
new file mode 100644
index 0000000..4d80c2a
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/namespace.tmpl
@@ -0,0 +1,2 @@
+<%! page_type="guide" %>\
+<%inherit file="/namespace.tmpl"/>
diff --git a/giscanner/doctemplates/Gjs/property.tmpl b/giscanner/doctemplates/Gjs/property.tmpl
new file mode 100644
index 0000000..f05bc82
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/property.tmpl
@@ -0,0 +1,10 @@
+<%inherit file="/base.tmpl"/>
+<%block name="info">
+ <link type="guide" xref="${namespace.name}.${node.parent.name}" group="property"/>
+ <title type="link" role="topic">${node.name}</title>
+</%block>
+<%block name="synopsis">
+<synopsis><code mime="text/x-python">
+"${node.name}" ${formatter.format_type(node.type)} : ${formatter.format_property_flags(node)}
+</code></synopsis>
+</%block>
diff --git a/giscanner/doctemplates/Gjs/record.tmpl b/giscanner/doctemplates/Gjs/record.tmpl
new file mode 100644
index 0000000..1523e0d
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/record.tmpl
@@ -0,0 +1,2 @@
+<%! page_type="guide" %>\
+<%inherit file="/base.tmpl"/>
diff --git a/giscanner/doctemplates/Gjs/signal.tmpl b/giscanner/doctemplates/Gjs/signal.tmpl
new file mode 100644
index 0000000..f2eb586
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/signal.tmpl
@@ -0,0 +1,35 @@
+<%inherit file="/base.tmpl"/>
+<%block name="info">
+ <link type="guide" xref="${namespace.name}.${node.parent.name}" group="signal"/>
+ <title type="link" role="topic">${node.name}</title>
+</%block>
+<%block name="synopsis">
+<synopsis><code mime="text/x-python">
+function callback(${formatter.to_underscores(node.parent.name).lower()}, \
+% for arg in node.parameters:
+${arg.argname}:${formatter.format_type(arg.type)}, \
+% endfor
+user_param1, ...):${formatter.format_type(node.retval.type)};
+</code></synopsis>
+</%block>
+<%block name="details">
+<dl>
+<dt><p>${formatter.to_underscores(node.parent.name).lower()} :</p></dt>
+<dd><p>instance of ${namespace.name}.${node.parent.name} that is emitting the signal</p></dd>
+% for arg in node.parameters:
+<dt><p>${arg.argname} :</p></dt>
+<dd>${formatter.format(node, arg.doc)}</dd>
+% endfor
+<dt><p>user_param1 :</p></dt>
+<dd><p>first user parameter (if any) specified with the connect() method</p></dd>
+<dt><p>... :</p></dt>
+<dd><p>additional user parameters (if any)</p></dd>
+% if node.retval and \
+ node.retval.type.ctype != 'void' and \
+ node.retval.type.ctype is not None:
+<dt><p>Returns :</p></dt>
+<dd>${node.retval.type.ctype} ${formatter.format(node, node.retval.doc)}</dd>
+% endif
+</dl>
+</%block>
+
diff --git a/giscanner/doctemplates/Gjs/vfunc.tmpl b/giscanner/doctemplates/Gjs/vfunc.tmpl
new file mode 100644
index 0000000..bba3f38
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/vfunc.tmpl
@@ -0,0 +1,23 @@
+<%inherit file="/base.tmpl"/>
+<%block name="synopsis">
+<synopsis><code mime="text/x-gjs">
+function vfunc_${node.name}(\
+${', '.join('%s:%s' % (arg.argname, formatter.format_type(arg.type)) for arg in node.parameters)}\
+):${formatter.format_type(node.retval.type)} {
+}
+</code></synopsis>
+</%block>
+<%block name="details">
+% if node.parameters or node.retval:
+<dl>
+% for arg, ix in zip(node.parameters, range(len(node.parameters))):
+<dt><p>${arg.argname} :</p></dt>
+<dd>${formatter.format(node, arg.doc)}</dd>
+% endfor
+% if node.retval and node.retval.type.ctype != 'void':
+<dt><p>Returns :</p></dt>
+<dd>${formatter.format(node, node.retval.doc)}</dd>
+% endif
+</dl>
+% endif
+</%block>
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index 08d52c8..ece54a9 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -450,9 +450,80 @@ class MallardFormatterPython(MallardFormatter):
else:
return func.name
+class MallardFormatterGjs(MallardFormatter):
+ language = "Gjs"
+ mime_type = "text/x-gjs"
+
+ fundamentals = {
+ "TRUE": "true",
+ "FALSE": "false",
+ "NULL": "null",
+ }
+
+ def should_render_node(self, node):
+ if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None:
+ return False
+
+ return True
+
+ def is_method(self, node):
+ if getattr(node, "is_method", False):
+ return True
+
+ if isinstance(node, (ast.VFunction)):
+ return True
+
+ return False
+
+ def format_fundamental_type(self, name):
+ fundamental_types = {
+ "utf8": "String",
+ "gunichar": "String",
+ "gchar": "String",
+ "guchar": "String",
+ "gboolean": "Boolean",
+ "gint": "Number",
+ "guint": "Number",
+ "glong": "Number",
+ "gulong": "Number",
+ "gint64": "Number",
+ "guint64": "Number",
+ "gfloat": "Number",
+ "gdouble": "Number",
+ "gchararray": "String",
+ "GParam": "GLib.Param",
+ "PyObject": "Object",
+ "GStrv": "[String]",
+ "GVariant": "GLib.Variant",
+ }
+
+ return fundamental_types.get(name, name)
+
+ def format_type(self, type_):
+ if isinstance(type_, ast.Array):
+ return '[' + self.format_type(type_.element_type) + ']'
+ elif isinstance(type_, ast.Map):
+ return '{%s: %s}' % (self.format_type(type_.key_type),
+ self.format_type(type_.value_type))
+ elif type_.target_fundamental == "none":
+ return "void"
+ elif type_.target_giname is not None:
+ return type_.target_giname
+ else:
+ return self.format_fundamental_type(type_.target_fundamental)
+
+ def format_function_name(self, func):
+ if func.is_method:
+ return "%s.prototype.%s" % (func.parent.name, func.name)
+ elif func.is_constructor:
+ return "%s.%s" % (func.parent.name, func.name)
+ else:
+ return func.name
+
LANGUAGES = {
"c": MallardFormatterC,
"python": MallardFormatterPython,
+ "gjs": MallardFormatterGjs,
}
class MallardWriter(object):
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Callback.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Callback.page
new file mode 100644
index 0000000..98d30f8
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Callback.page
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Callback"
+ type="topic"
+ style="default"
+ 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"/>
+
+ </info>
+ <title>DocExamples.Callback</title>
+
+
+
+
+
+
+
+
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Enum.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Enum.page
new file mode 100644
index 0000000..79ea637
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Enum.page
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Enum"
+ type="topic"
+ style="enum"
+ 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"/>
+
+ </info>
+ <title>DocExamples.Enum</title>
+
+
+
+ <p>This is an example to document an enumeration.</p>
+
+
+
+
+<dl>
+<dt><p>Enum.FOO :</p></dt>
+<dd><p>a foo</p></dd>
+<dt><p>Enum.BAR :</p></dt>
+<dd><p>a bar</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-property-example.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-property-example.page
new file mode 100644
index 0000000..398fc4c
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-property-example.page
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj-property-example"
+ type="topic"
+ style="property"
+ 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="property"/>
+ <title type="link" role="topic">property-example</title>
+
+ </info>
+ <title>DocExamples.Obj:property-example</title>
+
+<synopsis><code mime="text/x-python">
+"property-example" {String: gint8} : Read / Write
+</code></synopsis>
+
+
+ <p>This is an example of how to document a property.</p>
+
+
+ <p>Since 0.99</p>
+
+
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-signal-example.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-signal-example.page
new file mode 100644
index 0000000..8b7e5d5
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-signal-example.page
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj-signal-example"
+ type="topic"
+ style="signal"
+ 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="signal"/>
+ <title type="link" role="topic">signal-example</title>
+
+ </info>
+ <title>DocExamples.Obj::signal-example</title>
+
+<synopsis><code mime="text/x-python">
+def callback(obj, int_param, float_param, pointer_param, user_param1, ...)
+</code></synopsis>
+
+
+ <p>This is an example of how to document a signal.</p>
+
+
+ <p>Since 0.99</p>
+
+
+<dl>
+<dt><p>obj :</p></dt>
+<dd><p>instance of DocExamples.Obj that is emitting the signal</p></dd>
+<dt><p>int_param :</p></dt>
+<dd><p>a parameter of type int</p></dd>
+<dt><p>float_param :</p></dt>
+<dd><p>a parameter of type float</p></dd>
+<dt><p>pointer_param :</p></dt>
+<dd><p>A pointer to @obj's thingy -- pass <code>int_param</code> if you really want to.</p></dd>
+<dt><p>user_param1 :</p></dt>
+<dd><p>first user parameter (if any) specified with the connect() method</p></dd>
+<dt><p>... :</p></dt>
+<dd><p>additional user parameters (if any)</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-vfunc.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-vfunc.page
new file mode 100644
index 0000000..bd876ca
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj-vfunc.page
@@ -0,0 +1,35 @@
+<?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="index"/>
+
+ </info>
+ <title>DocExamples.Obj::vfunc</title>
+
+<synopsis><code mime="text/x-python">
+ accepts(Number)
+ returns(none)
+def do_vfunc(self, first_arg):
+</code></synopsis>
+
+
+ <p>This is an example of how to document a vfunc.</p>
+
+
+ <p>Since 0.99</p>
+
+
+<dl>
+<dt><p>first_arg :</p></dt>
+<dd><p>first argument</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.method.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.method.page
new file mode 100644
index 0000000..4e04912
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.method.page
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj.method"
+ 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="DocExamples.Obj" group="method"/>
+ <api:function>
+ <api:returns>
+ <api:type>Boolean</api:type>
+ </api:returns>
+ <api:name>doc_examples_obj_method</api:name>
+ <api:arg>
+ <api:type>DocExamplesObj *</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>Number</api:type>
+ <api:name>first_arg</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>Number</api:type>
+ <api:name>second_arg</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>Boolean</api:type>
+ <api:name>boolean_arg</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>gpointer</api:type>
+ <api:name>pointer_arg</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>String</api:type>
+ <api:name>string</api:name>
+ </api:arg>
+ </api:function>
+
+ </info>
+ <title>Obj.prototype.method</title>
+
+<synopsis><code mime="text/x-python">
+ accepts(Number, Number, Boolean, gpointer, String)
+ returns(Boolean)
+def method(self, first_arg, second_arg, boolean_arg, pointer_arg, string):
+ # Python wrapper for doc_examples_obj_method()
+</code></synopsis>
+
+
+ <p>This is an example of how to document a method.</p><p>You should call this on a <link xref="DocExamples.Obj"/> that was
+created with <link xref="DocExamples.Obj.new"/>.</p><p>This should be a %FALSEALARM.</p>
+
+
+ <p>Since 0.99</p>
+
+
+<dl>
+<dt><p>first_arg :</p></dt>
+<dd><p>A <link xref="DocExamples.Obj"/>.</p></dd>
+<dt><p>second_arg :</p></dt>
+<dd><p>second argument</p></dd>
+<dt><p>boolean_arg :</p></dt>
+<dd><p>You should always pass <code>true</code>.</p></dd>
+<dt><p>pointer_arg :</p></dt>
+<dd><p>If not <code>null</code>, do a thing. Pass <code>first_arg</code> if you want to sometimes. You can also pass <code>second_arg</code>, or even <code>boolean_arg</code>.</p></dd>
+<dt><p>string :</p></dt>
+<dd><p>A NUL-terminated string.</p></dd>
+<dt><p>Returns :</p></dt>
+<dd><p>Either <code>false</code> or something <code>false</code>-y.</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.new.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.new.page
new file mode 100644
index 0000000..16dbd65
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.new.page
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj.new"
+ type="topic"
+ style="constructor"
+ 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="constructor"/>
+ <api:function>
+ <api:returns>
+ <api:type>DocExamples.Obj</api:type>
+ </api:returns>
+ <api:name>doc_examples_obj_new</api:name>
+ </api:function>
+
+ </info>
+ <title>Obj.new</title>
+
+<synopsis><code mime="text/x-python">
+ returns(DocExamples.Obj)
+def new():
+ # Python wrapper for doc_examples_obj_new()
+</code></synopsis>
+
+
+
+
+
+
+
+<dl>
+<dt><p>Returns :</p></dt>
+<dd></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.page
new file mode 100644
index 0000000..c040d0e
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.page
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj"
+ 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"/>
+
+ </info>
+ <title>DocExamples.Obj</title>
+
+ <synopsis><code>
+from gi.repository import DocExamples
+
+obj = DocExamples.Obj(<link xref='DocExamples.Obj-property-example'>property_example</link>=value) </code></synopsis>
+
+
+ <p>This is an example of how to document a class</p><p>This class has a signal: <link xref="DocExamples.Obj-signal-example"/>.</p><p>And also has a property: <link xref="DocExamples.Obj-property-example"/>.</p>
+
+
+ <p>Since 0.99</p>
+
+
+ <synopsis>
+ <title>Hierarchy</title>
+ <tree>
+ <item>
+ <code>GObject.Object</code>
+ <item>
+ <code>DocExamples.Obj</code>
+ </item>
+ </item>
+ </tree>
+ </synopsis>
+
+
+ <links type="topic" ui:expanded="yes"
+ api:type="function" api:mime="text/x-gjs"
+ groups="method" style="linklist">
+ <title>Methods</title>
+ </links>
+ <links type="topic" ui:expanded="yes"
+ api:type="function" api:mime="text/x-gjs"
+ groups="function" style="linklist">
+ <title>Functions</title>
+ </links>
+ <links type="topic" ui:expanded="yes" groups="property" style="linklist">
+ <title>Properties</title>
+ </links>
+ <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>
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.static_method.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.static_method.page
new file mode 100644
index 0000000..6577e9b
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.Obj.static_method.page
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<page id="DocExamples.Obj.static_method"
+ 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="DocExamples.Obj" group="function"/>
+ <api:function>
+ <api:returns>
+ <api:type>Boolean</api:type>
+ </api:returns>
+ <api:name>doc_examples_obj_static_method</api:name>
+ <api:arg>
+ <api:type>Number</api:type>
+ <api:name>out_arg</api:name>
+ </api:arg>
+ </api:function>
+
+ </info>
+ <title>static_method</title>
+
+<synopsis><code mime="text/x-python">
+ accepts(Number)
+ returns(Boolean)
+def static_method(out_arg):
+ # Python wrapper for doc_examples_obj_static_method()
+</code></synopsis>
+
+
+ <p>This is an example of a function with an out argument
+and a return value.</p>
+
+
+
+
+<dl>
+<dt><p>out_arg :</p></dt>
+<dd><p>a pointer to int, or <code>null</code> to ignore</p></dd>
+<dt><p>Returns :</p></dt>
+<dd><p><code>true</code> if <code>out_arg</code> is valid, <code>false</code> otherwise</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.array_function.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.array_function.page
new file mode 100644
index 0000000..f41047b
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.array_function.page
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<page id="DocExamples.array_function"
+ 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:returns>
+ <api:type>[Number]</api:type>
+ </api:returns>
+ <api:name>doc_examples_array_function</api:name>
+ <api:arg>
+ <api:type>Number</api:type>
+ <api:name>out_len</api:name>
+ </api:arg>
+ </api:function>
+
+ </info>
+ <title>array_function</title>
+
+<synopsis><code mime="text/x-python">
+ accepts(Number)
+ returns([Number])
+def array_function(out_len):
+ # Python wrapper for doc_examples_array_function()
+</code></synopsis>
+
+
+ <p>This function returns an array with an explicit length,
+and the length should be invisible in most introspected bindings.</p>
+
+
+
+
+<dl>
+<dt><p>out_len :</p></dt>
+<dd><p>the length of the returned array</p></dd>
+<dt><p>Returns :</p></dt>
+<dd><p>an array of numbers.</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page
new file mode 100644
index 0000000..9b80571
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/DocExamples.callback_function.page
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<page id="DocExamples.callback_function"
+ 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:returns>
+ <api:type>DocExamples.Enum</api:type>
+ </api:returns>
+ <api:name>doc_examples_callback_function</api:name>
+ <api:arg>
+ <api:type>DocExamples.Callback</api:type>
+ <api:name>callback</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>gpointer</api:type>
+ <api:name>user_data</api:name>
+ </api:arg>
+ <api:arg>
+ <api:type>GLib.DestroyNotify</api:type>
+ <api:name>destroy_notify</api:name>
+ </api:arg>
+ </api:function>
+
+ </info>
+ <title>callback_function</title>
+
+<synopsis><code mime="text/x-python">
+ accepts(DocExamples.Callback, gpointer, GLib.DestroyNotify)
+ returns(DocExamples.Enum)
+def callback_function(callback, user_data, destroy_notify):
+ # Python wrapper for doc_examples_callback_function()
+</code></synopsis>
+
+
+ <p>This is a function that takes a callback. Different languages
+will expose this in different ways (e.g. Python keeps the
+<code>user_data</code> parameter, while JS doesn't)</p>
+
+
+
+
+<dl>
+<dt><p>callback :</p></dt>
+<dd><p>Just Call Me Maybe</p></dd>
+<dt><p>user_data :</p></dt>
+<dd><p>your stuff</p></dd>
+<dt><p>destroy_notify :</p></dt>
+<dd><p>how to get rid of <code>user_data</code></p></dd>
+<dt><p>Returns :</p></dt>
+<dd><p><link xref="DocExamples.Enum"/>.foo sometimes, <link xref="DocExamples.Enum"/>.bar other times.</p></dd>
+</dl>
+
+
+
+</page>
diff --git a/tests/doctool/DocExamples-1.0-Gjs-expected/index.page b/tests/doctool/DocExamples-1.0-Gjs-expected/index.page
new file mode 100644
index 0000000..de98563
--- /dev/null
+++ b/tests/doctool/DocExamples-1.0-Gjs-expected/index.page
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<page id="index"
+ type="guide"
+ style="namespace"
+ 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"/>
+
+ </info>
+ <title>Index</title>
+
+
+
+
+
+
+
+
+
+ <links type="topic" ui:expanded="yes" groups="class" style="linklist">
+ <title>Classes</title>
+ </links>
+ <links type="topic" ui:expanded="yes" groups="function" style="linklist">
+ <title>Functions</title>
+ </links>
+ <links type="topic" ui:expanded="yes" groups="#first #default #last" style="linklist">
+ <title>Other</title>
+ </links>
+
+</page>
diff --git a/tests/doctool/Makefile.am b/tests/doctool/Makefile.am
index 127b258..4d2b9d7 100644
--- a/tests/doctool/Makefile.am
+++ b/tests/doctool/Makefile.am
@@ -14,8 +14,8 @@ libdocexamples_la_SOURCES = $(srcdir)/doc-examples-obj.c $(srcdir)/doc-examples-
GIRS =
TYPELIBS = $(GIRS:.gir=.typelib)
INTROSPECTION_GIRS = $(GIRS)
-CHECK_TARGETS = $(GIRS:.gir=-C.page.check) $(GIRS:.gir=-Python.page.check)
-MALLARD_DIRS = $(GIRS:.gir=-C) $(GIRS:.gir=-Python)
+CHECK_TARGETS = $(GIRS:.gir=-C.page.check) $(GIRS:.gir=-Python.page.check) $(GIRS:.gir=-Gjs.page.check)
+MALLARD_DIRS = $(GIRS:.gir=-C) $(GIRS:.gir=-Python) $(GIRS:.gir=-Gjs)
EXPECTED_MALLARD_DIRS = $(MALLARD_DIRS:=-expected)
CLEANFILES = $(TYPELIBS) $(GIRS)
BUILT_SOURCES = $(MALLARD_DIRS)
@@ -40,12 +40,21 @@ GIRS += DocExamples-1.0.gir
$(AM_V_at)rm -f $*-Python/*.page
$(AM_V_at)$(INTROSPECTION_DOCTOOL) --language Python $*.gir -o $*-Python/
+%-Gjs: %.gir
+ $(AM_V_GEN)
+ $(AM_V_at)$(MKDIR_P) $*-Gjs
+ $(AM_V_at)rm -f $*-Gjs/*.page
+ $(AM_V_at)$(INTROSPECTION_DOCTOOL) --language Gjs $*.gir -o $*-Gjs/
+
%-C.page.check: %-C
@diff -u -w -B -U 10 $(srcdir)/$*-C-expected $*-C && echo " TEST $*-C"
%-Python.page.check: %-Python
@diff -u -w -B -U 10 $(srcdir)/$*-Python-expected $*-Python && echo " TEST $*-Python"
+%-Gjs.page.check: %-Gjs
+ @diff -u -w -B -U 10 $(srcdir)/$*-Gjs-expected $*-Gjs && echo " TEST $*-Gjs"
+
check-local: $(CHECK_TARGETS) $(TYPELIBS)
clean-local:
@rm -rf $(MALLARD_DIRS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]