[gobject-introspection/wip/docs: 11/11] doctool: Add constants to the namespace
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/docs: 11/11] doctool: Add constants to the namespace
- Date: Wed, 27 Mar 2013 22:13:43 +0000 (UTC)
commit 751957cef1948cccb6eedb890ffbeec1aa022a93
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Mar 27 18:06:24 2013 -0400
doctool: Add constants to the namespace
This is an initial test before we port over to docbook to see if we
can build a new structure for how the pages should act.
giscanner/doctemplates/C/constant.tmpl | 4 ++++
giscanner/doctemplates/Gjs/constant.tmpl | 4 ++++
giscanner/doctemplates/Python/constant.tmpl | 4 ++++
giscanner/doctemplates/namespace.tmpl | 9 +++++++++
giscanner/docwriter.py | 8 ++++++++
5 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/giscanner/doctemplates/C/constant.tmpl b/giscanner/doctemplates/C/constant.tmpl
new file mode 100644
index 0000000..9cb05dd
--- /dev/null
+++ b/giscanner/doctemplates/C/constant.tmpl
@@ -0,0 +1,4 @@
+<item>
+ <title><code>#define ${constant.ctype} ${constant.value}</code></title>
+ ${formatter.format(constant, constant.doc)
+</item>
diff --git a/giscanner/doctemplates/Gjs/constant.tmpl b/giscanner/doctemplates/Gjs/constant.tmpl
new file mode 100644
index 0000000..f44f69c
--- /dev/null
+++ b/giscanner/doctemplates/Gjs/constant.tmpl
@@ -0,0 +1,4 @@
+<item>
+ <title><code>${constant.parent.name}.${constant.name} = ${constant.value}</code></title>
+ ${formatter.format(constant, constant.doc)
+</item>
diff --git a/giscanner/doctemplates/Python/constant.tmpl b/giscanner/doctemplates/Python/constant.tmpl
new file mode 100644
index 0000000..f44f69c
--- /dev/null
+++ b/giscanner/doctemplates/Python/constant.tmpl
@@ -0,0 +1,4 @@
+<item>
+ <title><code>${constant.parent.name}.${constant.name} = ${constant.value}</code></title>
+ ${formatter.format(constant, constant.doc)
+</item>
diff --git a/giscanner/doctemplates/namespace.tmpl b/giscanner/doctemplates/namespace.tmpl
index bb58bb1..4e29dc1 100644
--- a/giscanner/doctemplates/namespace.tmpl
+++ b/giscanner/doctemplates/namespace.tmpl
@@ -15,5 +15,14 @@
<title>Other</title>
</links>
</%block>
+<%block name="details">
+<terms>
+% for constant in formatter.collect('constant'):
+<item>
+<%include file="constant.tmpl" args="constant=constant"/>
+</item>
+% endfor
+</%block>
+
<%block name="since_version">
</%block>
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 7924b2d..d909ed1 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -165,11 +165,19 @@ class DocFormatter(object):
return saxutils.escape(text)
def should_render_node(self, node):
+ # Handled inline
if isinstance(node, ast.Constant):
return False
return True
+ def collect(self, type_name):
+ namespace = self._transformer.namespace
+ type_ = { 'constant': ast.Constant }[type_name]
+ for item in namespace.itervalues():
+ if isinstance(item, type_):
+ yield item
+
def format(self, node, doc):
if doc is None:
return ''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]