[gobject-introspection] docwriter: Clean up make_page_id
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] docwriter: Clean up make_page_id
- Date: Sat, 16 Feb 2013 00:54:55 +0000 (UTC)
commit a3e9079c7381218e8111f81402ad2e70c9e416d4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Feb 15 06:40:20 2013 -0500
docwriter: Clean up make_page_id
Make it use a simple recursive technique similar to format_page_name.
giscanner/docwriter.py | 29 ++++++++---------------------
1 files changed, 8 insertions(+), 21 deletions(-)
---
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
index 763a09d..affcd2d 100644
--- a/giscanner/docwriter.py
+++ b/giscanner/docwriter.py
@@ -31,30 +31,17 @@ from mako.lookup import TemplateLookup
from . import ast, xmlwriter
from .utils import to_underscores
-def make_page_id(node):
+def make_page_id(node, recursive=False):
if isinstance(node, ast.Namespace):
- return 'index'
-
- namespace = node.namespace
- if isinstance(node, (ast.Class, ast.Interface)):
- return '%s.%s' % (namespace.name, node.name)
- elif isinstance(node, ast.Record):
- return '%s.%s' % (namespace.name, node.name)
- elif isinstance(node, ast.Function):
- if node.parent is not None:
- return '%s.%s.%s' % (namespace.name, node.parent.name, node.name)
+ if recursive:
+ return node.name
else:
- return '%s.%s' % (namespace.name, node.name)
- elif isinstance(node, ast.Enum):
- return '%s.%s' % (namespace.name, node.name)
- 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)
+ return 'index'
+
+ if isinstance(node, (ast.Property, ast.Signal, ast.VFunction)):
+ return '%s-%s' % (make_page_id(node.parent, recursive=True), node.name)
else:
- return '%s.%s' % (namespace.name, node.name)
+ return '%s.%s' % (make_page_id(node.parent, recursive=True), node.name)
def get_node_kind(node):
if isinstance(node, ast.Namespace):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]