summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2011-02-01 16:14:00 -0200
committerJohan Dahlin <johan@gnome.org>2011-02-01 16:38:42 -0200
commited5437545efbf4e86833e1c632de76f30bb4ea52 (patch)
tree4fb352472dba63693e27bdc23260e06d0fd32dfc
parentd79670b1bf45bdb51635c9775d29b1c34ea18110 (diff)
downloadgobject-introspection-ed5437545efbf4e86833e1c632de76f30bb4ea52.tar.gz
Preserve gtk-doc section names
Preserve the section names and write them out on the class/record/ interface.
-rw-r--r--giscanner/annotationparser.py12
-rw-r--r--giscanner/maintransformer.py5
-rw-r--r--tests/scanner/Annotation-1.0-expected.gir1
3 files changed, 15 insertions, 3 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 3b376be2..f267d84d 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -123,7 +123,10 @@ class DocBlock(object):
if self.options:
options += ' '
options += ' '.join('(%s)' % o for o in self.options)
- lines = [self.name + ':' + options]
+ lines = [self.name]
+ if 'SECTION' not in self.name:
+ lines[0] += ':'
+ lines[0] += options
tags = []
for name, tag in self.tags.iteritems():
if name in self.params:
@@ -451,8 +454,11 @@ class AnnotationParser(object):
block_header = block_header.strip()
cpos = block_header.find(': ')
block_name = block_header
- if cpos:
- block_name = block_name[:cpos]
+ raw_name = block_header
+ if cpos != -1:
+ block_name = block_name[:cpos].strip()
+ if block_name.endswith(':'):
+ block_name = block_name[:-1]
block = DocBlock(block_name)
block.set_position(message.Position(filename, lineno))
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 893b3b71..1fcf5e81 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -217,6 +217,11 @@ usage is void (*_gtk_reserved1)(void);"""
block = self._get_block(node)
for field in node.fields:
self._apply_annotations_field(node, block, field)
+ name = self._get_annotation_name(node)
+ section_name = 'SECTION:' + name.lower()
+ block = self._blocks.get(section_name)
+ if block:
+ node.doc = block.comment
if isinstance(node, (ast.Class, ast.Interface)):
for prop in node.properties:
self._apply_annotations_property(node, prop)
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index e05e61b8..a760a19a 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -516,6 +516,7 @@ annotation_object_watch_full().</doc>
</return-value>
<parameters>
<parameter name="data" transfer-ownership="none">
+ <doc xml:whitespace="preserve">Opaque pointer handle</doc>
<type name="gpointer" c:type="void*"/>
</parameter>
</parameters>