More docs

This commit is contained in:
Yevgen Muntyan 2011-01-22 17:40:22 -08:00
parent 00682f27c0
commit 3ed115e2d7
26 changed files with 476 additions and 506 deletions

View File

@ -10,6 +10,7 @@ op = optparse.OptionParser()
op.add_option("--python", action="store_true") op.add_option("--python", action="store_true")
op.add_option("--lua", action="store_true") op.add_option("--lua", action="store_true")
op.add_option("--template", action="store") op.add_option("--template", action="store")
op.add_option("-i", "--import", action="append", dest="import_modules")
(opts, args) = op.parse_args() (opts, args) = op.parse_args()
assert len(args) == 1 assert len(args) == 1
@ -19,5 +20,12 @@ if opts.python:
elif opts.lua: elif opts.lua:
mode = 'lua' mode = 'lua'
import_modules = []
if opts.import_modules:
for filename in opts.import_modules:
import_modules.append(Module.from_xml(filename))
mod = Module.from_xml(args[0]) mod = Module.from_xml(args[0])
for im in import_modules:
mod.import_module(im)
Writer(mode, opts.template, sys.stdout).write(mod) Writer(mode, opts.template, sys.stdout).write(mod)

View File

@ -13,8 +13,64 @@ python_constants = {
'NULL': 'None', 'NULL': 'None',
'TRUE': 'True', 'TRUE': 'True',
'FALSE': 'False', 'FALSE': 'False',
'GTK_RESPONSE_OK': 'gtk.RESPONSE_OK',
} }
common_types = {
'gboolean': '<constant>bool</constant>',
'strv': 'list of strings',
}
lua_types = dict(common_types)
lua_types.update({
'index': '<constant>index</constant>',
'gunichar': '<constant>string</constant>',
'double': '<constant>number</constant>',
'int': '<constant>integer</constant>',
'gint': '<constant>integer</constant>',
'guint': '<constant>integer</constant>',
'const-utf8': '<constant>string</constant>',
'utf8': '<constant>string</constant>',
'const-filename': '<constant>string</constant>',
'filename': '<constant>string</constant>',
'const-cstring': '<constant>string</constant>',
'cstring': '<constant>string</constant>',
})
python_types = dict(common_types)
python_types.update({
'index': '<constant>int</constant>',
'gunichar': '<constant>str</constant>',
'double': '<constant>float</constant>',
'int': '<constant>int</constant>',
'gint': '<constant>int</constant>',
'guint': '<constant>int</constant>',
'const-utf8': '<constant>str</constant>',
'utf8': '<constant>str</constant>',
'const-filename': '<constant>str</constant>',
'filename': '<constant>str</constant>',
'const-cstring': '<constant>str</constant>',
'cstring': '<constant>str</constant>',
})
def format_python_symbol_ref(symbol):
constants = {
}
classes = {
'GFile': 'gio.File',
'GObject': 'gobject.Object',
'GType': 'type',
}
if symbol in constants:
return '<constant>%s</constant>' % constants[symbol]
if symbol in classes:
return '<constant>%s</constant>' % classes[symbol]
if symbol.startswith('Gtk'):
return '<constant>gtk.%s</constant>' % symbol[3:]
if symbol.startswith('Gdk'):
return '<constant>gtk.gdk.%s</constant>' % symbol[3:]
raise NotImplementedError(symbol)
def split_camel_case_name(name): def split_camel_case_name(name):
comps = [] comps = []
cur = '' cur = ''
@ -40,15 +96,30 @@ class Writer(object):
self.template = template self.template = template
if mode == 'python': if mode == 'python':
self.constants = python_constants self.constants = python_constants
self.builtin_types = python_types
elif mode == 'lua': elif mode == 'lua':
self.constants = lua_constants self.constants = lua_constants
self.builtin_types = lua_types
else: else:
oops('unknown mode %s' % mode) oops('unknown mode %s' % mode)
self.section_suffix = ' (%s)' % self.mode.capitalize() self.section_suffix = ' (%s)' % self.mode.capitalize()
def __format_symbol_ref(self, symbol): def __format_symbol_ref(self, name):
return symbol sym = self.symbols.get(name)
if sym:
if isinstance(sym, EnumValue):
return '<constant><link linkend="%(mode)s.%(parent)s" endterm="%(mode)s.%(symbol)s.title"></link></constant>' % \
dict(symbol=name, mode=self.mode, parent=sym.enum.symbol_id())
elif isinstance(sym, Type):
return '<constant><link linkend="%(mode)s.%(symbol)s" endterm="%(mode)s.%(symbol)s.title"></link></constant>' % \
dict(symbol=name, mode=self.mode)
else:
oops(name)
if self.mode == 'python':
return format_python_symbol_ref(name)
else:
raise NotImplementedError(name)
def __string_to_bool(self, s): def __string_to_bool(self, s):
if s == '0': if s == '0':
@ -72,7 +143,10 @@ class Writer(object):
return value return value
except ValueError: except ValueError:
pass pass
warning("unknown constant '%s'" % value) formatted = self.__format_symbol_ref(value)
if formatted:
return formatted
error("unknown constant '%s'" % value)
return value return value
def __format_doc(self, doc): def __format_doc(self, doc):
@ -87,20 +161,27 @@ class Writer(object):
dict(func_id=m.group(1), mode=self.mode) dict(func_id=m.group(1), mode=self.mode)
text = re.sub(r'([\w\d_.]+)\(\)', repl_func, text) text = re.sub(r'([\w\d_.]+)\(\)', repl_func, text)
def repl_func(m): def repl_signal(m):
return self.__format_symbol_ref(m.group(1)) cls = m.group(1)
text = re.sub(r'#([\w\d_]+)', repl_func, text) signal = m.group(2).replace('_', '-')
symbol = 'signal:%s:%s' % (cls, signal)
return '<function><link linkend="%(mode)s.%(symbol)s">%(signal)s</link></function>' % \
dict(symbol=symbol, mode=self.mode, signal=signal)
text = re.sub(r'([\w\d_-]+)::([\w\d_-]+)', repl_signal, text)
def repl_symbol(m):
symbol = m.group(1)
formatted = self.__format_symbol_ref(symbol)
if not formatted:
raise RuntimeError('unknown symbol %s' % symbol)
return formatted
text = re.sub(r'#([\w\d_]+)', repl_symbol, text)
assert not re.search(r'NULL|TRUE|FALSE', text) assert not re.search(r'NULL|TRUE|FALSE', text)
return text return text
def __make_class_name(self, cls): def __make_class_name(self, cls):
if self.mode == 'python': return '%s.%s' % (self.module.name.lower(), cls.short_name)
return 'moo.%s' % cls.short_name
elif self.mode == 'lua':
return 'medit.%s' % cls.short_name
else:
oops()
def __get_obj_name(self, cls): def __get_obj_name(self, cls):
name = cls.annotations.get('moo.doc-object-name') name = cls.annotations.get('moo.doc-object-name')
@ -149,14 +230,8 @@ class Writer(object):
else: else:
oops() oops()
else: else:
if self.mode == 'python':
func_title = func.name + '()' func_title = func.name + '()'
func_name = 'moo.%s' % func.name func_name = '%s.%s' % (self.module.name.lower(), func.name)
elif self.mode == 'lua':
func_title = func.name + '()'
func_name = 'medit.%s' % func.name
else:
oops()
params_string = ', '.join(params) params_string = ', '.join(params)
@ -175,13 +250,7 @@ class Writer(object):
if func.doc: if func.doc:
self.out.write('<para>%s</para>\n' % self.__format_doc(func.doc)) self.out.write('<para>%s</para>\n' % self.__format_doc(func.doc))
has_param_docs = False if func_params:
for p in func_params:
if p.doc:
has_param_docs = True
break
if has_param_docs:
self.out.write("""\ self.out.write("""\
<variablelist> <variablelist>
<?dbhtml list-presentation="table"?> <?dbhtml list-presentation="table"?>
@ -189,7 +258,26 @@ class Writer(object):
""") """)
for p in func_params: for p in func_params:
param_dic = dict(param=p.name, doc=self.__format_doc(p.doc)) if p.doc:
docs = doc=self.__format_doc(p.doc)
else:
ptype = p.type.symbol_id()
if ptype.endswith('*'):
ptype = ptype[:-1]
if ptype.startswith('const-'):
ptype = ptype[len('const-'):]
if ptype in self.builtin_types:
docs = self.builtin_types[ptype]
elif ptype.endswith('Array'):
elmtype = ptype[:-len('Array')]
if elmtype in self.symbols and isinstance(self.symbols[elmtype], InstanceType):
docs = 'list of %s objects' % self.__format_symbol_ref(self.symbols[elmtype].symbol_id())
else:
docs = self.__format_symbol_ref(ptype)
else:
docs = self.__format_symbol_ref(ptype)
param_dic = dict(param=p.name, doc=docs)
self.out.write("""\ self.out.write("""\
<varlistentry> <varlistentry>
<term><parameter>%(param)s</parameter></term> <term><parameter>%(param)s</parameter></term>
@ -199,6 +287,26 @@ class Writer(object):
self.out.write('</variablelist>\n') self.out.write('</variablelist>\n')
if func.retval:
retdoc = None
if func.retval.doc:
retdoc = self.__format_doc(func.retval.doc)
else:
rettype = func.retval.type.symbol_id()
if rettype.endswith('*'):
rettype = rettype[:-1]
if rettype in self.builtin_types:
retdoc = self.builtin_types[rettype]
elif rettype.endswith('Array'):
elmtype = rettype[:-len('Array')]
if elmtype in self.symbols and isinstance(self.symbols[elmtype], InstanceType):
retdoc = 'list of %s objects' % self.__format_symbol_ref(self.symbols[elmtype].symbol_id())
else:
retdoc = self.__format_symbol_ref(rettype)
else:
retdoc = self.__format_symbol_ref(rettype)
if retdoc:
self.out.write('<para><parameter>Returns:</parameter> %s</para>\n' % retdoc)
self.out.write('</sect2>\n') self.out.write('</sect2>\n')
@ -210,42 +318,13 @@ class Writer(object):
if not self.__check_bind_ann(cls): if not self.__check_bind_ann(cls):
return return
do_write = False
if cls.constructor is not None and self.__check_bind_ann(cls.constructor):
do_write = True
elif self.mode != 'lua' and hasattr(cls, 'constructable') and cls.constructable:
do_write = True
else:
for meth in cls.methods:
if self.__check_bind_ann(meth):
do_write = True
break
if not do_write:
for meth in cls.static_methods:
if self.__check_bind_ann(meth):
do_write = True
break
if not do_write and hasattr(cls, 'signals'):
for meth in cls.signals:
if self.__check_bind_ann(meth):
do_write = True
break
if not do_write:
return
title = self.__make_class_name(cls) title = self.__make_class_name(cls)
if cls.summary: if cls.summary:
title += ' - ' + cls.summary.text title += ' - ' + cls.summary.text
dic = dict(Class=self.__make_class_name(cls), dic = dict(class_id=cls.symbol_id(), title=title, mode=self.mode)
HELPSECTION='SCRIPT_%s_%s' % (self.mode.upper(), name_all_caps(cls)),
section_suffix=self.section_suffix,
title=title,
summary=cls.summary.text + '.' if cls.summary else '',
subsection='class %s' % self.__make_class_name(cls))
self.out.write("""\ self.out.write("""\
<sect1 id="%(Class)s"> <sect1 id="%(mode)s.%(class_id)s">
<title>%(title)s</title> <title id="%(mode)s.%(class_id)s.title">%(title)s</title>
""" % dic) """ % dic)
if cls.doc: if cls.doc:
@ -270,22 +349,91 @@ class Writer(object):
</sect1> </sect1>
""" % dic) """ % dic)
def write(self, module): def __write_enum(self, enum):
self.module = module if not self.__check_bind_ann(enum):
return
for cls in module.get_classes() + module.get_boxed() + module.get_pointers(): do_write = False
self.__write_class(cls) for v in enum.values:
if self.__check_bind_ann(v):
do_write = True
break
if not do_write:
return
title = self.__make_class_name(enum)
if enum.summary:
title += ' - ' + enum.summary.text
dic = dict(title=title,
mode=self.mode,
enum_id=enum.symbol_id())
self.out.write("""\ self.out.write("""\
<sect1 id="functions"> <sect2 id="%(mode)s.%(enum_id)s">
<title>Functions</title> <title id="%(mode)s.%(enum_id)s.title">%(title)s</title>
""" % dic)
if enum.doc:
self.out.write('<para>%s</para>\n' % self.__format_doc(enum.doc))
self.out.write("""\
<variablelist>
<?dbhtml list-presentation="table"?>
""") """)
for func in module.get_functions(): for v in enum.values:
if not self.__check_bind_ann(v):
continue
value_dic = dict(mode=self.mode, enum_id=v.name, value=v.short_name,
doc=self.__format_doc(v.doc) if v.doc else '')
self.out.write("""\
<varlistentry>
<term><constant id="%(mode)s.%(enum_id)s.title">%(value)s</constant></term>
<listitem><para>%(doc)s</para></listitem>
</varlistentry>
""" % value_dic)
self.out.write('</variablelist>\n')
self.out.write('</sect2>\n')
def write(self, module):
self.module = module
self.symbols = module.get_symbols()
classes = module.get_classes() + module.get_boxed() + module.get_pointers()
for cls in sorted(classes, lambda cls1, cls2: cmp(cls1.short_name, cls2.short_name)):
self.__write_class(cls)
funcs = []
for f in module.get_functions():
if self.__check_bind_ann(f):
funcs.append(f)
dic = dict(mode=self.mode)
if funcs:
self.out.write("""\
<sect1 id="%(mode)s.functions">
<title>Functions</title>
""" % dic)
for func in funcs:
self.__write_function(func, None) self.__write_function(func, None)
self.out.write('</sect1>\n') self.out.write('</sect1>\n')
self.out.write("""\
<sect1 id="%(mode)s.enums">
<title>Enumerations</title>
""" % dic)
for func in module.get_enums():
self.__write_enum(func)
self.out.write('</sect1>\n')
content = self.out.getvalue() content = self.out.getvalue()
template = open(self.template).read() template = open(self.template).read()
self.file.write(template.replace('###GENERATED###', content)) self.file.write(template.replace('###GENERATED###', content))

View File

@ -1,4 +1,5 @@
import re import re
import sys
import xml.etree.ElementTree as _etree import xml.etree.ElementTree as _etree
class Doc(object): class Doc(object):
@ -30,14 +31,16 @@ class _XmlObject(object):
self.doc = None self.doc = None
self.summary = None self.summary = None
self.annotations = {} self.annotations = {}
self.module = None
@classmethod @classmethod
def from_xml(cls, elm, *args): def from_xml(cls, module, elm, *args):
obj = cls() obj = cls()
obj._parse_xml(elm, *args) obj.module = module
obj._parse_xml(module, elm, *args)
return obj return obj
def _parse_xml_element(self, elm): def _parse_xml_element(self, module, elm):
if elm.tag in ('doc', 'summary'): if elm.tag in ('doc', 'summary'):
_set_unique_attribute(self, elm.tag, Doc.from_xml(elm)) _set_unique_attribute(self, elm.tag, Doc.from_xml(elm))
else: else:
@ -50,12 +53,12 @@ class _XmlObject(object):
else: else:
return False return False
def _parse_xml(self, elm, *args): def _parse_xml(self, module, elm, *args):
for attr, value in elm.items(): for attr, value in elm.items():
if not self._parse_attribute(attr, value): if not self._parse_attribute(attr, value):
raise RuntimeError('unknown attribute %s' % (attr,)) raise RuntimeError('unknown attribute %s' % (attr,))
for child in elm.getchildren(): for child in elm.getchildren():
self._parse_xml_element(child) self._parse_xml_element(module, child)
class _ParamBase(_XmlObject): class _ParamBase(_XmlObject):
def __init__(self): def __init__(self):
@ -90,7 +93,7 @@ class Retval(_ParamBase):
def __init__(self): def __init__(self):
_ParamBase.__init__(self) _ParamBase.__init__(self)
class _FunctionBase(_XmlObject): class FunctionBase(_XmlObject):
def __init__(self): def __init__(self):
_XmlObject.__init__(self) _XmlObject.__init__(self)
self.name = None self.name = None
@ -106,34 +109,34 @@ class _FunctionBase(_XmlObject):
return _XmlObject._parse_attribute(self, attr, value) return _XmlObject._parse_attribute(self, attr, value)
return True return True
def _parse_xml_element(self, elm): def _parse_xml_element(self, module, elm):
if elm.tag == 'retval': if elm.tag == 'retval':
_set_unique_attribute(self, 'retval', Retval.from_xml(elm)) _set_unique_attribute(self, 'retval', Retval.from_xml(module, elm))
elif elm.tag == 'param': elif elm.tag == 'param':
self.params.append(Param.from_xml(elm)) self.params.append(Param.from_xml(module, elm))
else: else:
_XmlObject._parse_xml_element(self, elm) _XmlObject._parse_xml_element(self, module, elm)
def _parse_xml(self, elm, *args): def _parse_xml(self, module, elm, *args):
_XmlObject._parse_xml(self, elm, *args) _XmlObject._parse_xml(self, module, elm, *args)
if not self.name: if not self.name:
raise RuntimeError('function name missing') raise RuntimeError('function name missing')
if not self.c_name: if not self.c_name:
raise RuntimeError('function c_name missing') raise RuntimeError('function c_name missing')
class Function(_FunctionBase): class Function(FunctionBase):
def __init__(self): def __init__(self):
_FunctionBase.__init__(self) FunctionBase.__init__(self)
def symbol_id(self): def symbol_id(self):
return self.c_name return self.c_name
class _MethodBase(_FunctionBase): class _MethodBase(FunctionBase):
def __init__(self): def __init__(self):
super(_MethodBase, self).__init__() super(_MethodBase, self).__init__()
def _parse_xml(self, elm, cls): def _parse_xml(self, module, elm, cls):
super(_MethodBase, self)._parse_xml(elm, cls) super(_MethodBase, self)._parse_xml(module, elm, cls)
self.cls = cls self.cls = cls
class Constructor(_MethodBase): class Constructor(_MethodBase):
@ -171,7 +174,7 @@ class Signal(_MethodBase):
self.c_name = "fake" self.c_name = "fake"
def symbol_id(self): def symbol_id(self):
return '%s::%s' % (self.cls.name, self.name) return 'signal:%s:%s' % (self.cls.name, self.name)
class Type(_XmlObject): class Type(_XmlObject):
def __init__(self): def __init__(self):
@ -212,8 +215,8 @@ class GTypedType(Type):
return Type._parse_attribute(self, attr, value) return Type._parse_attribute(self, attr, value)
return True return True
def _parse_xml(self, elm, *args): def _parse_xml(self, module, elm, *args):
Type._parse_xml(self, elm, *args) Type._parse_xml(self, module, elm, *args)
if self.name is None: if self.name is None:
raise RuntimeError('class name missing') raise RuntimeError('class name missing')
if self.short_name is None: if self.short_name is None:
@ -225,6 +228,11 @@ class EnumValue(_XmlObject):
def __init__(self): def __init__(self):
super(EnumValue, self).__init__() super(EnumValue, self).__init__()
self.name = None self.name = None
self.short_name = None
self.enum = None
def symbol_id(self):
return self.name
def _parse_attribute(self, attr, value): def _parse_attribute(self, attr, value):
if attr in ('name'): if attr in ('name'):
@ -233,10 +241,15 @@ class EnumValue(_XmlObject):
return super(EnumValue, self)._parse_attribute(attr, value) return super(EnumValue, self)._parse_attribute(attr, value)
return True return True
def _parse_xml(self, elm, *args): def _parse_xml(self, module, elm, *args):
super(EnumValue, self)._parse_xml(elm, *args) super(EnumValue, self)._parse_xml(module, elm, *args)
if self.name is None: if self.name is None:
raise RuntimeError('enum value name missing') raise RuntimeError('enum value name missing')
if not self.short_name:
self.short_name = self.name
prefix = module.name.upper() + '_'
if self.short_name.startswith(prefix):
self.short_name = self.short_name[len(prefix):]
class EnumBase(GTypedType): class EnumBase(GTypedType):
def __init__(self): def __init__(self):
@ -244,14 +257,15 @@ class EnumBase(GTypedType):
self.values = [] self.values = []
self.__value_hash = {} self.__value_hash = {}
def _parse_xml_element(self, elm): def _parse_xml_element(self, module, elm):
if elm.tag == 'value': if elm.tag == 'value':
value = EnumValue.from_xml(elm) value = EnumValue.from_xml(module, elm)
assert not value.name in self.__value_hash assert not value.name in self.__value_hash
self.__value_hash[value.name] = value self.__value_hash[value.name] = value
value.enum = self
self.values.append(value) self.values.append(value)
else: else:
super(EnumBase, self)._parse_xml_element(elm) super(EnumBase, self)._parse_xml_element(module, elm)
class Enum(EnumBase): class Enum(EnumBase):
def __init__(self): def __init__(self):
@ -269,22 +283,22 @@ class InstanceType(GTypedType):
self.static_methods = [] self.static_methods = []
self.__method_hash = {} self.__method_hash = {}
def _parse_xml_element(self, elm): def _parse_xml_element(self, module, elm):
if elm.tag == 'method': if elm.tag == 'method':
meth = Method.from_xml(elm, self) meth = Method.from_xml(module, elm, self)
assert not meth.name in self.__method_hash assert not meth.name in self.__method_hash
self.__method_hash[meth.name] = meth self.__method_hash[meth.name] = meth
self.methods.append(meth) self.methods.append(meth)
elif elm.tag == 'static-method': elif elm.tag == 'static-method':
meth = StaticMethod.from_xml(elm, self) meth = StaticMethod.from_xml(module, elm, self)
assert not meth.name in self.__method_hash assert not meth.name in self.__method_hash
self.__method_hash[meth.name] = meth self.__method_hash[meth.name] = meth
self.static_methods.append(meth) self.static_methods.append(meth)
elif elm.tag == 'constructor': elif elm.tag == 'constructor':
assert not self.constructor assert not self.constructor
self.constructor = Constructor.from_xml(elm, self) self.constructor = Constructor.from_xml(module, elm, self)
else: else:
GTypedType._parse_xml_element(self, elm) GTypedType._parse_xml_element(self, module, elm)
class Pointer(InstanceType): class Pointer(InstanceType):
def __init__(self): def __init__(self):
@ -313,22 +327,22 @@ class Class(InstanceType):
return InstanceType._parse_attribute(self, attr, value) return InstanceType._parse_attribute(self, attr, value)
return True return True
def _parse_xml_element(self, elm): def _parse_xml_element(self, module, elm):
if elm.tag == 'virtual': if elm.tag == 'virtual':
meth = VMethod.from_xml(elm, self) meth = VMethod.from_xml(module, elm, self)
assert not meth.name in self.__vmethod_hash assert not meth.name in self.__vmethod_hash
self.__vmethod_hash[meth.name] = meth self.__vmethod_hash[meth.name] = meth
self.vmethods.append(meth) self.vmethods.append(meth)
elif elm.tag == 'signal': elif elm.tag == 'signal':
meth = Signal.from_xml(elm, self) meth = Signal.from_xml(module, elm, self)
assert not meth.name in self.__signal_hash assert not meth.name in self.__signal_hash
self.__signal_hash[meth.name] = meth self.__signal_hash[meth.name] = meth
self.signals.append(meth) self.signals.append(meth)
else: else:
InstanceType._parse_xml_element(self, elm) InstanceType._parse_xml_element(self, module, elm)
def _parse_xml(self, elm, *args): def _parse_xml(self, module, elm, *args):
InstanceType._parse_xml(self, elm, *args) InstanceType._parse_xml(self, module, elm, *args)
if self.parent is None: if self.parent is None:
raise RuntimeError('class parent name missing') raise RuntimeError('class parent name missing')
if self.constructable and self.constructor: if self.constructable and self.constructor:
@ -408,6 +422,13 @@ class Module(object):
for meth in typ.signals: for meth in typ.signals:
self.__finish_parsing_method(meth, typ) self.__finish_parsing_method(meth, typ)
def __finish_parsing_enum(self, typ):
for v in typ.values:
sym_id = v.symbol_id()
if self.__symbols.get(sym_id):
raise RuntimeError('duplicate symbol %s' % sym_id)
self.__symbols[sym_id] = v
def __add_type_symbol(self, typ): def __add_type_symbol(self, typ):
sym_id = typ.symbol_id() sym_id = typ.symbol_id()
if self.__symbols.get(sym_id): if self.__symbols.get(sym_id):
@ -425,12 +446,18 @@ class Module(object):
for module in self.__import_modules: for module in self.__import_modules:
for typ in module.get_classes() + module.get_boxed() + \ for typ in module.get_classes() + module.get_boxed() + \
module.get_pointers() + module.get_enums(): module.get_pointers() + module.get_enums():
self.__add_type_symbol(typ)
self.__types[typ.name] = typ self.__types[typ.name] = typ
for sym in module.__symbols:
if self.__symbols.get(sym):
raise RuntimeError('duplicate symbol %s' % sym)
self.__symbols[sym] = module.__symbols[sym]
for typ in self.__classes + self.__boxed + self.__pointers: for typ in self.__classes + self.__boxed + self.__pointers:
self.__finish_parsing_type(typ) self.__finish_parsing_type(typ)
for typ in self.__enums:
self.__finish_parsing_enum(typ)
for func in self.__functions: for func in self.__functions:
self.__finish_parsing_method(func, None) self.__finish_parsing_method(func, None)
@ -456,29 +483,33 @@ class Module(object):
self.__finish_parsing() self.__finish_parsing()
return list(self.__functions) return list(self.__functions)
def get_symbols(self):
self.__finish_parsing()
return dict(self.__symbols)
def __parse_module_entry(self, elm): def __parse_module_entry(self, elm):
if elm.tag == 'class': if elm.tag == 'class':
cls = Class.from_xml(elm) cls = Class.from_xml(self, elm)
self.__add_type(cls) self.__add_type(cls)
self.__classes.append(cls) self.__classes.append(cls)
elif elm.tag == 'boxed': elif elm.tag == 'boxed':
cls = Boxed.from_xml(elm) cls = Boxed.from_xml(self, elm)
self.__add_type(cls) self.__add_type(cls)
self.__boxed.append(cls) self.__boxed.append(cls)
elif elm.tag == 'pointer': elif elm.tag == 'pointer':
cls = Pointer.from_xml(elm) cls = Pointer.from_xml(self, elm)
self.__add_type(cls) self.__add_type(cls)
self.__pointers.append(cls) self.__pointers.append(cls)
elif elm.tag == 'enum': elif elm.tag == 'enum':
enum = Enum.from_xml(elm) enum = Enum.from_xml(self, elm)
self.__add_type(enum) self.__add_type(enum)
self.__enums.append(enum) self.__enums.append(enum)
elif elm.tag == 'flags': elif elm.tag == 'flags':
enum = Flags.from_xml(elm) enum = Flags.from_xml(self, elm)
self.__add_type(enum) self.__add_type(enum)
self.__enums.append(enum) self.__enums.append(enum)
elif elm.tag == 'function': elif elm.tag == 'function':
func = Function.from_xml(elm) func = Function.from_xml(self, elm)
assert not func.name in self.__function_hash assert not func.name in self.__function_hash
self.__function_hash[func.name] = func self.__function_hash[func.name] = func
self.__functions.append(func) self.__functions.append(func)

View File

@ -13,6 +13,11 @@ gendocbook_files = \
$(top_srcdir)/api/mpi/module.py \ $(top_srcdir)/api/mpi/module.py \
$(top_srcdir)/api/mpi/docbookwriter.py $(top_srcdir)/api/mpi/docbookwriter.py
script_docbook_sources = \
built/script-python.docbook \
built/script-lua.docbook \
built/script-lua-gtk.docbook
$(srcdir)/built/script-python.docbook: $(gendocbook_files) script-python.tmpl.docbook $(top_srcdir)/api/moo.xml $(srcdir)/built/script-python.docbook: $(gendocbook_files) script-python.tmpl.docbook $(top_srcdir)/api/moo.xml
$(AM_V_at)$(MKDIR_P) $(srcdir)/built $(AM_V_at)$(MKDIR_P) $(srcdir)/built
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \ $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \
@ -20,10 +25,11 @@ $(srcdir)/built/script-python.docbook: $(gendocbook_files) script-python.tmpl.do
$(top_srcdir)/api/moo.xml > script-python.docbook.tmp && \ $(top_srcdir)/api/moo.xml > script-python.docbook.tmp && \
mv script-python.docbook.tmp $(srcdir)/built/script-python.docbook mv script-python.docbook.tmp $(srcdir)/built/script-python.docbook
$(srcdir)/built/script-lua.docbook: $(gendocbook_files) script-lua.tmpl.docbook $(top_srcdir)/api/moo.xml $(srcdir)/built/script-lua.docbook: $(gendocbook_files) script-lua.tmpl.docbook $(top_srcdir)/api/moo.xml $(top_srcdir)/api/gtk.xml
$(AM_V_at)$(MKDIR_P) $(srcdir)/built $(AM_V_at)$(MKDIR_P) $(srcdir)/built
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \ $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \
--lua --template $(srcdir)/script-lua.tmpl.docbook \ --lua --template $(srcdir)/script-lua.tmpl.docbook \
--import $(top_srcdir)/api/gtk.xml \
$(top_srcdir)/api/moo.xml > script-lua.docbook.tmp && \ $(top_srcdir)/api/moo.xml > script-lua.docbook.tmp && \
mv script-lua.docbook.tmp $(srcdir)/built/script-lua.docbook mv script-lua.docbook.tmp $(srcdir)/built/script-lua.docbook
@ -34,23 +40,26 @@ $(srcdir)/built/script-lua-gtk.docbook: $(gendocbook_files) script-lua-gtk.tmpl.
$(top_srcdir)/api/gtk.xml > script-lua-gtk.docbook.tmp && \ $(top_srcdir)/api/gtk.xml > script-lua-gtk.docbook.tmp && \
mv script-lua-gtk.docbook.tmp $(srcdir)/built/script-lua-gtk.docbook mv script-lua-gtk.docbook.tmp $(srcdir)/built/script-lua-gtk.docbook
$(srcdir)/help/script-python.html: built/script-python.docbook built/medit-defines.ent script.xsl # $(srcdir)/help/script-python.html: built/script-python.docbook built/medit-defines.ent script.xsl
$(AM_V_at)$(MKDIR_P) $(srcdir)/help/ # $(AM_V_at)$(MKDIR_P) $(srcdir)/help/
$(AM_V_GEN)xsltproc --output script-python.html.tmp \ # $(AM_V_GEN)xsltproc --output script-python.html.tmp \
$(srcdir)/script.xsl $(srcdir)/built/script-python.docbook \ # $(srcdir)/script.xsl $(srcdir)/built/script-python.docbook \
&& mv script-python.html.tmp $(srcdir)/help/script-python.html # && mv script-python.html.tmp $(srcdir)/help/script-python.html
#
# $(srcdir)/help/script-lua.html: built/script-lua.docbook built/medit-defines.ent script.xsl
# $(AM_V_at)$(MKDIR_P) $(srcdir)/help/
# $(AM_V_GEN)xsltproc --output script-lua.html.tmp \
# $(srcdir)/script.xsl $(srcdir)/built/script-lua.docbook \
# && mv script-lua.html.tmp $(srcdir)/help/script-lua.html
#
# $(srcdir)/help/script-lua-gtk.html: built/script-lua-gtk.docbook built/medit-defines.ent script.xsl
# $(AM_V_at)$(MKDIR_P) $(srcdir)/help/
# $(AM_V_GEN)xsltproc --output script-lua-gtk.html.tmp \
# $(srcdir)/script.xsl $(srcdir)/built/script-lua-gtk.docbook \
# && mv script-lua-gtk.html.tmp $(srcdir)/help/script-lua-gtk.html
$(srcdir)/help/script-lua.html: built/script-lua.docbook built/medit-defines.ent script.xsl $(srcdir)/help/script/index.html: $(script_docbook_sources) script-book.xsl
$(AM_V_at)$(MKDIR_P) $(srcdir)/help/ $(AM_V_GEN)cd $(srcdir) && xsltproc --xinclude script-book.xsl script.docbook
$(AM_V_GEN)xsltproc --output script-lua.html.tmp \
$(srcdir)/script.xsl $(srcdir)/built/script-lua.docbook \
&& mv script-lua.html.tmp $(srcdir)/help/script-lua.html
$(srcdir)/help/script-lua-gtk.html: built/script-lua-gtk.docbook built/medit-defines.ent script.xsl
$(AM_V_at)$(MKDIR_P) $(srcdir)/help/
$(AM_V_GEN)xsltproc --output script-lua-gtk.html.tmp \
$(srcdir)/script.xsl $(srcdir)/built/script-lua-gtk.docbook \
&& mv script-lua-gtk.html.tmp $(srcdir)/help/script-lua-gtk.html
$(srcdir)/help/medit.css: medit.css $(srcdir)/help/medit.css: medit.css
$(AM_V_at)$(MKDIR_P) $(srcdir)/help/ $(AM_V_at)$(MKDIR_P) $(srcdir)/help/
@ -105,9 +114,7 @@ all-am: doc
doc: \ doc: \
$(srcdir)/help/index.html \ $(srcdir)/help/index.html \
$(srcdir)/help/help.html \ $(srcdir)/help/help.html \
$(srcdir)/help/script-lua.html \ $(srcdir)/help/script/index.html \
$(srcdir)/help/script-lua-gtk.html \
$(srcdir)/help/script-python.html \
$(srcdir)/help/medit.css \ $(srcdir)/help/medit.css \
$(srcdir)/built/medit.1 \ $(srcdir)/built/medit.1 \
$(dest_png_files) \ $(dest_png_files) \

31
doc/script-book.xsl Normal file
View File

@ -0,0 +1,31 @@
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
<xsl:param name="html.stylesheet" select="'../medit.css'"/>
<xsl:output method="html" indent="yes"/>
<xsl:param name="chunker.output.indent" select="'yes'"/>
<xsl:param name="base.dir" select="'help/script/'"/>
<xsl:param name="chunk.first.sections" select="'1'"/>
<!--<xsl:param name="variablelist.as.table" select="1"/>-->
<!-- <xsl:template match="sect1">
<xsl:if test="preceding-sibling::sect1">
<hr/>
</xsl:if>
<xsl:apply-imports/>
</xsl:template>-->
<xsl:template match="sect2">
<xsl:if test="preceding-sibling::sect2">
<hr/>
</xsl:if>
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE article [ <!DOCTYPE chapter [
<!ENTITY % medit-defines SYSTEM "medit-defines.ent"> <!ENTITY % medit-defines SYSTEM "medit-defines.ent">
%medit-defines; %medit-defines;
]> ]>
<article> <chapter id="chapter-script-lua-gtk">
<title>&medit; Gtk API for Lua scripts</title> <title>&medit; Gtk API for Lua scripts</title>
<sect1> <sect1>
<title>Introduction</title> <title>Introduction</title>
<para>Lua scripts running in &medit; have limited access to <para>Lua scripts running in &medit; have limited access to
<ulink url="http://www.gtk.org/">Gtk</ulink> functionality <ulink url="http://www.gtk.org/">Gtk</ulink> functionality
exposed through <code>gtk</code> package in addition to functions in exposed through <code>gtk</code> package in addition to functions in
<ulink url="script-lua.html"><code>medit</code> package</ulink>. <link linkend="chapter-script-lua"><code>moo</code> package</link>.
It is not a goal to provide complete Lua bindings for Gtk, It is not a goal to provide complete Lua bindings for Gtk,
and it is not a goal to enable creating UI in Lua scripts. and it is not a goal to enable creating UI in Lua scripts.
If there is a demand, &medit; might bind more Gtk functionality, If there is a demand, &medit; might bind more Gtk functionality,
@ -19,8 +19,8 @@ scripting language which is always available. Use Python if
you need more functionality.</para> you need more functionality.</para>
<para> <para>
Notations used in this manual are described Notations used in this manual are described
<ulink url="script-lua.html#section-notations">here</ulink>. <link linkend="section-script-lua-notations">here</link>.
</para> </para>
</sect1> </sect1>
###GENERATED### ###GENERATED###
</article> </chapter>

View File

@ -3,13 +3,13 @@
<!ENTITY % medit-defines SYSTEM "medit-defines.ent"> <!ENTITY % medit-defines SYSTEM "medit-defines.ent">
%medit-defines; %medit-defines;
]> ]>
<article> <chapter id="chapter-script-lua">
<title>&medit; Lua API</title> <title>&medit; Lua API</title>
<sect1 id="section-introduction"> <sect1 id="section-script-lua-introduction">
<title>Introduction</title> <title>Introduction</title>
<para>Lua scripts running in &medit; have access to its <para>Lua scripts running in &medit; have access to its
functionality through the <code>medit</code> package.</para> functionality through the <code>moo</code> package.</para>
<warning> <warning>
Functions which are not documented here may or may not work differently in Functions which are not documented here may or may not work differently in
the future and they may disappear without notice. Contact the author if you the future and they may disappear without notice. Contact the author if you
@ -17,7 +17,7 @@ need functions which are not present here.
</warning> </warning>
</sect1> </sect1>
<sect1 id="section-object-model"> <sect1 id="section-script-lua-object-model">
<title>&medit; object model</title> <title>&medit; object model</title>
<para>&medit; uses very simple object model where its objects are <para>&medit; uses very simple object model where its objects are
represented as user data in Lua and methods are provided via metatable represented as user data in Lua and methods are provided via metatable
@ -36,7 +36,7 @@ and <code>obj.method(args)</code>.
</note> </note>
</sect1> </sect1>
<sect1 id="section-notations"> <sect1 id="section-script-lua-notations">
<title>Notations</title> <title>Notations</title>
<para>This manual uses the following conventions:</para> <para>This manual uses the following conventions:</para>
<variablelist> <variablelist>
@ -84,4 +84,4 @@ and <code>obj.method(args)</code>.
</sect1> </sect1>
###GENERATED### ###GENERATED###
</article> </chapter>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE article [ <!DOCTYPE chapter [
<!ENTITY % medit-defines SYSTEM "medit-defines.ent"> <!ENTITY % medit-defines SYSTEM "medit-defines.ent">
%medit-defines; %medit-defines;
]> ]>
<article> <chapter id="chapter-script-python">
<title>&medit; Python API</title> <title>&medit; Python API</title>
<sect1> <sect1>
<title>Introduction</title> <title>Introduction</title>
@ -24,4 +24,4 @@ need functions which are not present here.
</warning> </warning>
</sect1> </sect1>
###GENERATED### ###GENERATED###
</article> </chapter>

18
doc/script.docbook Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?><!-- -%- indent-width:1 -%- -->
<!DOCTYPE book [
<!ENTITY % medit-defines SYSTEM "built/medit-defines.ent">
%medit-defines;
]>
<book id="medit-scripting-manual">
<bookinfo>
<title>&medit; scripting manual</title>
<date>1/22/2011</date>
<releaseinfo>&medit-version;</releaseinfo>
</bookinfo>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="built/script-lua.docbook"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="built/script-lua-gtk.docbook"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="built/script-python.docbook"/>
</book>

View File

@ -1,279 +0,0 @@
/* Generated data (by glib-mkenums) */
#include "mooedit/mooedit-enum-types.h"
#include "mooedit/mooedit-enums.h"
/**
* enum:MooEditConfigSource
**/
GType
moo_edit_config_source_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_EDIT_CONFIG_SOURCE_USER, (char*) "MOO_EDIT_CONFIG_SOURCE_USER", (char*) "user" },
{ MOO_EDIT_CONFIG_SOURCE_FILE, (char*) "MOO_EDIT_CONFIG_SOURCE_FILE", (char*) "file" },
{ MOO_EDIT_CONFIG_SOURCE_FILENAME, (char*) "MOO_EDIT_CONFIG_SOURCE_FILENAME", (char*) "filename" },
{ MOO_EDIT_CONFIG_SOURCE_LANG, (char*) "MOO_EDIT_CONFIG_SOURCE_LANG", (char*) "lang" },
{ MOO_EDIT_CONFIG_SOURCE_AUTO, (char*) "MOO_EDIT_CONFIG_SOURCE_AUTO", (char*) "auto" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooEditConfigSource", values);
}
return etype;
}
/**
* enum:MooSaveResponse
**/
GType
moo_save_response_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_SAVE_RESPONSE_CONTINUE, (char*) "MOO_SAVE_RESPONSE_CONTINUE", (char*) "continue" },
{ MOO_SAVE_RESPONSE_CANCEL, (char*) "MOO_SAVE_RESPONSE_CANCEL", (char*) "cancel" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooSaveResponse", values);
}
return etype;
}
/**
* enum:MooEditState
**/
GType
moo_edit_state_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_EDIT_STATE_NORMAL, (char*) "MOO_EDIT_STATE_NORMAL", (char*) "normal" },
{ MOO_EDIT_STATE_LOADING, (char*) "MOO_EDIT_STATE_LOADING", (char*) "loading" },
{ MOO_EDIT_STATE_SAVING, (char*) "MOO_EDIT_STATE_SAVING", (char*) "saving" },
{ MOO_EDIT_STATE_PRINTING, (char*) "MOO_EDIT_STATE_PRINTING", (char*) "printing" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooEditState", values);
}
return etype;
}
/**
* flags:MooEditStatus
**/
GType
moo_edit_status_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GFlagsValue values[] = {
{ MOO_EDIT_STATUS_NORMAL, (char*) "MOO_EDIT_STATUS_NORMAL", (char*) "normal" },
{ MOO_EDIT_STATUS_MODIFIED_ON_DISK, (char*) "MOO_EDIT_STATUS_MODIFIED_ON_DISK", (char*) "modified-on-disk" },
{ MOO_EDIT_STATUS_DELETED, (char*) "MOO_EDIT_STATUS_DELETED", (char*) "deleted" },
{ MOO_EDIT_STATUS_CHANGED_ON_DISK, (char*) "MOO_EDIT_STATUS_CHANGED_ON_DISK", (char*) "changed-on-disk" },
{ MOO_EDIT_STATUS_MODIFIED, (char*) "MOO_EDIT_STATUS_MODIFIED", (char*) "modified" },
{ MOO_EDIT_STATUS_NEW, (char*) "MOO_EDIT_STATUS_NEW", (char*) "new" },
{ MOO_EDIT_STATUS_CLEAN, (char*) "MOO_EDIT_STATUS_CLEAN", (char*) "clean" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static ("MooEditStatus", values);
}
return etype;
}
/**
* enum:MooLineEndType
**/
GType
moo_line_end_type_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_LE_NONE, (char*) "MOO_LE_NONE", (char*) "none" },
{ MOO_LE_UNIX, (char*) "MOO_LE_UNIX", (char*) "unix" },
{ MOO_LE_WIN32, (char*) "MOO_LE_WIN32", (char*) "win32" },
{ MOO_LE_MAC, (char*) "MOO_LE_MAC", (char*) "mac" },
{ MOO_LE_MIX, (char*) "MOO_LE_MIX", (char*) "mix" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooLineEndType", values);
}
return etype;
}
/**
* enum:MooTextSelectionType
**/
GType
moo_text_selection_type_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_TEXT_SELECT_CHARS, (char*) "MOO_TEXT_SELECT_CHARS", (char*) "chars" },
{ MOO_TEXT_SELECT_WORDS, (char*) "MOO_TEXT_SELECT_WORDS", (char*) "words" },
{ MOO_TEXT_SELECT_LINES, (char*) "MOO_TEXT_SELECT_LINES", (char*) "lines" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooTextSelectionType", values);
}
return etype;
}
/**
* flags:MooTextSearchFlags
**/
GType
moo_text_search_flags_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GFlagsValue values[] = {
{ MOO_TEXT_SEARCH_CASELESS, (char*) "MOO_TEXT_SEARCH_CASELESS", (char*) "caseless" },
{ MOO_TEXT_SEARCH_REGEX, (char*) "MOO_TEXT_SEARCH_REGEX", (char*) "regex" },
{ MOO_TEXT_SEARCH_WHOLE_WORDS, (char*) "MOO_TEXT_SEARCH_WHOLE_WORDS", (char*) "whole-words" },
{ MOO_TEXT_SEARCH_REPL_LITERAL, (char*) "MOO_TEXT_SEARCH_REPL_LITERAL", (char*) "repl-literal" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static ("MooTextSearchFlags", values);
}
return etype;
}
/**
* flags:MooFindFlags
**/
GType
moo_find_flags_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GFlagsValue values[] = {
{ MOO_FIND_REGEX, (char*) "MOO_FIND_REGEX", (char*) "regex" },
{ MOO_FIND_CASELESS, (char*) "MOO_FIND_CASELESS", (char*) "caseless" },
{ MOO_FIND_IN_SELECTED, (char*) "MOO_FIND_IN_SELECTED", (char*) "in-selected" },
{ MOO_FIND_BACKWARDS, (char*) "MOO_FIND_BACKWARDS", (char*) "backwards" },
{ MOO_FIND_WHOLE_WORDS, (char*) "MOO_FIND_WHOLE_WORDS", (char*) "whole-words" },
{ MOO_FIND_FROM_CURSOR, (char*) "MOO_FIND_FROM_CURSOR", (char*) "from-cursor" },
{ MOO_FIND_DONT_PROMPT, (char*) "MOO_FIND_DONT_PROMPT", (char*) "dont-prompt" },
{ MOO_FIND_REPL_LITERAL, (char*) "MOO_FIND_REPL_LITERAL", (char*) "repl-literal" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static ("MooFindFlags", values);
}
return etype;
}
/**
* flags:MooDrawWsFlags
**/
GType
moo_draw_ws_flags_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GFlagsValue values[] = {
{ MOO_DRAW_WS_NONE, (char*) "MOO_DRAW_WS_NONE", (char*) "none" },
{ MOO_DRAW_WS_SPACES, (char*) "MOO_DRAW_WS_SPACES", (char*) "spaces" },
{ MOO_DRAW_WS_TABS, (char*) "MOO_DRAW_WS_TABS", (char*) "tabs" },
{ MOO_DRAW_WS_TRAILING, (char*) "MOO_DRAW_WS_TRAILING", (char*) "trailing" },
{ 0, NULL, NULL }
};
etype = g_flags_register_static ("MooDrawWsFlags", values);
}
return etype;
}
/**
* enum:MooActionCheckType
**/
GType
moo_action_check_type_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_ACTION_CHECK_SENSITIVE, (char*) "MOO_ACTION_CHECK_SENSITIVE", (char*) "sensitive" },
{ MOO_ACTION_CHECK_VISIBLE, (char*) "MOO_ACTION_CHECK_VISIBLE", (char*) "visible" },
{ MOO_ACTION_CHECK_ACTIVE, (char*) "MOO_ACTION_CHECK_ACTIVE", (char*) "active" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooActionCheckType", values);
}
return etype;
}
/**
* enum:MooTextCursor
**/
GType
moo_text_cursor_get_type (void)
{
static GType etype;
if (G_UNLIKELY (!etype))
{
static const GEnumValue values[] = {
{ MOO_TEXT_CURSOR_NONE, (char*) "MOO_TEXT_CURSOR_NONE", (char*) "none" },
{ MOO_TEXT_CURSOR_TEXT, (char*) "MOO_TEXT_CURSOR_TEXT", (char*) "text" },
{ MOO_TEXT_CURSOR_ARROW, (char*) "MOO_TEXT_CURSOR_ARROW", (char*) "arrow" },
{ MOO_TEXT_CURSOR_LINK, (char*) "MOO_TEXT_CURSOR_LINK", (char*) "link" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("MooTextCursor", values);
}
return etype;
}
/* Generated data ends here */

View File

@ -9,9 +9,7 @@
/*** END file-production ***/ /*** END file-production ***/
/*** BEGIN enumeration-production ***/ /*** BEGIN enumeration-production ***/
/** /* @type@ @EnumName@ */
* @type@:@EnumName@
**/
/*** END enumeration-production ***/ /*** END enumeration-production ***/
/*** BEGIN value-header ***/ /*** BEGIN value-header ***/

View File

@ -1,60 +0,0 @@
/* Generated data (by glib-mkenums) */
#ifndef MOO_EDIT_ENUM_TYPES_H
#define MOO_EDIT_ENUM_TYPES_H
#include <glib-object.h>
G_BEGIN_DECLS
/* MooEditConfigSource */
GType moo_edit_config_source_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_EDIT_CONFIG_SOURCE (moo_edit_config_source_get_type ())
/* MooSaveResponse */
GType moo_save_response_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_SAVE_RESPONSE (moo_save_response_get_type ())
/* MooEditState */
GType moo_edit_state_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_EDIT_STATE (moo_edit_state_get_type ())
/* MooEditStatus */
GType moo_edit_status_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_EDIT_STATUS (moo_edit_status_get_type ())
/* MooLineEndType */
GType moo_line_end_type_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_LINE_END_TYPE (moo_line_end_type_get_type ())
/* MooTextSelectionType */
GType moo_text_selection_type_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_TEXT_SELECTION_TYPE (moo_text_selection_type_get_type ())
/* MooTextSearchFlags */
GType moo_text_search_flags_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_TEXT_SEARCH_FLAGS (moo_text_search_flags_get_type ())
/* MooFindFlags */
GType moo_find_flags_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_FIND_FLAGS (moo_find_flags_get_type ())
/* MooDrawWsFlags */
GType moo_draw_ws_flags_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_DRAW_WS_FLAGS (moo_draw_ws_flags_get_type ())
/* MooActionCheckType */
GType moo_action_check_type_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_ACTION_CHECK_TYPE (moo_action_check_type_get_type ())
/* MooTextCursor */
GType moo_text_cursor_get_type (void) G_GNUC_CONST;
#define MOO_TYPE_TEXT_CURSOR (moo_text_cursor_get_type ())
G_END_DECLS
#endif /* MOO_EDIT_ENUM_TYPES_H */
/* Generated data ends here */

View File

@ -13,6 +13,12 @@ typedef enum {
MOO_EDIT_CONFIG_SOURCE_AUTO = 40 MOO_EDIT_CONFIG_SOURCE_AUTO = 40
} MooEditConfigSource; } MooEditConfigSource;
/**
* enum:MooSaveResponse
*
* @MOO_SAVE_RESPONSE_CONTINUE:
* @MOO_SAVE_RESPONSE_CANCEL:
**/
typedef enum { typedef enum {
MOO_SAVE_RESPONSE_CONTINUE = 2, MOO_SAVE_RESPONSE_CONTINUE = 2,
MOO_SAVE_RESPONSE_CANCEL = 3 MOO_SAVE_RESPONSE_CANCEL = 3
@ -25,6 +31,17 @@ typedef enum {
MOO_EDIT_STATE_PRINTING MOO_EDIT_STATE_PRINTING
} MooEditState; } MooEditState;
/**
* enum:MooEditStatus
*
* @MOO_EDIT_STATUS_NORMAL:
* @MOO_EDIT_STATUS_MODIFIED_ON_DISK:
* @MOO_EDIT_STATUS_DELETED:
* @MOO_EDIT_STATUS_CHANGED_ON_DISK:
* @MOO_EDIT_STATUS_MODIFIED:
* @MOO_EDIT_STATUS_NEW:
* @MOO_EDIT_STATUS_CLEAN:
**/
typedef enum { typedef enum {
MOO_EDIT_STATUS_NORMAL = 0, MOO_EDIT_STATUS_NORMAL = 0,
MOO_EDIT_STATUS_MODIFIED_ON_DISK = 1 << 0, MOO_EDIT_STATUS_MODIFIED_ON_DISK = 1 << 0,
@ -35,6 +52,15 @@ typedef enum {
MOO_EDIT_STATUS_CLEAN = 1 << 4 /* doesn't prompt when it's being closed, even if it's modified */ MOO_EDIT_STATUS_CLEAN = 1 << 4 /* doesn't prompt when it's being closed, even if it's modified */
} MooEditStatus; } MooEditStatus;
/**
* enum:MooLineEndType
*
* @MOO_LE_NONE:
* @MOO_LE_UNIX:
* @MOO_LE_WIN32:
* @MOO_LE_MAC:
* @MOO_LE_MIX:
**/
typedef enum { typedef enum {
MOO_LE_NONE, MOO_LE_NONE,
MOO_LE_UNIX, MOO_LE_UNIX,
@ -74,6 +100,13 @@ typedef enum {
MOO_DRAW_WS_TRAILING = 1 << 2 MOO_DRAW_WS_TRAILING = 1 << 2
} MooDrawWsFlags; } MooDrawWsFlags;
/**
* enum:MooActionCheckType: (moo.lua 0)
*
* @MOO_ACTION_CHECK_SENSITIVE:
* @MOO_ACTION_CHECK_VISIBLE:
* @MOO_ACTION_CHECK_ACTIVE:
**/
typedef enum { typedef enum {
MOO_ACTION_CHECK_SENSITIVE, MOO_ACTION_CHECK_SENSITIVE,
MOO_ACTION_CHECK_VISIBLE, MOO_ACTION_CHECK_VISIBLE,

View File

@ -118,6 +118,9 @@ _moo_edit_tab_new (MooEdit *doc)
return tab; return tab;
} }
/**
* moo_edit_tab_get_doc:
**/
MooEdit * MooEdit *
moo_edit_tab_get_doc (MooEditTab *tab) moo_edit_tab_get_doc (MooEditTab *tab)
{ {
@ -125,6 +128,9 @@ moo_edit_tab_get_doc (MooEditTab *tab)
return tab->doc; return tab->doc;
} }
/**
* moo_edit_tab_get_views:
**/
MooEditViewArray * MooEditViewArray *
moo_edit_tab_get_views (MooEditTab *tab) moo_edit_tab_get_views (MooEditTab *tab)
{ {
@ -149,6 +155,9 @@ moo_edit_tab_get_views (MooEditTab *tab)
return views; return views;
} }
/**
* moo_edit_tab_get_active_view:
**/
MooEditView * MooEditView *
moo_edit_tab_get_active_view (MooEditTab *tab) moo_edit_tab_get_active_view (MooEditTab *tab)
{ {
@ -180,6 +189,9 @@ _moo_edit_tab_set_focused_view (MooEditTab *tab,
_moo_edit_window_set_active_tab (moo_edit_tab_get_window (tab), tab); _moo_edit_window_set_active_tab (moo_edit_tab_get_window (tab), tab);
} }
/**
* moo_edit_tab_get_window:
**/
MooEditWindow * MooEditWindow *
moo_edit_tab_get_window (MooEditTab *tab) moo_edit_tab_get_window (MooEditTab *tab)
{ {

View File

@ -5,7 +5,10 @@
G_BEGIN_DECLS G_BEGIN_DECLS
MooEdit *moo_edit_tab_get_doc (MooEditTab *tab);
MooEditViewArray *moo_edit_tab_get_views (MooEditTab *tab);
MooEditView *moo_edit_tab_get_active_view (MooEditTab *tab);
MooEditWindow *moo_edit_tab_get_window (MooEditTab *tab);
G_END_DECLS G_END_DECLS

View File

@ -152,6 +152,9 @@ moo_edit_view_focus_in (GtkWidget *widget,
} }
/**
* moo_edit_view_get_doc:
**/
MooEdit * MooEdit *
moo_edit_view_get_doc (MooEditView *view) moo_edit_view_get_doc (MooEditView *view)
{ {
@ -159,6 +162,9 @@ moo_edit_view_get_doc (MooEditView *view)
return view->priv->doc; return view->priv->doc;
} }
/**
* moo_edit_view_get_editor:
**/
MooEditor * MooEditor *
moo_edit_view_get_editor (MooEditView *view) moo_edit_view_get_editor (MooEditView *view)
{ {
@ -166,6 +172,9 @@ moo_edit_view_get_editor (MooEditView *view)
return view->priv->editor; return view->priv->editor;
} }
/**
* moo_edit_view_get_tab:
**/
MooEditTab * MooEditTab *
moo_edit_view_get_tab (MooEditView *view) moo_edit_view_get_tab (MooEditView *view)
{ {
@ -183,6 +192,9 @@ _moo_edit_view_set_tab (MooEditView *view,
view->priv->tab = tab; view->priv->tab = tab;
} }
/**
* moo_edit_view_get_window:
**/
MooEditWindow * MooEditWindow *
moo_edit_view_get_window (MooEditView *view) moo_edit_view_get_window (MooEditView *view)
{ {

View File

@ -111,11 +111,6 @@ int moo_edit_window_get_n_tabs (MooEditWindow *win
MooEditTab *moo_edit_window_get_nth_tab (MooEditWindow *window, MooEditTab *moo_edit_window_get_nth_tab (MooEditWindow *window,
guint n); guint n);
MooEdit *moo_edit_tab_get_doc (MooEditTab *tab);
MooEditViewArray *moo_edit_tab_get_views (MooEditTab *tab);
MooEditView *moo_edit_tab_get_active_view (MooEditTab *tab);
MooEditWindow *moo_edit_tab_get_window (MooEditTab *tab);
/* sinks widget */ /* sinks widget */
MooPane *moo_edit_window_add_pane (MooEditWindow *window, MooPane *moo_edit_window_add_pane (MooEditWindow *window,
const char *user_id, const char *user_id,

View File

@ -38,6 +38,7 @@
#include "mooedit/moolangmgr.h" #include "mooedit/moolangmgr.h"
#include "mooedit/mooeditfileinfo.h" #include "mooedit/mooeditfileinfo.h"
#include "mooedit/mooedit-script.h" #include "mooedit/mooedit-script.h"
#include "mooedit/mooedittab.h"
#include "plugins/support/moocmdview.h" #include "plugins/support/moocmdview.h"
#include "plugins/support/mooeditwindowoutput.h" #include "plugins/support/mooeditwindowoutput.h"

View File

@ -63,6 +63,7 @@ headers
#include "mooedit/moolangmgr.h" #include "mooedit/moolangmgr.h"
#include "mooedit/mooeditfileinfo.h" #include "mooedit/mooeditfileinfo.h"
#include "mooedit/mooedit-script.h" #include "mooedit/mooedit-script.h"
#include "mooedit/mooedittab.h"
#include "plugins/support/moocmdview.h" #include "plugins/support/moocmdview.h"
#include "plugins/support/mooeditwindowoutput.h" #include "plugins/support/mooeditwindowoutput.h"

View File

@ -20,10 +20,6 @@
#include "mooutils/mooi18n.h" #include "mooutils/mooi18n.h"
#include "mooutils/moocompat.h" #include "mooutils/moocompat.h"
/**
* enum:MooSaveChangesResponse
**/
static GtkWidget * static GtkWidget *
create_message_dialog (GtkWindow *parent, create_message_dialog (GtkWindow *parent,
GtkMessageType type, GtkMessageType type,

View File

@ -22,6 +22,13 @@
G_BEGIN_DECLS G_BEGIN_DECLS
/**
* enum:MooSaveChangesResponse
*
* @MOO_SAVE_CHANGES_RESPONSE_CANCEL:
* @MOO_SAVE_CHANGES_RESPONSE_SAVE:
* @MOO_SAVE_CHANGES_RESPONSE_DONT_SAVE:
**/
typedef enum { typedef enum {
MOO_SAVE_CHANGES_RESPONSE_CANCEL, MOO_SAVE_CHANGES_RESPONSE_CANCEL,
MOO_SAVE_CHANGES_RESPONSE_SAVE, MOO_SAVE_CHANGES_RESPONSE_SAVE,

View File

@ -3018,9 +3018,6 @@ moo_paned_is_open (MooPaned *paned)
} }
/**
* enum:MooPanePosition
*/
GType GType
moo_pane_position_get_type (void) moo_pane_position_get_type (void)
{ {

View File

@ -35,6 +35,14 @@ typedef struct _MooPaned MooPaned;
typedef struct _MooPanedPrivate MooPanedPrivate; typedef struct _MooPanedPrivate MooPanedPrivate;
typedef struct _MooPanedClass MooPanedClass; typedef struct _MooPanedClass MooPanedClass;
/**
* enum:MooPanePosition
*
* @MOO_PANE_POS_LEFT:
* @MOO_PANE_POS_RIGHT:
* @MOO_PANE_POS_TOP:
* @MOO_PANE_POS_BOTTOM:
*/
typedef enum { typedef enum {
MOO_PANE_POS_LEFT = 0, MOO_PANE_POS_LEFT = 0,
MOO_PANE_POS_RIGHT, MOO_PANE_POS_RIGHT,

View File

@ -17,10 +17,6 @@
* class:MooWindow: (parent GtkWindow) * class:MooWindow: (parent GtkWindow)
**/ **/
/**
* enum:MooCloseResponse
**/
#include "mooutils/moowindow.h" #include "mooutils/moowindow.h"
#include "mooutils/mooaction-private.h" #include "mooutils/mooaction-private.h"
#include "mooutils/mooactionbase-private.h" #include "mooutils/mooactionbase-private.h"

View File

@ -31,6 +31,12 @@ G_BEGIN_DECLS
#define MOO_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_WINDOW)) #define MOO_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_WINDOW))
#define MOO_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_WINDOW, MooWindowClass)) #define MOO_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_WINDOW, MooWindowClass))
/**
* enum:MooCloseResponse
*
* @MOO_CLOSE_RESPONSE_CONTINUE:
* @MOO_CLOSE_RESPONSE_CANCEL:
**/
typedef enum { typedef enum {
MOO_CLOSE_RESPONSE_CONTINUE = 4, MOO_CLOSE_RESPONSE_CONTINUE = 4,
MOO_CLOSE_RESPONSE_CANCEL MOO_CLOSE_RESPONSE_CANCEL

View File

@ -20,6 +20,7 @@
#include "moofileselector.h" #include "moofileselector.h"
#include "mooedit/mooplugin-macro.h" #include "mooedit/mooplugin-macro.h"
#include "mooedit/mooeditwindow.h" #include "mooedit/mooeditwindow.h"
#include "mooedit/mooedittab.h"
#include "moofileview/moobookmarkmgr.h" #include "moofileview/moobookmarkmgr.h"
#include "moofileview/moofileview-tools.h" #include "moofileview/moofileview-tools.h"
#include "plugins/mooplugin-builtin.h" #include "plugins/mooplugin-builtin.h"