Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Config.py
1| # $Id: Config.py.in,v 1.20 2003/02/01 05:33:02 chalky Exp $
2| #
3| # This file is a part of Synopsis.
4| # Copyright (C) 2000, 2001 Stefan Seefeld
5| #
6| # Synopsis is free software; you can redistribute it and/or modify it
7| # under the terms of the GNU General Public License as published by
8| # the Free Software Foundation; either version 2 of the License, or
9| # (at your option) any later version.
10| #
11| # This program is distributed in the hope that it will be useful,
12| # but WITHOUT ANY WARRANTY; without even the implied warranty of
13| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14| # General Public License for more details.
15| #
16| # You should have received a copy of the GNU General Public License
17| # along with this program; if not, write to the Free Software
18| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19| # 02111-1307, USA.
20| """Configuration script module.
21| There are a large number of command line options to control Synopsis, but
22| there are many more options than it is feasable to implement in this fashion.
23| Rather, Synopsis opts for the config file approach if you want full control
24| over the process.
25|
26| <heading>The problem</heading>
27| Synopsis is very modular, and it is desirable to separate the options from
28| different modules - something achieved by the -W flag. The modules form a
29| hierarchical structure however, with up to three levels of depth. Some modules
30| are used rarely, and the user may want different sets of settings depending on
31| what they are doing - eg: generating HTML or Docbook, parsing different
32| sections of the code, etc. We tossed about various ideas of representing
33| options in an related way, and came up with the idea of a Python script that
34| builds an object hierarchy that mirrors that of the modules.
35|
36| <heading>The Config Script</heading>
37| A config script is specified by passing the -c option to 'synopsis'. Options may
38| be passed to the script via the -Wc option, as key=value pairs. For example:
39|
40| <example>synopsis -c config.py -Wc,formatter=C++</example>
41|
42| The script is interpreted as a Python source file, and the only requirement is
43| that once loaded it have a global object called Config. This Config object is
44| usually a class which is constructed with the options dictionary to retrieve an
45| object with nested configuration objects. Every config object has at least one
46| attribute 'name', which identifies the module the object configures.
47|
48| If no config script is specified on the command line, the default class Base
49| is used, defined in this Config module. It is recommended that the Config
50| class in your config script derive from this Base class to extend it as you
51| wish.
52|
53| <heading>Modules</heading>
54| In many places modules or lists of modules can be specified to perform tasks.
55| These may be selected in one of four ways:
56|
57| 1. From a list of built-in defaults for that task as a simple string (depends
58| on attribute),
59|
60| 2. As a member of a module or package as a simple string (depends on
61| attribute),
62|
63| 3. From anywhere via a tuple of two strings: (module, class-name); for
64| example, to use the provided DOxygen Scope Sorter, you specify
65| ('Synopsis.Formatter.HTML.doxygen', 'DOScopeSorter') or to use your own
66| something like ('mymodules.py', 'ScopeSorter') - Note that ending the first
67| string in '.py' forces it to be loaded from a file, something which cannot be
68| achieved using the next method:
69|
70| 4. From anywhere via an absolute dotted reference, eg:
71| 'Synopsis.Formatter.HTML.doxygen.DOScopeSorter'.
72|
73| Of these methods, 1 or 2 are preferable for brevity and 4 for absolute
74| references, unless a filename is needed in which case you need 3.
75|
76| @see Synopsis.Config.Base
77| """
78|
79| import sys
80|
81| prefix = '/usr/local'
82|
83| class Base:
84| """The base class for configuration objects.
85| If no config script is specified on the command line, then this class is
86| instantiated directly.
87| @attr parser The parser config object to use, or None if no parsing should
88| be done. This attribute is set by __init__()
89| @attr linker The linker config object to use, or None if no linking should
90| be done. This attribute is set by __init__()
91| @attr formatter The formatter config object to use, or None if no
92| formatting should be done. This attribute is set by __init__()
93| @see Base.__init__()
94| """
95| name = 'synopsis'
96| parser = None
97| linker = None
98| formatter = None
99| class Parser:
100| """Contains nested classes for the different Parser modules.
101| @attr modules a dictionary mapping names to config objects. This
102| dictionary may be used to select an object from a command line option.
103| """
104| class IDL:
105| """Config object for the IDL parser.
106| @attr name Name of this config object: 'IDL'
107| @attr verbose Verbosity flag. This attribute is set by __init__(),
108| but only if 'verbose' was passed as a config option.
109| @attr main_file Flag that selects if should only store the AST
110| generated from the file(s) being processed, and not included
111| files. This attribute is true by default.
112| @attr basename A file path to strip from the start of all
113| filenames before storing. Setting this option will for example
114| remove any redundant parent directories in the HTML FileTree page.
115| @attr include_path A list of strings, each specifying a path to
116| add to the include path. For example: ['/usr/local/corba/']
117| @attr keep_comments If set to true (ie: 1) then comments are kept
118| in the documentation. This is true by default.
119| @see Synopsis.Parser.IDL
120| """
121| name = 'IDL'
122| keep_comments = 1
123| main_file = 1
124| def __init__(self, argv):
125| if argv.has_key('verbose'): self.verbose = 1
126| class CXX:
127| """Config object for the C++ parser.
128| @attr name Name of this config object: 'C++'
129| @attr verbose Verbosity flag. This attribute is set by __init__(),
130| but only if 'verbose' was passed as a config option.
131| @attr main_file Flag that selects if should only store the AST
132| generated from the file(s) being processed, and not included
133| files. This attribute is set by __init__ always
134| @attr basename A file path to strip from the start of all
135| filenames before storing. Setting this option for example will
136| remove any redundant parent directories in the HTML FileListing
137| page.
138| @attr include_path A list of strings, each specifying a path to
139| add to the include path. For example: ['/usr/local/corba/']
140| @attr defines A list of strings, each specifying a define to pass
141| to the preprocessor. For example: ['FOO', 'BAR=true']
142| @attr preprocessor Which preprocessor to use. Not setting this
143| causes the builtin ucpp to be used, which can track macro
144| expansions when doing SXR stuff and extract macro definitions for
145| the documentation. Setting it to 'gcc' will cause
146| gcc (well, really g++) to be used instead, for use only in cases
147| when ucpp can't parse your standard libraries (usually because of
148| compiler specific syntax).
149| @attr extract_tails If set to true, then the parser will look for
150| trailing comments before close braces. If it finds them, it will
151| create dummy declarations to hold the comments. If you set this,
152| you should probably also use the 'dummy' or 'prev' comment
153| processors in the Linker options.
154| @attr storage If set, this must be a string which defines the file
155| to store links into. Setting this also causes the parser to look
156| more carefully at the input file, so that it can generate the
157| links from inside blocks of code (otherwise it skips over them).
158| Note that you usually set this from the command-line with your
159| Makefile via "-Wp,-s,$@.links" or something. (deprecated)
160| @attr syntax_prefix If set, must be a string which defines a
161| prefix to store syntax info into. The source filenames are
162| appended to the prefix to create the output filename, so it should
163| be a directory name to avoid clashes (there is no suffix!). For
164| example, if your file is "src/foo.cc" and prefix is "syn/" then
165| the syntax information will be stored in "syn/src/foo.cc".
166| @attr xref_prefix If set, must be a string which defines a prefix
167| to store xref info into. See syntax_prefix.
168| @attr syntax_file If set, must be a string with the file to store
169| syntax info into. Note that the syntax info can only hold syntax
170| information about one source file, so this option is of limited
171| use.
172| @attr xref_file If set, must be a string with the file to store
173| xref info into. Note that the xref info can only hold xref
174| information about one source file, so this option is of limited
175| yse.
176| @attr fake_std If set, this causes the parser to construct a fake
177| using directive from the std namespace to the global namespace. In
178| effect, this fixes problems seen with using the stdc++ headers for
179| gcc 2.95.x where most things dont get placed in the std namespace.
180| @attr multiple_files If set to true then the parser handles
181| multiple files included from the main file at the same time. This
182| option can only be used with the Project file. If syntax_prefix or
183| xref_prefix is set then the extra files will get syntax and xref
184| info recorded into the appropriate files. Only one AST is output,
185| but it is as if the ASTs for the individual files were already
186| linked. To use this option, your Project file must have a single
187| SourceAction connected to this ParserAction. The SourceAction
188| should have a Simple rule first which is the main sourcefile, and
189| any number of other rules to select other files to record the AST
190| for.
191| @see Synopsis.Parser.C++.__init__
192| """
193| name = 'C++'
194| include_path = []
195| def __init__(self, argv):
196| if argv.has_key('verbose'): self.verbose = 1
197| if not hasattr(self, 'main_file'):
198| self.main_file = 1
199| class Python:
200| """Config object for the Python parser.
201| @attr name Name of this config object: 'Python'
202| @attr verbose Verbosity flag. This attribute is set by __init__(),
203| but only if 'verbose' was passed as a config option.
204| @attr basename A file path to strip from the start of all
205| filenames before storing. Setting this option for example will
206| remove any redundant parent directories in the HTML FileListing
207| page.
208| @see Synopsis.Parser.Python
209| """
210| name = 'Python'
211| def __init__(self, argv):
212| if argv.has_key('verbose'): self.verbose = 1
213| self.main_file = 1
214|
215| modules = {'C++': CXX,
216| 'IDL': IDL,
217| 'Python': Python}
218|
219| class Linker:
220| """Contains nested classes for the Linker modules. Currently there is
221| just Linker.
222| @attr modules Dictionary mapping names to nested classes
223| @see Synopsis.Linker
224| @see Synopsis.Linker.Linker The main linker module
225| @see Synopsis.Linker.Comments The comment linker module
226| """
227| class Linker:
228| """Config for the main linker module. The linker performs various
229| options on an AST, including some which are essential when merging
230| multiple AST's.
231|
232| @attr verbose Boolean value indicating whether to print extra
233| information on what's going on. Can be useful for debugging
234| problems
235| @attr strip A list of strings, where each string is a scoped name
236| to strip from the front of declarations. If this list is not
237| empty, any declaration not matching one of the strip names will be
238| removed from the AST. The default is [], but an example is
239| ['boost::python'].
240| @attr mapper_list A list of mappers (?)
241| @attr max_access Maximum access level to permit - any declaration
242| with a lower accessibility (higher access level) will be removed. The
243| default is None, which disables the operation. Possible values are
244| 1 for public (only public members shown), 2 for protected (only
245| public and protected shown)
246| @attr map_declaration_names Prepends some namespace onto each name
247| in the AST. This is used for example by the Synopsis RefManual to
248| place all C++ code in the Synopsis.Parser.C++ package. The value
249| should be a tuple of two strings - the namespace separated by ::'s
250| and the type of module to use (eg: Module or Package). The default
251| value is None.
252| @attr map_declaration_type The type (string) of the declarations
253| inserted when mapping declarations.
254| @attr operations The list of operations to perform on the AST. The
255| default is ['Unduplicator', 'Stripper', 'NameMapper', 'Comments',
256| 'EmptyNS', 'AccessRestrictor']. Others include 'LanguageMapper'
257| and 'XRefCompiler'.
258| @attr comment_processors a list of processors to use which use
259| declaration comments to perform actions. The default is an empty
260| list, but an example minimum you would use is ['ssd', 'summary'].
261| The processors are: (note that any you do use should be in this
262| order!): ssd: removes any comment not in the "//." style and
263| removes the prefix. ss: removes any comment not in the "//" style
264| and removes the prefix. java: removes any comment not in Java's
265| "/** */" style and removes the prefix. dummy: removes dummy
266| declarations from the C++ parser. prev: extends dummy to move
267| comments that belong to the previous declaration (comments that
268| begin with "<") summary: extracts a summary from comments, needed
269| for normal documentation. javatags: extracts JavaDoc-style tags
270| from comments, needed to display things like @param and @return
271| properly.
272| """
273| name = 'Linker'
274| verbose = 0
275| strip = []
276| mapper_list = []
277| max_access = None
278| map_declaration_names = None
279| map_declaration_type = 'Language'
280| comment_processors = []
281| operations = [
282| 'Unduplicator', 'Stripper', 'NameMapper',
283| 'Comments', 'EmptyNS', 'AccessRestrictor'
284| ] # Off by default: LanguageMapper, XRefCompiler
285| class XRefCompiler:
286| """This is the config object for the XRefCompiler module.
287|
288| XRefCompiler compiles the text-based xref files generated by
289| the C++ parser into a single pickled python datastructure.
290| This data structure can then be used by HTML formatter for
291| generating cross-reference info, or by external search tools.
292|
293| @attr xref_path A string with one %s, which when replaced with the
294| 'filename()' attribute of a declaration (ie: filename with the
295| basepath stripped from it by the parser) will give the input
296| xref filename for that file. The default is './%s-xref'.
297| @attr xref_file A string with the filename of the output xref
298| file. The default is 'compiled.xref'
299| @see Synopsis.Formatter.HTML.FileSource
300| """
301| xref_path = './%s-xref'
302| xref_file = 'compiled.xref'
303| def __init__(self, argv):
304| if argv.has_key('verbose'): self.verbose = 1
305|
306| modules = {'Linker': Linker}
307|
308| class Formatter:
309| """Contains nested classes for the different Formatter modules.
310| @attr modules a dictionary mapping names to config objects. This
311| dictionary may be used to select an object from a command line option.
312| """
313| class HTML:
314| """Config object for HTML Formatter.
315| This is the most complicated config object, because the HTML
316| formatter is itself very modular and flexible, allowing the user
317| to customise output at many levels. All this flexibility comes at
318| a price however - but if you read this (and send feedback to the
319| Synopsis developers) then it should get easier.
320| @attr name The name of the module, ie: 'HTML'
321| @attr stylesheet The filename of the stylesheet file linked to by all
322| generated pages.
323| @attr stylesheet_file Specifies a file which is read and written
324| over the stylesheet file in the output directory. It is only
325| copied if it has a newer timestamp than the existing stylesheet
326| file. The default is the file html.css installed in Synopsis'
327| share directory.
328| @attr pages Lists the names of page modules to load and process in
329| order. Each module generates a different type of output, and some
330| register names to be shown as a link at the top of every page. For
331| example, ScopePages generates the pages for Classes, Modules, etc.
332| ModuleIndexer creates the index pages for all the modules that
333| usually go in the bottom-left frame. FramesIndex creates the
334| index.html with the frames. The default is ['ScopePages',
335| 'ModuleListingJS', 'ModuleIndexer', 'FileTreeJS',
336| 'InheritanceTree', 'InheritanceGraph', 'NameIndex', 'FramesIndex']
337| @attr comment_formatters Lists the formatters to be applied to
338| all comments. The default is ['javadoc', 'section'].
339| Javadoc formats
340| javadoc-style @tags. Section splits blank lines into paragraph
341| breaks. The quotehtml formatter quotes any html characters such as
342| angle brackets and ampersands, such as comments that mention C++
343| templates. This also has the effect of disabling any HTML in the
344| comments, and so is off by default.
345| @attr sorter Specifies the Sorter to be used to sort declarations
346| on Scope Pages. You may set this to override the default sorting,
347| for example using ('Synopsis.Formatter.HTML.doxygen',
348| 'DOScopeSorter')
349| @attr structs_as_classes A boolean value which if set causes
350| structs to be listed as classes in the output. The default is
351| 0 (false).
352| @attr tree_formatter Specifies which tree formatter to use. There
353| is a default package of 'Synopsis.Formatter.HTML' and the default
354| value is 'TreeFormatter.TreeFormatter'
355| @attr file_layout Specifies the file layout to use. This must be a
356| class that implements the FileLayout interface defined in the
357| HTML.FileLayout module.
358| @attr output_dir Specifies the base output directory for generated
359| files. May be an absolute or relative path, but absolute will
360| probably work better in larger projects with TOC references. If
361| this option is not set, the -o argument must be used when running
362| Synopsis. Simple example: 'output/html'
363| @see Synopsis.Formatter.HTML The HTML Formatter
364| @see Synopsis.Formatter.HTML.core The main HTML module
365| """
366| name = 'HTML'
367| # Defaults
368| datadir = prefix + '/share/synopsis'
369| stylesheet = 'style.css'
370| stylesheet_file = datadir + '/html.css'
371| file_layout = 'Synopsis.Formatter.HTML.FileLayout.FileLayout'
372| pages = ['FramesIndex',
373| 'ScopePages',
374| 'ModuleListing',
375| 'ModuleIndexer',
376| 'FileListing',
377| 'FileIndexer',
378| 'FileDetails',
379| 'InheritanceTree',
380| 'InheritanceGraph',
381| 'NameIndex',
382| 'FramesIndex']
383| comment_formatters = ['javadoc', 'section']
384| tree_formatter = 'TreeFormatter.TreeFormatter'
385| structs_as_classes = 0
386| class FileSource:
387| """This is the config object for the FileSource module.
388| FileSource creates html pages that contain the actual source
389| code for the program, which depending on the language may be
390| highlighted and hyperlinked. Currently only the C++ parser
391| provides this - other languages are displayed without
392| formatting.
393|
394| The formatting information is stored in a '.links'
395| file for each input file, and since the location is specific
396| to your project you must set this here, and FileSource is not
397| in the default list of Page modules to use.
398|
399| @attr file_path A string with one %s, which when replaced with the
400| 'filename()' attribute (ie: filename with the basepath
401| stripped from it by the parser) will give the input filename.
402| The default is './%s'.
403| @attr links_path is the same as file_path, but must give the
404| 'links' file. The default is './%s-links'
405| @attr toc_files is a list of '.toc' files to load and use to
406| link references from the file.
407| @attr scope is the base scope to prepend to all names for
408| looking up in the TOC. Eg: the RefManual for Synopsis maps all
409| C++ things to Synopsis::Parser::C++::, so that string must be
410| set here and prepended to all names to look up in the TOC.
411| @see Synopsis.Formatter.HTML.FileSource
412| """
413| file_path = './%s'
414| links_path = './%s-links'
415| toc_files = []
416| scope = ''
417| # Old name for FileSource:
418| FilePages = FileSource
419| class FileTree:
420| """Config object for the FileTree module.
421| FileTree creates a page with a tree of filenames, for use in
422| the top-left frame.
423| @attr link_to_pages If true, then links are generated to the
424| hyperlinked source files.
425| @see Synopsis.Formatter.HTML.FileTree
426| """
427| link_to_pages = 0
428| class ScopePages:
429| """Config for ScopePages module. ScopePages is the module that
430| creates the bulk of the documentation - the pages for modules
431| and classes, with summary and detail sections for each type of
432| ast node. ScopePages is very modular, and all the modules it
433| uses are in the ASTFormatter and FormatStrategy modules, which
434| is where it looks if you use the 'simple' module spec.
435| (FIXME)
436|
437| @param parts modules to use to generate parts of each page.
438| The default package is Synopsis.Formatter.HTML.ASTFormatter
439| and the default list is 'Heading','Summary', and 'Detail'
440|
441| @param heading_formatters list of modules for Heading page
442| Part. The default is 'Heading', 'ClassHierarchyGraph', and
443| 'DetailCommenter'.
444|
445| @param summary_formatters list of modules for SummaryFormatter
446| to use. The default is ['SummaryAST', 'SummaryCommenter']
447|
448| @param detail_formatters list of modules for DetailFormatter
449| to use. The default is ['DetailAST',
450| 'ClassHierarchyGraph', 'DetailCommenter']. Note that it is
451| these modules that are used to display the top of the class
452| and module pages (hence the ClassHierarchyGraph module, which
453| shows class hierarchies at the top of class pages).
454|
455| @see Synopsis.Formatter.HTML.ScopePages
456| @see Synopsis.Formatter.HTML.ASTFormatter
457| """
458| parts = [
459| 'Heading',
460| 'Summary',
461| 'Inheritance',
462| 'Detail'
463| ]
464| heading_formatters = [
465| 'Heading',
466| 'ClassHierarchyGraph',
467| 'DetailCommenter'
468| ]
469| summary_formatters = [
470| 'SummaryAST',
471| 'SummaryCommenter'
472| ]
473| detail_formatters = [
474| 'DetailAST',
475| 'DetailCommenter'
476| ]
477| class InheritanceGraph:
478| """Config for InheritanceGraph module.
479| @attr min_size Minimum size of graphs to be included in
480| output. The default setting is 1, which means all classes will
481| be included. A setting of three means that only hierarchies
482| consisting of three or more classes will be included.
483| @attr min_group_size Minimum grouping size of graphs. The graph is
484| split into subgraphs because graphviz can makes graphs tens of
485| thousands of pixels wide otherwise. The time to process the
486| graphs is proportional to the number of times graphviz is run,
487| so setting this attribute will attempt to group smaller graphs
488| into larger graphs with a minimum number of nodes. The default
489| is 5.
490| @attr direction Can be either 'horizontal' or 'vertical'.
491| Specified the direction of inheritance in the inheritance
492| graphs. The default is 'vertical'.
493| @see Synopsis.Formatter.HTML.InheritanceGraph.InheritanceGraph
494| """
495| min_size = 1
496| min_group_size = 5
497| direction = 'vertical'
498|
499| class ModuleListing:
500| """Config for ModuleListing module.
501| @attr child_types The types of children to include in the
502| module listing. Children are found by looking for Module AST
503| nodes, but their (string) type may depend on other factors
504| (eg: Python creates Package and Module types). The default is
505| to just print all Module AST nodes.
506| """
507| pass
508|
509| def __init__(self, argv):
510| """Initialise HTML config object.
511| If there is a verbose argument, then the verbose attribute is
512| set to true, causing various verbose information to be printed
513| out.
514| @param argv a dictionary of key:value arguments
515| """
516| if argv.has_key('verbose'): self.verbose = 1
517|
518| class HTML_Doxygen (HTML):
519| """Doxygen-style HTML. This Config class actually derives from
520| the HTML class but overrides a few options to provide an output
521| that looks more like Doxygen's output. You may use this via
522| something like:
523| <example>synopsis -Wcformatter=HTML_Doxygen</example>
524| @see HTML The parent HTML config
525| """
526| # Doxygen-style options
527| sorter = ('Synopsis.Formatter.HTML.doxygen', 'DOScopeSorter')
528| class ScopePages:
529| """Overrides the default ScopePages with doxygen modules."""
530| summarizer = ('Synopsis.Formatter.HTML.doxygen', 'DOSummary')
531| detailer = ('Synopsis.Formatter.HTML.doxygen', 'DODetail')
532| summary_formatters = [
533| ('Synopsis.Formatter.HTML.doxygen', 'DOSummaryAST'),
534| ('Synopsis.Formatter.HTML.doxygen', 'PreSummaryDiv'),
535| ('Synopsis.Formatter.HTML.doxygen', 'DOSummaryCommenter'),
536| ('Synopsis.Formatter.HTML.doxygen', 'PostSummaryDiv'),
537| ]
538| detail_formatters = [
539| ('Synopsis.Formatter.HTML.doxygen', 'PreDivFormatter'),
540| ('Synopsis.Formatter.HTML.doxygen', 'DODetailAST'),
541| ('Synopsis.Formatter.HTML.doxygen', 'PostDivFormatter'),
542| ('Synopsis.Formatter.HTML.FormatStrategy', 'ClassHierarchyGraph'),
543| ('Synopsis.Formatter.HTML.FormatStrategy', 'DetailCommenter'),
544| ]
545|
546| class DocBook:
547| name = 'DocBook'
548| def __init__(self, argv): pass
549|
550| class BoostBook:
551| name = 'BoostBook'
552| def __init__(self, argv): pass
553|
554| class TexInfo:
555| name = 'TexInfo'
556| def __init__(self, argv): pass
557|
558| class Dot:
559| name = 'Dot'
560| def __init__(self, argv): pass
561|
562| class HTML_Simple:
563| name = 'HTML_Simple'
564| def __init__(self, argv): pass
565|
566| class ASCII:
567| name = 'ASCII'
568| def __init__(self, argv): pass
569|
570| class DUMP:
571| name = 'DUMP'
572| def __init__(self, argv): pass
573|
574| class Dia:
575| name = 'Dia'
576| def __init__(self, argv): pass
577|
578| modules = {
579| 'HTML': HTML, 'DocBook':DocBook, 'TexInfo':TexInfo, 'Dot':Dot,
580| 'HTML_Simple':HTML_Simple, 'ASCII':ASCII,
581| 'DUMP':DUMP, 'Dia':Dia,
582| 'HTML_Doxygen':HTML_Doxygen,
583| 'BoostBook':BoostBook
584| }
585|
586| def __init__(self, argv):
587| """Initialise the Config object.
588| The argv dictionary is used to fill in the attributes 'parser',
589| 'linker' and 'formatter'. For example, if the dictionary contains a
590| parser argument, then its value is used to select the parser to use
591| by setting self.parser to the config object for that parser. The
592| modules are selected from the 'modules' dictionary attribute of the
593| Parser, Linker and Formatter nested classes.
594| @param argv A dictionary of keyword arguments passed to synopsis via
595| -Wc
596| """
597| self.parser = None
598| if 'parser' in argv.keys():
599| parser = argv['parser']
600| try:
601| parsers = self.Parser.modules
602| self.parser = parser and \
603| parsers[parser](argv) or \
604| parsers.values()[0](argv)
605| except KeyError:
606| sys.stderr.write("Synopsis.Config: parser '" + parser + "' unknown\n")
607| sys.exit(-1)
608| self.linker = None
609| if 'linker' in argv.keys():
610| linker = argv['linker']
611| try:
612| linkers = self.Linker.modules
613| self.linker = linker and \
614| linkers[linker](argv) or \
615| linkers.values()[0](argv)
616| except KeyError:
617| sys.stderr.write("Synopsis.Config: linker '" + linker + "' unknown\n")
618| sys.exit(-1)
619| self.formatter = None
620| if 'formatter' in argv.keys():
621| formatter = argv['formatter']
622| try:
623| formatters = self.Formatter.modules
624| self.formatter = formatter and \
625| formatters[formatter](argv) or \
626| formatters.values()[0](argv)
627| except KeyError:
628| sys.stderr.write("Synopsis.Config: formatter '" + formatter + "' unknown\n")
629| sys.exit(-1)