2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008-2011 Johan Dahlin
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 from .docbookwriter import DocBookWriter
24 from .transformer import Transformer
26 class GIDocGenerator(object):
28 def parse(self, filename):
29 self.transformer = Transformer.parse_from_gir(filename)
31 def generate(self, writer, output):
32 writer.add_transformer(self.transformer)
36 parser = optparse.OptionParser('%prog [options] GIR-file')
38 parser.add_option("-o", "--output",
39 action="store", dest="output",
40 help="Filename to write output")
41 parser.add_option("-f", "--format",
42 action="store", dest="format",
46 options, args = parser.parse_args(args)
47 if not options.output:
48 raise SystemExit("missing output parameter")
51 raise SystemExit("Need an input GIR filename")
53 if options.format == "docbook":
54 writer = DocBookWriter()
56 raise SystemExit("Unsupported output format: %s" % (options.format, ))
58 generator = GIDocGenerator()
59 generator.parse(args[1])
61 generator.generate(writer, options.output)