[gobject-introspection] Preserve gtk-doc section names
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Preserve gtk-doc section names
- Date: Tue, 1 Feb 2011 18:40:17 +0000 (UTC)
commit ed5437545efbf4e86833e1c632de76f30bb4ea52
Author: Johan Dahlin <johan gnome org>
Date: Tue Feb 1 16:14:00 2011 -0200
Preserve gtk-doc section names
Preserve the section names and write them out on the class/record/
interface.
giscanner/annotationparser.py | 12 +++++++++---
giscanner/maintransformer.py | 5 +++++
tests/scanner/Annotation-1.0-expected.gir | 1 +
3 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 3b376be..f267d84 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 893b3b7..1fcf5e8 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 e05e61b..a760a19 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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]