[gobject-introspection: 1/2] Introduce documentation-block options



commit 5b4df314f3c59530a930ab3b09cd44212603a771
Author: Andreas Rottmann <a rottmann gmx at>
Date:   Wed Mar 4 15:59:28 2009 +0100

    Introduce documentation-block options
    
    Allow a documentation block to have options, e.g.:
    
    /*
     * SomeType: (OPT-NAME VALUE) ...
     */
    
    Signed-off-by: Andreas Rottmann <a rottmann gmx at>
---
 giscanner/annotationparser.py |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 0798b80..b831f93 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -71,14 +71,15 @@ class InvalidAnnotationError(Exception):
 
 class DocBlock(object):
 
-    def __init__(self, name):
+    def __init__(self, name, options):
         self.name = name
+        self.options = options
         self.value = None
         self.tags = odict()
         self.comment = None
 
     def __repr__(self):
-        return '<DocBlock %r>' % (self.name, )
+        return '<DocBlock %r %r>' % (self.name, self.options)
 
     def get(self, name):
         if name == TAG_RETURNS:
@@ -148,6 +149,10 @@ class AnnotationParser(object):
         # /**
         #   * symbol:
         #
+        # Or, alternatively, with options:
+        # /**
+        #   * symbol: (name value) ...
+        #
         # symbol is currently one of:
         #  - function: gtk_widget_show
         #  - signal:   GtkWidget::destroy
@@ -165,11 +170,17 @@ class AnnotationParser(object):
         pos = comment.find('\n ')
         if pos == -1:
             return
-        block_name = comment[:pos]
-        block_name = block_name.strip()
-        if not block_name.endswith(':'):
-            return
-        block = DocBlock(block_name[:-1])
+        block_header = comment[:pos]
+        block_header = block_header.strip()
+        cpos = block_header.find(': ')
+        if cpos:
+            block_name = block_header[:cpos]
+            block_options, rest = self._parse_options(block_header[cpos+2:])
+            if rest:
+                return
+        else:
+            block_name, block_options = block_header, {}
+        block = DocBlock(block_name, block_options)
         comment_lines = []
         for line in comment[pos+1:].split('\n'):
             line = line.lstrip()



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