2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2010 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 giscanner import message
24 from giscanner.annotationparser import AnnotationParser
25 from giscanner.scannermain import (get_preprocessor_option_group,
26 create_source_scanner,
29 def annotation_main(args):
30 parser = optparse.OptionParser('%prog [options] sources')
32 group = optparse.OptionGroup(parser, "Tool modes, one is required")
33 group.add_option("-e", "--extract",
34 action="store_true", dest="extract",
35 help="Extract annotations from the input files")
36 parser.add_option_group(group)
38 group = get_preprocessor_option_group(parser)
39 group.add_option("-L", "--library-path",
40 action="append", dest="library_paths", default=[],
41 help="directories to search for libraries")
42 group.add_option("", "--pkg",
43 action="append", dest="packages", default=[],
44 help="pkg-config packages to get cflags from")
45 parser.add_option_group(group)
47 options, args = parser.parse_args(args)
49 if not options.extract:
50 raise SystemExit("ERROR: Nothing to do")
53 process_packages(options, options.packages)
55 logger = message.MessageLogger.get(namespace='')
57 ss = create_source_scanner(options, args)
60 ap = AnnotationParser()
61 blocks = ap.parse(ss.get_comments())
62 print '/' + ('*' * 60) + '/'
63 print '/* THIS FILE IS GENERATED DO NOT EDIT */'
64 print '/' + ('*' * 60) + '/'
66 for block in blocks.values():
67 print block.to_gtk_doc()
70 print '/' + ('*' * 60) + '/'
71 print '/* THIS FILE IS GENERATED DO NOT EDIT */'
72 print '/' + ('*' * 60) + '/'