summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-05-30 08:32:15 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-10-08 20:55:21 +0200
commitc3b42eeddca29a716f30df3c2bb093e53b6e62ea (patch)
tree930e4b659ee44d732c84e66f743bb27c34e9de43 /giscanner/annotationparser.py
parent24f9b0cea132e4f2c54c260b411ae0293f5b6117 (diff)
downloadgobject-introspection-c3b42eeddca29a716f30df3c2bb093e53b6e62ea.tar.gz
giscanner: rename DocAnnotations to GtkDocAnnotations
and move it below DocOption for easier reading
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r--giscanner/annotationparser.py88
1 files changed, 44 insertions, 44 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 2d3caf1e..fe89a48d 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -455,7 +455,45 @@ MULTILINE_ANNOTATION_CONTINUATION_RE = re.compile(
re.UNICODE | re.VERBOSE)
-class DocAnnotations(object):
+class DocOption(object):
+
+ __slots__ = ('tag', '_array', '_dict')
+
+ def __init__(self, tag, option):
+ self.tag = tag
+ self._array = []
+ self._dict = OrderedDict()
+ # (annotation option1=value1 option2=value2) etc
+ for p in option.split(' '):
+ if '=' in p:
+ name, value = p.split('=', 1)
+ else:
+ name = p
+ value = None
+ self._dict[name] = value
+ if value is None:
+ self._array.append(name)
+ else:
+ self._array.append((name, value))
+
+ def __repr__(self):
+ return '<DocOption %r>' % (self._array, )
+
+ def length(self):
+ return len(self._array)
+
+ def one(self):
+ assert len(self._array) == 1
+ return self._array[0]
+
+ def flat(self):
+ return self._array
+
+ def all(self):
+ return self._dict
+
+
+class GtkDocAnnotations(object):
__slots__ = ('values', 'position')
@@ -464,7 +502,7 @@ class DocAnnotations(object):
self.position = None
def __repr__(self):
- return '<DocAnnotations %r>' % (self.values, )
+ return '<GtkDocAnnotations %r>' % (self.values, )
def __getitem__(self, item):
for key, value in self.values:
@@ -496,44 +534,6 @@ class DocAnnotations(object):
return iter(self.values)
-class DocOption(object):
-
- __slots__ = ('tag', '_array', '_dict')
-
- def __init__(self, tag, option):
- self.tag = tag
- self._array = []
- self._dict = OrderedDict()
- # (annotation option1=value1 option2=value2) etc
- for p in option.split(' '):
- if '=' in p:
- name, value = p.split('=', 1)
- else:
- name = p
- value = None
- self._dict[name] = value
- if value is None:
- self._array.append(name)
- else:
- self._array.append((name, value))
-
- def __repr__(self):
- return '<DocOption %r>' % (self._array, )
-
- def length(self):
- return len(self._array)
-
- def one(self):
- assert len(self._array) == 1
- return self._array[0]
-
- def flat(self):
- return self._array
-
- def all(self):
- return self._dict
-
-
class GtkDocTag(object):
__slots__ = ('block', 'name', 'annotations', 'description', 'value', 'position')
@@ -541,7 +541,7 @@ class GtkDocTag(object):
def __init__(self, block, name):
self.block = block
self.name = name
- self.annotations = DocAnnotations()
+ self.annotations = GtkDocAnnotations()
self.description = None
self.value = ''
self.position = None
@@ -736,7 +736,7 @@ class GtkDocCommentBlock(object):
#: applied to this :class:`GtkDocCommentBlock`.
self.tags = OrderedDict()
- self.annotations = DocAnnotations()
+ self.annotations = GtkDocAnnotations()
self.value = None
self.position = None
@@ -793,7 +793,7 @@ class GtkDocCommentBlockParser(object):
GTK-Doc comment block parser.
Parse GTK-Doc comment blocks into a parse tree built out of :class:`GtkDocCommentBlock`,
- :class:`GtkDocTag`, :class:`DocAnnotations` and :class:`DocOption` objects. This
+ :class:`GtkDocTag`, :class:`GtkDocAnnotations` and :class:`DocOption` objects. This
parser tries to accept malformed input whenever possible and does not emit
syntax errors. However, it does emit warnings at the slightest indication
of malformed input when possible. It is usually a good idea to heed these
@@ -1291,7 +1291,7 @@ class GtkDocCommentBlockParser(object):
# (annotation opt1 opt2 ...)
# (annotation opt1=value1 opt2=value2 ...)
opened = -1
- annotations = DocAnnotations()
+ annotations = GtkDocAnnotations()
annotations.position = tag.position
for i, c in enumerate(value):