diff --git a/api/gendocbook.py b/api/gendocbook.py index fa0aa4bf..1084730e 100644 --- a/api/gendocbook.py +++ b/api/gendocbook.py @@ -9,6 +9,7 @@ from mpi.docbookwriter import Writer op = optparse.OptionParser() op.add_option("--python", action="store_true") op.add_option("--lua", action="store_true") +op.add_option("--template", action="store") (opts, args) = op.parse_args() assert len(args) == 1 @@ -19,4 +20,4 @@ elif opts.lua: mode = 'lua' mod = Module.from_xml(args[0]) -Writer(mode, sys.stdout).write(mod) +Writer(mode, opts.template, sys.stdout).write(mod) diff --git a/api/mpi/docbookwriter.py b/api/mpi/docbookwriter.py index dd7dd2fd..d9c66941 100644 --- a/api/mpi/docbookwriter.py +++ b/api/mpi/docbookwriter.py @@ -3,19 +3,6 @@ import StringIO from mpi.util import * from mpi.module import * -tmpl_file_start = """\ - - -%medit-defines; -]> -
-""" - -tmpl_file_end = """\ -
-""" - lua_constants = { 'NULL': 'nil', 'TRUE': 'true', @@ -45,10 +32,12 @@ def name_all_caps(cls): return '_'.join([s.upper() for s in split_camel_case_name(cls.name)]) class Writer(object): - def __init__(self, mode, out): + def __init__(self, mode, template, out): super(Writer, self).__init__() - self.out = out + self.file = out + self.out = StringIO.StringIO() self.mode = mode + self.template = template if mode == 'python': self.constants = python_constants elif mode == 'lua': @@ -235,8 +224,6 @@ class Writer(object): def write(self, module): self.module = module - self.out.write(tmpl_file_start) - for cls in module.get_classes() + module.get_boxed() + module.get_pointers(): self.__write_class(cls) @@ -250,6 +237,9 @@ class Writer(object): self.out.write('\n') - self.out.write(tmpl_file_end) + content = self.out.getvalue() + template = open(self.template).read() + self.file.write(template.replace('###GENERATED###', content)) + del self.out del self.module diff --git a/doc/Makefile.am b/doc/Makefile.am index 975ec79b..9604f6da 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -12,17 +12,23 @@ gendocbook_files = \ $(top_srcdir)/api/mpi/module.py \ $(top_srcdir)/api/mpi/docbookwriter.py -$(srcdir)/script-python.docbook: $(gendocbook_files) $(top_srcdir)/api/moo.xml - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py --python $(top_srcdir)/api/moo.xml \ - > script-python.docbook.tmp && mv script-python.docbook.tmp $(srcdir)/script-python.docbook +$(srcdir)/script-python.docbook: $(gendocbook_files) script-python.tmpl.docbook $(top_srcdir)/api/moo.xml + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \ + --python --template $(srcdir)/script-python.tmpl.docbook \ + $(top_srcdir)/api/moo.xml > script-python.docbook.tmp && \ + mv script-python.docbook.tmp $(srcdir)/script-python.docbook -$(srcdir)/script-lua.docbook: $(gendocbook_files) $(top_srcdir)/api/moo.xml - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py --lua $(top_srcdir)/api/moo.xml \ - > script-lua.docbook.tmp && mv script-lua.docbook.tmp $(srcdir)/script-lua.docbook +$(srcdir)/script-lua.docbook: $(gendocbook_files) script-lua.tmpl.docbook $(top_srcdir)/api/moo.xml + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \ + --lua --template $(srcdir)/script-lua.tmpl.docbook \ + $(top_srcdir)/api/moo.xml > script-lua.docbook.tmp && \ + mv script-lua.docbook.tmp $(srcdir)/script-lua.docbook -$(srcdir)/script-lua-gtk.docbook: $(gendocbook_files) $(top_srcdir)/api/gtk.xml - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py --lua $(top_srcdir)/api/gtk.xml \ - > script-lua-gtk.docbook.tmp && mv script-lua-gtk.docbook.tmp $(srcdir)/script-lua-gtk.docbook +$(srcdir)/script-lua-gtk.docbook: $(gendocbook_files) script-lua-gtk.tmpl.docbook $(top_srcdir)/api/gtk.xml + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/api/gendocbook.py \ + --lua --template $(srcdir)/script-lua-gtk.tmpl.docbook \ + $(top_srcdir)/api/gtk.xml > script-lua-gtk.docbook.tmp && \ + mv script-lua-gtk.docbook.tmp $(srcdir)/script-lua-gtk.docbook $(srcdir)/help/script-python.html: script-python.docbook medit-defines.ent script.xsl $(AM_V_at)$(MKDIR_P) $(srcdir)/help/ diff --git a/doc/medit.css b/doc/medit.css index 7981e489..be16704e 100644 --- a/doc/medit.css +++ b/doc/medit.css @@ -87,10 +87,10 @@ hr { margin-top: 0.0em } -.note p, .warning p +/*.note p, .warning p { margin-bottom: 0.0em -} +}*/ /* blob links */ h2 .extralinks, h3 .extralinks diff --git a/doc/script-lua-gtk.tmpl.docbook b/doc/script-lua-gtk.tmpl.docbook new file mode 100644 index 00000000..6289f0b7 --- /dev/null +++ b/doc/script-lua-gtk.tmpl.docbook @@ -0,0 +1,26 @@ + + +%medit-defines; +]> +
+&medit; Gtk API for Lua scripts + +Introduction +Lua scripts running in &medit; have limited access to +Gtk functionality +exposed through gtk package in addition to functions in +medit package. +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. +If there is a demand, &medit; might bind more Gtk functionality, +but so far Lua in &medit; is supposed to be lean and mean +scripting language which is always available. Use Python if +you need more functionality. + +Notations used in this manual are described +here. + + +###GENERATED### +
diff --git a/doc/script-lua.tmpl.docbook b/doc/script-lua.tmpl.docbook new file mode 100644 index 00000000..c4d2f6e5 --- /dev/null +++ b/doc/script-lua.tmpl.docbook @@ -0,0 +1,87 @@ + + +%medit-defines; +]> +
+&medit; Lua API + + +Introduction +Lua scripts running in &medit; have access to its +functionality through the medit package. + +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 +need functions which are not present here. + + + + +&medit; object model +&medit; uses very simple object model where its objects are +represented as user data in Lua and methods are provided via metatable +shared by all objects of all "classes". Method dispatch is dynamic, +i.e. metatable does not contain functions which correspond to methods, +and obj:method returns a function object which knows which +method on which object it is going to call. +This manual lists and talks about "classes", but it is merely +to avoid complicated terminology. When we say that an object belongs +to or is an instance of a class Foo, it just means that +it has methods listed in manual section for class Foo +and methods of parent classes, if any. + +To call a method, you can use both obj:method(args) +and obj.method(args). + + + + +Notations +This manual uses the following conventions: + + + func() and func(nil) are equivalent. + There is no distinction between nil value + of a parameter and missing parameter, unless documentation for given function + says otehrwise. + + + + Optional parameters + + func(arg1=val1, arg2=val, arg3=val3, ...) + arg=val means that + parameter arg is optional, and function receives + value val if it's missing or nil. + Not all parameters are necessarily optional. For example, + insert_text(text, where=nil) + means that text may not be missing or nil + (unless documentation says otherwise), and where is optional. + + + + Keyword parameters + + func{arg1, arg2=val2} + This means that function takes a single table parameter, and + table must be a dictionary with keys arg1, + arg2, etc. Similar to regular parameters, + arg=val means that + arg is optional. + + + + Dictionary parameters + + func(arg1, arg2, {arg3, arg4=val}) + {} denote a parameter which must be a table with given keys, + similar to keyword parameters (the difference is that with keyword parameters + function takes a single table argument). + + + + + +###GENERATED### +
diff --git a/doc/script-python.tmpl.docbook b/doc/script-python.tmpl.docbook new file mode 100644 index 00000000..922f217b --- /dev/null +++ b/doc/script-python.tmpl.docbook @@ -0,0 +1,27 @@ + + +%medit-defines; +]> +
+&medit; Python API + +Introduction +When compiled with Python support, &medit; uses +PyGtk. Its functionality is +exposed through moo module. You can use built-in Python console +available from Tools to experiment with &medit; API. + +Classes and functions documented here are guaranteed to work as long as you +follow the rules from their documentation (most often there are no special +rules, but for some functions you may only use named arguments, etc.) + + +moo module has more classes and functions than documented here, +but undocumented classes and functions may or may not work differently in +the future and they may disappear without notice. Contact the author if you +need functions which are not present here. + + +###GENERATED### +