[gobject-introspection/wip/doctool-improvements: 6/14] mallardwriter: Consolidate xref building and page naming code
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/doctool-improvements: 6/14] mallardwriter: Consolidate xref building and page naming code
- Date: Wed, 9 Jan 2013 08:17:22 +0000 (UTC)
commit 709408994a2806678c6c3258de2820a322f4e0c7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jan 9 01:56:41 2013 -0500
mallardwriter: Consolidate xref building and page naming code
Simple code cleanups.
giscanner/mallardwriter.py | 31 +++++++++++++++++++++++--------
1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index 0c9b996..a682709 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -215,8 +215,7 @@ class MallardFormatter(object):
except (AttributeError, KeyError), e:
return match
- xref_name = "%s.%s:%s" % (node.namespace.name, type_node.name, node.name)
- return '<link xref="%s">%s</link>' % (make_page_id(node), xref_name)
+ return self.format_xref(node)
def _process_signal(self, match, props):
type_node = self._resolve_type(props['type_name'])
@@ -228,23 +227,21 @@ class MallardFormatter(object):
except (AttributeError, KeyError), e:
return match
- xref_name = "%s.%s::%s" % (node.namespace.name, type_node.name, node.name)
- return '<link xref="%s">%s</link>' % (make_page_id(node), xref_name)
+ return self.format_xref(node)
def _process_type_name(self, match, props):
node = self._resolve_type(props['type_name'])
if node is None:
return match
- xref_name = "%s.%s" % (node.namespace.name, node.name)
- return '<link xref="%s">%s</link>' % (make_page_id(node), xref_name)
+
+ return self.format_xref(node)
def _process_function_call(self, match, props):
node = self._resolve_symbol(props['symbol_name'])
if node is None:
return match
- return '<link xref="%s">%s</link>' % (make_page_id(node),
- self.format_function_name(node))
+ return self.format_xref(node)
def _process_fundamental(self, match, props):
return self.fundamentals.get(props['fundamental'], match)
@@ -274,6 +271,24 @@ class MallardFormatter(object):
def format_type(self, type_):
raise NotImplementedError
+ def format_page_name(self, node):
+ namespace = node.namespace
+ if isinstance(node, ast.Namespace):
+ return 'Index'
+ elif isinstance(node, ast.Function):
+ return self.format_function_name(node)
+ elif isinstance(node, ast.Property) and node.parent is not None:
+ return '%s.%s:%s' % (namespace.name, node.parent.name, node.name)
+ elif isinstance(node, ast.Signal) and node.parent is not None:
+ return '%s.%s::%s' % (namespace.name, node.parent.name, node.name)
+ elif isinstance(node, ast.VFunction) and node.parent is not None:
+ return '%s.%s::%s' % (namespace.name, node.parent.name, node.name)
+ else:
+ return make_page_id(node)
+
+ def format_xref(self, node):
+ return '<link xref="%s">%s</link>' % (make_page_id(node), self.format_page_name(node))
+
def format_property_flags(self, property_, construct_only=False):
flags = []
if property_.readable and not construct_only:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]