def __repr__(self):
return '<DocBlock %r %r>' % (self.name, self.options)
- def set_position(self, position):
- self.position = position
- self.options.position = position
-
def get_tag(self, name):
return self.tags.get(name)
value_str), self.position)
return
- def set_position(self, position):
- self.position = position
- self.options.position = position
-
def _get_gtk_doc_value(self):
def serialize_one(option, value, fmt, fmt2):
if value:
class DocOptions(object):
def __init__(self):
self.values = []
+ self.position = None
def __repr__(self):
return '<DocOptions %r>' % (self.values, )
def __init__(self, tag, option):
self.tag = tag
self._array = []
- self._dict = {}
+ self._dict = odict()
# (annotation option1=value1 option2=value2) etc
for p in option.split(' '):
if '=' in p:
comment_lines = list(enumerate(comment.split('\n')))
# Check for the start the comment block.
- if COMMENT_START_RE.search(comment_lines[0][1]):
+ if COMMENT_START_RE.match(comment_lines[0][1]):
del comment_lines[0]
else:
# Not a GTK-Doc comment block.
return None
# Check for the end the comment block.
- if COMMENT_END_RE.search(comment_lines[-1][1]):
+ if COMMENT_END_RE.match(comment_lines[-1][1]):
del comment_lines[-1]
# If we get this far, we are inside a GTK-Doc comment block.
# Check for GTK-Doc comment block identifier.
####################################################################
if not comment_block:
- # The correct identifier name would have the colon at the end
- # but maintransformer.py does not expect us to do that. So
- # make sure to compute an identifier_name without the colon and
- # a real_identifier_name with the colon.
-
if not identifier:
- result = SECTION_RE.search(line)
+ result = SECTION_RE.match(line)
if result:
identifier = IDENTIFIER_SECTION
- real_identifier_name = 'SECTION:%s' % (result.group('section_name'))
- identifier_name = real_identifier_name
+ identifier_name = 'SECTION:%s' % (result.group('section_name'))
column = result.start('section_name') + column_offset
if not identifier:
- result = SYMBOL_RE.search(line)
+ result = SYMBOL_RE.match(line)
if result:
identifier = IDENTIFIER_SYMBOL
- real_identifier_name = '%s:' % (result.group('symbol_name'))
identifier_name = '%s' % (result.group('symbol_name'))
column = result.start('symbol_name') + column_offset
if not identifier:
- result = PROPERTY_RE.search(line)
+ result = PROPERTY_RE.match(line)
if result:
identifier = IDENTIFIER_PROPERTY
- real_identifier_name = '%s:%s:' % (result.group('class_name'),
- result.group('property_name'))
identifier_name = '%s:%s' % (result.group('class_name'),
result.group('property_name'))
column = result.start('property_name') + column_offset
if not identifier:
- result = SIGNAL_RE.search(line)
+ result = SIGNAL_RE.match(line)
if result:
identifier = IDENTIFIER_SIGNAL
- real_identifier_name = '%s::%s:' % (result.group('class_name'),
- result.group('signal_name'))
identifier_name = '%s::%s' % (result.group('class_name'),
result.group('signal_name'))
column = result.start('signal_name') + column_offset
in_part = PART_IDENTIFIER
comment_block = DocBlock(identifier_name)
- comment_block.set_position(position)
+ comment_block.position = position
if 'colon' in result.groupdict() and result.group('colon') != ':':
colon_start = result.start('colon')
####################################################################
# Check for comment block parameters.
####################################################################
- result = PARAMETER_RE.search(line)
+ result = PARAMETER_RE.match(line)
if result:
param_name = result.group('parameter_name')
param_annotations = result.group('annotations')
position)
tag = DocTag(comment_block, param_name)
- tag.set_position(position)
+ tag.position = position
tag.comment = param_description
if param_annotations:
tag.options = self.parse_options(tag, param_annotations)
# identifier (when there are no parameters) and encounter an empty
# line, we must be parsing the comment block description.
####################################################################
- if (EMPTY_LINE_RE.search(line)
+ if (EMPTY_LINE_RE.match(line)
and in_part in [PART_IDENTIFIER, PART_PARAMETERS]):
in_part = PART_DESCRIPTION
continue
####################################################################
# Check for GTK-Doc comment block tags.
####################################################################
- result = TAG_RE.search(line)
+ result = TAG_RE.match(line)
if result:
tag_name = result.group('tag_name')
tag_annotations = result.group('annotations')
else:
comment_block.comment = ''
- for tag in comment_block.tags.itervalues():
+ for tag in comment_block.tags.values():
self._clean_comment_block_part(tag)
- for param in comment_block.params.itervalues():
+ for param in comment_block.params.values():
self._clean_comment_block_part(param)
# Validate and store block.
:param position: position of `line` in the source file
'''
- result = MULTILINE_ANNOTATION_CONTINUATION_RE.search(line)
+ result = MULTILINE_ANNOTATION_CONTINUATION_RE.match(line)
if result:
- line = result.group('description')
column = result.start('annotations') + column_offset
marker = ' '*column + '^'
message.warn('ignoring invalid multiline annotation continuation:\n'