summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-08-13 09:35:10 -0400
committerColin Walters <walters@verbum.org>2011-08-13 09:38:27 -0400
commitbdeccbd7de9c1e42a879a6f9b01756280a138f47 (patch)
tree3c1e7af5e8f81386c73fe9db0280d8cbec97ac12 /giscanner/annotationparser.py
parentdead144faeeef4c0cd547ca287ede994745dbe7d (diff)
downloadgobject-introspection-bdeccbd7de9c1e42a879a6f9b01756280a138f47.tar.gz
annotationparser: Only accept certain tags
Previously we were eating any line form "* [A-Za-z]: " as a tag, but this is a problem since e.g. gtk/gtk/gtkcssprovder.c had literal CSS e.g. block: which erroneously matched. Fix this by only accepting particular tags, similar to what gtk-doc does (although we accept a superset, e.g. transfer too). https://bugzilla.gnome.org/show_bug.cgi?id=656458
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r--giscanner/annotationparser.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 0d7672e4..67ba72bb 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -25,9 +25,10 @@ import re
from . import message
from .odict import odict
-# Tags - annotations applyed to comment blocks
+# Tags - annotations applied to comment blocks
TAG_VFUNC = 'virtual'
TAG_SINCE = 'since'
+TAG_STABILITY = 'stability'
TAG_DEPRECATED = 'deprecated'
TAG_RETURNS = 'returns'
TAG_ATTRIBUTES = 'attributes'
@@ -37,6 +38,20 @@ TAG_UNREF_FUNC = 'unref func'
TAG_REF_FUNC = 'ref func'
TAG_SET_VALUE_FUNC = 'set value func'
TAG_GET_VALUE_FUNC = 'get value func'
+TAG_TRANSFER = 'transfer'
+_ALL_TAGS = [TAG_VFUNC,
+ TAG_SINCE,
+ TAG_STABILITY,
+ TAG_DEPRECATED,
+ TAG_RETURNS,
+ TAG_ATTRIBUTES,
+ TAG_RENAME_TO,
+ TAG_TYPE,
+ TAG_UNREF_FUNC,
+ TAG_REF_FUNC,
+ TAG_SET_VALUE_FUNC,
+ TAG_GET_VALUE_FUNC,
+ TAG_TRANSFER]
# Options - annotations for parameters and return values
OPT_ALLOW_NONE = 'allow-none'
@@ -416,7 +431,6 @@ class AnnotationParser(object):
COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n[\t ]')
COMMENT_HEADER_START_RE = re.compile(r'\n[\t ]')
WHITESPACE_RE = re.compile(r'^\s*$')
- ASCII_TEXT_RE = re.compile(r'\s*[A-Za-z]+')
OPTION_RE = re.compile(r'\([A-Za-z]+[^(]*\)')
RETURNS_RE = re.compile(r'^return(s?)( value)?:', re.IGNORECASE)
@@ -572,7 +586,7 @@ class AnnotationParser(object):
# The line is of the form "Tag: some value here", like:
# Since: 0.8
tag_name = line[:first_colonspace_index]
- if self.ASCII_TEXT_RE.match(tag_name):
+ if tag_name.lower() in _ALL_TAGS:
tag_name = tag_name.lower()
tag = DocTag(block, tag_name)
tag.value = line[first_colonspace_index+2:]