# -*- Mode: Python -*- # GObject-Introspection - a framework for introspecting GObject libraries # Copyright (C) 2008 Johan Dahlin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # # AnnotationParser - parses gtk-doc annotations # All gtk-doc comments needs to start with this: _COMMENT_HEADER = '*\n * ' from .ast import (Array, Callback, Class, Enum, Field, Function, Interface, List, Map, Parameter, Record, Return, Type, Union, Varargs, default_array_types, BASIC_GIR_TYPES, PARAM_DIRECTION_INOUT, PARAM_DIRECTION_IN, PARAM_DIRECTION_OUT, PARAM_TRANSFER_NONE, PARAM_TRANSFER_CONTAINER, PARAM_TRANSFER_FULL, TYPE_ANY, TYPE_NONE) from .glibast import GLibBoxed class InvalidAnnotationError(Exception): pass class DocBlock(object): def __init__(self, name): self.name = name self.value = None self.tags = {} def __repr__(self): return '' % (self.name, ) def get(self, name): if name == 'Returns': value = self.tags.get(name) if value is None: return self.tags.get('Return value') else: return value else: return self.tags.get(name) class DocTag(object): def __init__(self, name): self.name = name self.options = [] class Option(object): def __init__(self, option): self._array = [] self._dict = {} 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 '