Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2009-03-04 14:59:28 (GMT)
committer Andreas Rottmann <a.rottmann@gmx.at>2009-03-04 14:59:28 (GMT)
commit5b4df314f3c59530a930ab3b09cd44212603a771 (patch)
tree03ac0e788b2efc07d954c1b8c90946523e6db28d
parent14556362aeb66e502c98cb9127c9b1acf67d598d (diff)
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>
-rw-r--r--giscanner/annotationparser.py25
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()