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 GtkDocCommentBlockParser, GtkDocCommentBlockWriter
25 from giscanner.scannermain import (get_preprocessor_option_group,
26 create_source_scanner,
30 def annotation_main(args):
31 parser = optparse.OptionParser('%prog [options] sources')
33 group = optparse.OptionGroup(parser, "Tool modes, one is required")
34 group.add_option("-e", "--extract",
35 action="store_true", dest="extract",
36 help="Extract annotations from the input files")
37 parser.add_option_group(group)
39 group = get_preprocessor_option_group(parser)
40 group.add_option("-L", "--library-path",
41 action="append", dest="library_paths", default=[],
42 help="directories to search for libraries")
43 group.add_option("", "--pkg",
44 action="append", dest="packages", default=[],
45 help="pkg-config packages to get cflags from")
46 parser.add_option_group(group)
48 options, args = parser.parse_args(args)
50 if not options.extract:
51 raise SystemExit("ERROR: Nothing to do")
54 process_packages(options, options.packages)
56 logger = message.MessageLogger.get(namespace=None)
58 ss = create_source_scanner(options, args)
61 parser = GtkDocCommentBlockParser()
62 writer = GtkDocCommentBlockWriter(indent=False)
63 blocks = parser.parse_comment_blocks(ss.get_comments())
64 print '/' + ('*' * 60) + '/'
65 print '/* THIS FILE IS GENERATED DO NOT EDIT */'
66 print '/' + ('*' * 60) + '/'
68 for block in sorted(blocks.values()):
69 print writer.write(block)
72 print '/' + ('*' * 60) + '/'
73 print '/* THIS FILE IS GENERATED DO NOT EDIT */'
74 print '/' + ('*' * 60) + '/'