summaryrefslogtreecommitdiff
path: root/giscanner/docmain.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2011-02-01 16:12:30 -0200
committerLaszlo Pandy <lpandy@src.gnome.org>2011-08-11 10:29:23 +0200
commit6a0a3f54db9a20cad02e954355cfb93ded1eb4dd (patch)
treeee2f588601bcc3a0b8b4cead722594107b71a31f /giscanner/docmain.py
parentd19fcd098ed69d9216efbf68fc8ae4ba57d09638 (diff)
downloadgobject-introspection-6a0a3f54db9a20cad02e954355cfb93ded1eb4dd.tar.gz
WIP doctool
https://bugzilla.gnome.org/show_bug.cgi?id=625494
Diffstat (limited to 'giscanner/docmain.py')
-rw-r--r--giscanner/docmain.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
new file mode 100644
index 00000000..8e54d7ad
--- /dev/null
+++ b/giscanner/docmain.py
@@ -0,0 +1,66 @@
+# -*- Mode: Python -*-
+# GObject-Introspection - a framework for introspecting GObject libraries
+# Copyright (C) 2008-2011 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.
+#
+
+import optparse
+
+from .docbookwriter import DocBookWriter
+from .girparser import GIRParser
+
+class GIDocGenerator(object):
+
+ def parse(self, filename):
+ self.parser = GIRParser()
+ self.parser.parse(filename)
+
+ def generate(self, writer, output):
+ ns = self.parser.get_namespace()
+ writer.add_namespace(ns)
+ writer.write(output)
+
+
+def doc_main(args):
+ parser = optparse.OptionParser('%prog [options] sources')
+
+ parser.add_option("-o", "--output",
+ action="store", dest="output",
+ help="Filename to write output")
+ parser.add_option("-f", "--format",
+ action="store", dest="format",
+ default="docbook",
+ help="Output format")
+
+ options, args = parser.parse_args(args)
+ if not options.output:
+ raise SystemExit("missing output parameter")
+
+ if len(args) < 2:
+ raise SystemExit("Need an input gir filename")
+
+ if options.format == "docbook":
+ writer = DocBookWriter()
+ else:
+ raise SystemExit("Unsupported output format: %s" % (options.format, ))
+
+ generator = GIDocGenerator()
+ generator.parse(args[1])
+
+ generator.generate(writer, options.output)
+
+ return 0