medit/api/gendocbook.py

32 lines
803 B
Python
Raw Normal View History

2010-12-25 15:16:51 -08:00
#! /usr/bin/env python
import sys
import optparse
from mpi.module import Module
from mpi.docbookwriter import Writer
op = optparse.OptionParser()
op.add_option("--python", action="store_true")
op.add_option("--lua", action="store_true")
2010-12-28 02:17:20 -08:00
op.add_option("--template", action="store")
2011-01-22 17:40:22 -08:00
op.add_option("-i", "--import", action="append", dest="import_modules")
2010-12-25 15:16:51 -08:00
(opts, args) = op.parse_args()
assert len(args) == 1
assert bool(opts.python) + bool(opts.lua) == 1
if opts.python:
mode = 'python'
elif opts.lua:
mode = 'lua'
2011-01-22 17:40:22 -08:00
import_modules = []
if opts.import_modules:
for filename in opts.import_modules:
import_modules.append(Module.from_xml(filename))
2010-12-25 15:16:51 -08:00
mod = Module.from_xml(args[0])
2011-01-22 17:40:22 -08:00
for im in import_modules:
mod.import_module(im)
2010-12-28 02:17:20 -08:00
Writer(mode, opts.template, sys.stdout).write(mod)