[gobject-introspection/wip/doctool-improvements: 7/14] mallardwriter: Pass the parent node around for inline formatting



commit 0153b1f4e8fc614800860df24aedda67ec3a4e16
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jan 9 02:12:13 2013 -0500

    mallardwriter: Pass the parent node around for inline formatting
    
    This will be used for @param detection.

 giscanner/mallard-C-class.tmpl         |    2 +-
 giscanner/mallard-C-default.tmpl       |    2 +-
 giscanner/mallard-C-enum.tmpl          |    2 +-
 giscanner/mallard-C-function.tmpl      |    6 ++--
 giscanner/mallard-C-property.tmpl      |    2 +-
 giscanner/mallard-C-record.tmpl        |    2 +-
 giscanner/mallard-C-signal.tmpl        |    2 +-
 giscanner/mallard-C-vfunc.tmpl         |    6 ++--
 giscanner/mallard-Python-class.tmpl    |    2 +-
 giscanner/mallard-Python-default.tmpl  |    2 +-
 giscanner/mallard-Python-enum.tmpl     |    4 +-
 giscanner/mallard-Python-function.tmpl |    6 ++--
 giscanner/mallard-Python-property.tmpl |    2 +-
 giscanner/mallard-Python-signal.tmpl   |    6 ++--
 giscanner/mallard-Python-vfunc.tmpl    |    6 ++--
 giscanner/mallardwriter.py             |   44 ++++++++++++++++----------------
 16 files changed, 48 insertions(+), 48 deletions(-)
---
diff --git a/giscanner/mallard-C-class.tmpl b/giscanner/mallard-C-class.tmpl
index 2d73904..b0f703f 100644
--- a/giscanner/mallard-C-class.tmpl
+++ b/giscanner/mallard-C-class.tmpl
@@ -9,7 +9,7 @@
     <link type="guide" xref="index" group="class"/>
   </info>
   <title>${node.ctype}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 % if node.version:
 <p>Since ${node.version}</p>
 % endif
diff --git a/giscanner/mallard-C-default.tmpl b/giscanner/mallard-C-default.tmpl
index 577fa56..8326343 100644
--- a/giscanner/mallard-C-default.tmpl
+++ b/giscanner/mallard-C-default.tmpl
@@ -7,5 +7,5 @@
   <info>
   </info>
   <title>${namespace.name}.${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-C-enum.tmpl b/giscanner/mallard-C-enum.tmpl
index 20cd089..b59f27e 100644
--- a/giscanner/mallard-C-enum.tmpl
+++ b/giscanner/mallard-C-enum.tmpl
@@ -8,5 +8,5 @@
     <link type="guide" xref="index"/>
   </info>
   <title>${node.namespace.name}.${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-C-function.tmpl b/giscanner/mallard-C-function.tmpl
index 2da4710..051fb0b 100644
--- a/giscanner/mallard-C-function.tmpl
+++ b/giscanner/mallard-C-function.tmpl
@@ -71,20 +71,20 @@ ${formatter.format_type(arg.type) | x} ${arg.argname}\
 %endif
 % endfor
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, 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>
+<td>${formatter.format(node, arg.doc)}</td>
 </tr>
 % endfor
 % if node.retval:
 <tr>
 <td><p>Returns :</p></td>
-<td>${formatter.format(node.retval.doc)}</td>
+<td>${formatter.format(node, node.retval.doc)}</td>
 </tr>
 % endif
 </table>
diff --git a/giscanner/mallard-C-property.tmpl b/giscanner/mallard-C-property.tmpl
index 2d37ba1..a471995 100644
--- a/giscanner/mallard-C-property.tmpl
+++ b/giscanner/mallard-C-property.tmpl
@@ -9,5 +9,5 @@
     <title type="link" role="topic">${node.name}</title>
   </info>
   <title>${node.parent.ctype}:${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-C-record.tmpl b/giscanner/mallard-C-record.tmpl
index a173e77..1c7223a 100644
--- a/giscanner/mallard-C-record.tmpl
+++ b/giscanner/mallard-C-record.tmpl
@@ -8,5 +8,5 @@
     <link type="guide" xref="index"/>
   </info>
   <title>${node.namespace.name}${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-C-signal.tmpl b/giscanner/mallard-C-signal.tmpl
index 7aae3ae..69ecaad 100644
--- a/giscanner/mallard-C-signal.tmpl
+++ b/giscanner/mallard-C-signal.tmpl
@@ -9,5 +9,5 @@
     <title type="link" role="topic">${node.name}</title>
   </info>
   <title>${node.parent.ctype}::${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-C-vfunc.tmpl b/giscanner/mallard-C-vfunc.tmpl
index 5b5bbfb..a35c7b5 100644
--- a/giscanner/mallard-C-vfunc.tmpl
+++ b/giscanner/mallard-C-vfunc.tmpl
@@ -11,20 +11,20 @@
   <title>${node.name}</title>
 <synopsis><code mime="text/x-csrc">
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, 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>
+<td>${formatter.format(node, arg.doc)}</td>
 </tr>
 % endfor
 % if node.retval:
 <tr>
 <td><p>Returns :</p></td>
-<td>${formatter.format(node.retval.doc)}</td>
+<td>${formatter.format(node, node.retval.doc)}</td>
 </tr>
 % endif
 </table>
diff --git a/giscanner/mallard-Python-class.tmpl b/giscanner/mallard-Python-class.tmpl
index 04e5fc7..6edf25d 100644
--- a/giscanner/mallard-Python-class.tmpl
+++ b/giscanner/mallard-Python-class.tmpl
@@ -9,7 +9,7 @@
     <link type="guide" xref="index" group="class"/>
   </info>
   <title>${namespace.name}.${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 
   <synopsis><code>
 from gi.repository import ${namespace.name}
diff --git a/giscanner/mallard-Python-default.tmpl b/giscanner/mallard-Python-default.tmpl
index 683adf6..8779105 100644
--- a/giscanner/mallard-Python-default.tmpl
+++ b/giscanner/mallard-Python-default.tmpl
@@ -7,5 +7,5 @@
   <info>
   </info>
   <title>${namespace.name}.${node.name}</title>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-Python-enum.tmpl b/giscanner/mallard-Python-enum.tmpl
index fd6ca0f..9e44ede 100644
--- a/giscanner/mallard-Python-enum.tmpl
+++ b/giscanner/mallard-Python-enum.tmpl
@@ -8,13 +8,13 @@
     <link type="guide" xref="index"/>
   </info>
   <title>${node.namespace.name}.${node.name}</title>
-  ${formatter.format(node.doc)}
+  ${formatter.format(node, node.doc)}
 % if node.members:
 <table>
 % for member, ix in zip(node.members, range(len(node.members))):
 <tr>
 <td><p>${node.name}.${member.name.upper()} :</p></td>
-<td>${formatter.format(member.doc)}</td>
+<td>${formatter.format(node, member.doc)}</td>
 </tr>
 % endfor
 </table>
diff --git a/giscanner/mallard-Python-function.tmpl b/giscanner/mallard-Python-function.tmpl
index 7aa25e8..496f3ae 100644
--- a/giscanner/mallard-Python-function.tmpl
+++ b/giscanner/mallard-Python-function.tmpl
@@ -64,20 +64,20 @@ ${arg.argname}\
 % endfor
 )
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, 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>
+<td>${formatter.format(node, 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>
+<td>${formatter.format(node, node.retval.doc)}</td>
 </tr>
 % endif
 </table>
diff --git a/giscanner/mallard-Python-property.tmpl b/giscanner/mallard-Python-property.tmpl
index c4d2229..7ef72cc 100644
--- a/giscanner/mallard-Python-property.tmpl
+++ b/giscanner/mallard-Python-property.tmpl
@@ -12,5 +12,5 @@
 <synopsis><code mime="text/x-python">
 "${node.name}"             ${formatter.format_type(node.type)}                : ${formatter.format_property_flags(node)}
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 </page>
diff --git a/giscanner/mallard-Python-signal.tmpl b/giscanner/mallard-Python-signal.tmpl
index fed0659..f26934f 100644
--- a/giscanner/mallard-Python-signal.tmpl
+++ b/giscanner/mallard-Python-signal.tmpl
@@ -16,7 +16,7 @@ ${arg.argname}, \
 % endfor
 user_param1, ...)
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, node.doc)}
 
 <table>
 <tr>
@@ -26,7 +26,7 @@ ${formatter.format(node.doc)}
 % for arg, ix in zip(node.parameters, range(len(node.parameters))):
 <tr>
 <td><p>${arg.argname} :</p></td>
-<td>${formatter.format(arg.doc)}</td>
+<td>${formatter.format(node, arg.doc)}</td>
 </tr>
 % endfor
 <tr>
@@ -42,7 +42,7 @@ ${formatter.format(node.doc)}
      node.retval.type.ctype is not None:
 <tr>
 <td><p>Returns :</p></td>
-<td>${node.retval.type.ctype} ${formatter.format(node.retval.doc)}</td>
+<td>${node.retval.type.ctype} ${formatter.format(node, node.retval.doc)}</td>
 </tr>
 % endif
 </table>
diff --git a/giscanner/mallard-Python-vfunc.tmpl b/giscanner/mallard-Python-vfunc.tmpl
index 7e95bc8..4c7ab8f 100644
--- a/giscanner/mallard-Python-vfunc.tmpl
+++ b/giscanner/mallard-Python-vfunc.tmpl
@@ -32,20 +32,20 @@ ${arg.argname}\
 % endfor
 ):
 </code></synopsis>
-${formatter.format(node.doc)}
+${formatter.format(node, 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>
+<td>${formatter.format(node, 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>
+<td>${formatter.format(node, node.retval.doc)}</td>
 </tr>
 % endif
 </table>
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index a682709..fe4307a 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -163,14 +163,14 @@ class MallardFormatter(object):
     def escape(self, text):
         return saxutils.escape(text)
 
-    def format(self, doc):
+    def format(self, node, doc):
         if doc is None:
             return ''
 
         result = ''
         for para in doc.split('\n\n'):
             result += '<p>'
-            result += self.format_inline(para)
+            result += self.format_inline(node, para)
             result += '</p>'
         return result
 
@@ -202,51 +202,51 @@ class MallardFormatter(object):
                 return item
         raise KeyError("Could not find %s" % (name, ))
 
-    def _process_other(self, match, props):
+    def _process_other(self, node, match, props):
         return self.escape(match)
 
-    def _process_property(self, match, props):
+    def _process_property(self, node, match, props):
         type_node = self._resolve_type(props['type_name'])
         if type_node is None:
             return match
 
         try:
-            node = self._find_thing(type_node.properties, props['property_name'])
+            prop = self._find_thing(type_node.properties, props['property_name'])
         except (AttributeError, KeyError), e:
             return match
 
-        return self.format_xref(node)
+        return self.format_xref(prop)
 
-    def _process_signal(self, match, props):
+    def _process_signal(self, node, match, props):
         type_node = self._resolve_type(props['type_name'])
         if type_node is None:
             return match
 
         try:
-            node = self._find_thing(type_node.signals, props['signal_name'])
+            signal = self._find_thing(type_node.signals, props['signal_name'])
         except (AttributeError, KeyError), e:
             return match
 
-        return self.format_xref(node)
+        return self.format_xref(signal)
 
-    def _process_type_name(self, match, props):
-        node = self._resolve_type(props['type_name'])
-        if node is None:
+    def _process_type_name(self, node, match, props):
+        type_ = self._resolve_type(props['type_name'])
+        if type_ is None:
             return match
 
-        return self.format_xref(node)
+        return self.format_xref(type_)
 
-    def _process_function_call(self, match, props):
-        node = self._resolve_symbol(props['symbol_name'])
-        if node is None:
+    def _process_function_call(self, node, match, props):
+        func = self._resolve_symbol(props['symbol_name'])
+        if func is None:
             return match
 
-        return self.format_xref(node)
+        return self.format_xref(func)
 
-    def _process_fundamental(self, match, props):
+    def _process_fundamental(self, node, match, props):
         return self.fundamentals.get(props['fundamental'], match)
 
-    def _process_token(self, tok):
+    def _process_token(self, node, tok):
         kind, match, props = tok
 
         dispatch = {
@@ -258,11 +258,11 @@ class MallardFormatter(object):
             'fundamental': self._process_fundamental,
         }
 
-        return dispatch[kind](match, props)
+        return dispatch[kind](node, match, props)
 
-    def format_inline(self, para):
+    def format_inline(self, node, para):
         tokens = self._scanner.scan(para)
-        words = [self._process_token(tok) for tok in tokens]
+        words = [self._process_token(node, tok) for tok in tokens]
         return ''.join(words)
 
     def format_function_name(self, func):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]