Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / configgen.py
1 #!/usr/bin/python
2 # python script to generate configoptions.cpp and config.doc from config.xml
3 #
4 # Copyright (C) 1997-2015 by Dimitri van Heesch.
5 #
6 # Permission to use, copy, modify, and distribute this software and its
7 # documentation under the terms of the GNU General Public License is hereby
8 # granted. No representations are made about the suitability of this software
9 # for any purpose. It is provided "as is" without express or implied warranty.
10 # See the GNU General Public License for more details.
11 #
12 # Documents produced by Doxygen are derivative works derived from the
13 # input used in their production; they are not affected by this license.
14 #
15 import xml.dom.minidom
16 import sys
17 import re
18 import textwrap
19 from xml.dom import minidom, Node
20
21 def transformDocs(doc):
22         # join lines, unless it is an empty line
23         # remove doxygen layout constructs
24         doc = doc.strip()
25         doc = doc.replace("\n", " ")
26         doc = doc.replace("\r", " ")
27         doc = doc.replace("\t", " ")
28         doc = doc.replace("\\&", "&")
29         doc = doc.replace("(\\c ", "(")
30         doc = doc.replace("\\c ", " ")
31         doc = doc.replace("\\b ", " ")
32         doc = doc.replace("\\e ", " ")
33         doc = doc.replace("\\$", "$")
34         doc = doc.replace("\\#include ", "#include ")
35         doc = doc.replace("\\#undef ", "#undef ")
36         doc = doc.replace("-# ", "\n - ")
37         doc = doc.replace(" - ", "\n - ")
38         doc = doc.replace("\\sa", "\nSee also: ")
39         doc = doc.replace("\\par", "\n")
40         doc = doc.replace("@note", "\nNote:")
41         doc = doc.replace("\\note", "\nNote:")
42         doc = doc.replace("\\verbatim", "\n")
43         doc = doc.replace("\\endverbatim", "\n")
44         doc = doc.replace("<code>", "")
45         doc = doc.replace("</code>", "")
46         doc = doc.replace("`", "")
47         doc = doc.replace("\\<", "<")
48         doc = doc.replace("\\>", ">")
49         doc = doc.replace("\\@", "@")
50         doc = doc.replace("\\\\", "\\")
51         # \ref name "description" -> description
52         doc = re.sub('\\\\ref +[^ ]* +"([^"]*)"', '\\1', doc)
53         # \ref specials
54         # \ref <key> -> description
55         doc = re.sub('\\\\ref +doxygen_usage', '"Doxygen usage"', doc)
56         doc = re.sub('\\\\ref +extsearch', '"External Indexing and Searching"',
57                                  doc)
58         doc = re.sub('\\\\ref +external', '"Linking to external documentation"',
59                                  doc)
60         # fallback for not handled
61         doc = re.sub('\\\\ref', '', doc)
62         #<a href="address">description</a> -> description (see: address)
63         doc = re.sub('<a +href="([^"]*)" *>([^<]*)</a>', '\\2 (see: \\1)', doc)
64         # LaTeX name as formula -> LaTeX
65         doc = doc.replace("\\f$\\mbox{\\LaTeX}\\f$", "LaTeX")
66         # Other formula's (now just 2) so explicitly mentioned.
67         doc = doc.replace("\\f$2^{(16+\\mbox{LOOKUP\\_CACHE\\_SIZE})}\\f$",
68                                           "2^(16+LOOKUP_CACHE_SIZE)")
69         doc = doc.replace("\\f$2^{16} = 65536\\f$", "2^16=65536")
70         # remove consecutive spaces
71         doc = re.sub(" +", " ", doc)
72         # a dirty trick to get an extra empty line in Doxyfile documentation.
73         # <br> will be removed later on again, we need it here otherwise splitlines
74         # will filter the extra line.
75         doc = doc.replace("<br>", "\n<br>\n")
76         # a dirty trick to go to the next line in Doxyfile documentation.
77         # <br/> will be removed later on again, we need it here otherwise splitlines
78         # will filter the line break.
79         doc = doc.replace("<br/>", "\n<br/>\n")
80         #
81         doc = doc.splitlines()
82         split_doc = []
83         for line in doc:
84                 split_doc += textwrap.wrap(line, 78)
85         # replace \ by \\, replace " by \", and '  ' by a newline with end string
86         # and start string at next line
87         docC = []
88         for line in split_doc:
89                 if (line.strip() != "<br/>"):
90                         docC.append(line.strip().replace('\\', '\\\\').
91                                         replace('"', '\\"').replace("<br>", ""))
92         return docC
93
94
95 def collectValues(node):
96         values = []
97         for n in node.childNodes:
98                 if (n.nodeName == "value"):
99                         if n.nodeType == Node.ELEMENT_NODE:
100                                 if n.getAttribute('name') != "":
101                                         if n.getAttribute('show_docu') != "NO":
102                                                 name = "<code>" + n.getAttribute('name') + "</code>"
103                                                 desc = n.getAttribute('desc')
104                                                 if (desc != ""):
105                                                         name += " " + desc
106                                                 values.append(name)
107         return values
108
109
110 def addValues(var, node):
111         for n in node.childNodes:
112                 if (n.nodeName == "value"):
113                         if n.nodeType == Node.ELEMENT_NODE:
114                                 name = n.getAttribute('name')
115                                 print("  %s->addValue(\"%s\");" % (var, name))
116
117
118 def parseHeader(node,objName):
119         doc = ""
120         for n in node.childNodes:
121                 if n.nodeType == Node.ELEMENT_NODE:
122                         if (n.nodeName == "docs"):
123                                 if (n.getAttribute('doxyfile') != "0"):
124                                         doc += parseDocs(n)
125         docC = transformDocs(doc)
126         print("  %s->setHeader(" % (objName))
127         rng = len(docC)
128         for i in range(rng):
129                 line = docC[i]
130                 if i != rng - 1:  # since we go from 0 to rng-1
131                         print("              \"%s\\n\"" % (line))
132                 else:
133                         print("              \"%s\"" % (line))
134         print("             );")
135
136
137 def prepCDocs(node):
138         type = node.getAttribute('type')
139         format = node.getAttribute('format')
140         defval = node.getAttribute('defval')
141         adefval = node.getAttribute('altdefval')
142         doc = "";
143         if (type != 'obsolete'):
144                 for n in node.childNodes:
145                         if (n.nodeName == "docs"):
146                                 if (n.getAttribute('doxyfile') != "0"):
147                                         if n.nodeType == Node.ELEMENT_NODE:
148                                                 doc += parseDocs(n)
149                 if (type == 'enum'):
150                         values = collectValues(node)
151                         doc += "<br/>Possible values are: "
152                         rng = len(values)
153                         for i in range(rng):
154                                 val = values[i]
155                                 if i == rng - 2:
156                                         doc += "%s and " % (val)
157                                 elif i == rng - 1:
158                                         doc += "%s." % (val)
159                                 else:
160                                         doc += "%s, " % (val)
161                         if (defval != ""):
162                                 doc += "<br/>The default value is: <code>%s</code>." % (defval)
163                 elif (type == 'int'):
164                         minval = node.getAttribute('minval')
165                         maxval = node.getAttribute('maxval')
166                         doc += "<br/>%s: %s, %s: %s, %s: %s." % (" Minimum value", minval, 
167                                          "maximum value", maxval,
168                                          "default value", defval)
169                 elif (type == 'bool'):
170                         if (node.hasAttribute('altdefval')):
171                           doc += "<br/>%s: %s." % ("The default value is", "system dependent")
172                         else:
173                           doc += "<br/>%s: %s." % ("The default value is", "YES" if (defval == "1") else "NO")
174                 elif (type == 'list'):
175                         if format == 'string':
176                                 values = collectValues(node)
177                                 rng = len(values)
178                                 for i in range(rng):
179                                         val = values[i]
180                                         if i == rng - 2:
181                                                 doc += "%s and " % (val)
182                                         elif i == rng - 1:
183                                                 doc += "%s." % (val)
184                                         else:
185                                                 doc += "%s, " % (val)
186                 elif (type == 'string'):
187                         if format == 'dir':
188                                 if defval != '':
189                                         doc += "<br/>The default directory is: <code>%s</code>." % (
190                                                 defval)
191                         elif format == 'file':
192                                 abspath = node.getAttribute('abspath')
193                                 if defval != '':
194                                         if abspath != '1':
195                                                 doc += "<br/>The default file is: <code>%s</code>." % (
196                                                         defval)
197                                         else:
198                                                 doc += "<br/>%s: %s%s%s." % (
199                                                         "The default file (with absolute path) is",
200                                                         "<code>",defval,"</code>")
201                                 else:
202                                         if abspath == '1':
203                                                 doc += "<br/>The file has to be specified with full path."
204                         elif format =='image':
205                                 abspath = node.getAttribute('abspath')
206                                 if defval != '':
207                                         if abspath != '1':
208                                                 doc += "<br/>The default image is: <code>%s</code>." % (
209                                                         defval)
210                                         else:
211                                                 doc += "<br/>%s: %s%s%s." % (
212                                                         "The default image (with absolute path) is",
213                                                         "<code>",defval,"</code>")
214                                 else:
215                                         if abspath == '1':
216                                                 doc += "<br/>The image has to be specified with full path."
217                         else: # format == 'string':
218                                 if defval != '':
219                                         doc += "<br/>The default value is: <code>%s</code>." % (
220                                                 defval)
221                 # depends handling
222                 if (node.hasAttribute('depends')):
223                         depends = node.getAttribute('depends')
224                         doc += "<br/>%s \\ref cfg_%s \"%s\" is set to \\c YES." % (
225                                 "This tag requires that the tag", depends.lower(), depends.upper())
226
227         docC = transformDocs(doc)
228         return docC;
229
230 def parseOption(node):
231         # Handling part for Doxyfile
232         name = node.getAttribute('id')
233         type = node.getAttribute('type')
234         format = node.getAttribute('format')
235         defval = node.getAttribute('defval')
236         adefval = node.getAttribute('altdefval')
237         depends = node.getAttribute('depends')
238         setting = node.getAttribute('setting')
239         docC = prepCDocs(node);
240         if len(setting) > 0:
241                 print("#if %s" % (setting))
242         print("  //----")
243         if type == 'bool':
244                 if len(adefval) > 0:
245                         enabled = adefval
246                 elif defval == '1':
247                         enabled = "TRUE"
248                 else:
249                         enabled = "FALSE"
250                 print("  cb = cfg->addBool(")
251                 print("             \"%s\"," % (name))
252                 rng = len(docC)
253                 for i in range(rng):
254                         line = docC[i]
255                         if i != rng - 1:  # since we go from 0 to rng-1
256                                 print("              \"%s\\n\"" % (line))
257                         else:
258                                 print("              \"%s\"," % (line))
259                 print("              %s" % (enabled))
260                 print("             );")
261                 if depends != '':
262                         print("  cb->addDependency(\"%s\");" % (depends))
263         elif type == 'string':
264                 print("  cs = cfg->addString(")
265                 print("              \"%s\"," % (name))
266                 rng = len(docC)
267                 for i in range(rng):
268                         line = docC[i]
269                         if i != rng - 1:  # since we go from 0 to rng-1
270                                 print("              \"%s\\n\"" % (line))
271                         else:
272                                 print("              \"%s\"" % (line))
273                 print("             );")
274                 if defval != '':
275                         print("  cs->setDefaultValue(\"%s\");" % (defval.replace('\\','\\\\')))
276                 if format == 'file':
277                         print("  cs->setWidgetType(ConfigString::File);")
278                 elif format == 'image':
279                         print("  cs->setWidgetType(ConfigString::Image);")
280                 elif format == 'dir':
281                         print("  cs->setWidgetType(ConfigString::Dir);")
282                 if depends != '':
283                         print("  cs->addDependency(\"%s\");" % (depends))
284         elif type == 'enum':
285                 print("  ce = cfg->addEnum(")
286                 print("              \"%s\"," % (name))
287                 rng = len(docC)
288                 for i in range(rng):
289                         line = docC[i]
290                         if i != rng - 1:  # since we go from 0 to rng-1
291                                 print("              \"%s\\n\"" % (line))
292                         else:
293                                 print("              \"%s\"," % (line))
294                 print("              \"%s\"" % (defval))
295                 print("             );")
296                 addValues("ce", node)
297                 if depends != '':
298                         print("  ce->addDependency(\"%s\");" % (depends))
299         elif type == 'int':
300                 minval = node.getAttribute('minval')
301                 maxval = node.getAttribute('maxval')
302                 print("  ci = cfg->addInt(")
303                 print("              \"%s\"," % (name))
304                 rng = len(docC)
305                 for i in range(rng):
306                         line = docC[i]
307                         if i != rng - 1:  # since we go from 0 to rng-1
308                                 print("              \"%s\\n\"" % (line))
309                         else:
310                                 print("              \"%s\"," % (line))
311                 print("              %s,%s,%s" % (minval, maxval, defval))
312                 print("             );")
313                 if depends != '':
314                         print("  ci->addDependency(\"%s\");" % (depends))
315         elif type == 'list':
316                 print("  cl = cfg->addList(")
317                 print("              \"%s\"," % (name))
318                 rng = len(docC)
319                 for i in range(rng):
320                         line = docC[i]
321                         if i != rng - 1:  # since we go from 0 to rng-1
322                                 print("              \"%s\\n\"" % (line))
323                         else:
324                                 print("              \"%s\"" % (line))
325                 print("             );")
326                 addValues("cl", node)
327                 if depends != '':
328                         print("  cl->addDependency(\"%s\");" % (depends))
329                 if format == 'file':
330                         print("  cl->setWidgetType(ConfigList::File);")
331                 elif format == 'dir':
332                         print("  cl->setWidgetType(ConfigList::Dir);")
333                 elif format == 'filedir':
334                         print("  cl->setWidgetType(ConfigList::FileAndDir);")
335         elif type == 'obsolete':
336                 print("  cfg->addObsolete(\"%s\");" % (name))
337         if len(setting) > 0:
338                 print("#else")
339                 print("  cfg->addDisabled(\"%s\");" % (name))
340                 print("#endif")
341
342
343 def parseGroups(node):
344         name = node.getAttribute('name')
345         doc = node.getAttribute('docs')
346         print("%s%s" % ("  //-----------------------------------------",
347                                         "----------------------------------"))
348         print("  cfg->addInfo(\"%s\",\"%s\");" % (name, doc))
349         print("%s%s" % ("  //-----------------------------------------",
350                                         "----------------------------------"))
351         print("")
352         for n in node.childNodes:
353                 if n.nodeType == Node.ELEMENT_NODE:
354                         parseOption(n)
355
356 def parseGroupMap(node):
357         map = { 'bool':'bool', 'string':'QCString', 'enum':'QCString', 'int':'int', 'list':'QStrList' }
358         for n in node.childNodes:
359                 if n.nodeType == Node.ELEMENT_NODE:
360                         setting = n.getAttribute('setting')
361                         if len(setting) > 0:
362                                 print("#if %s" % (setting))
363                         type = n.getAttribute('type')
364                         name = n.getAttribute('id')
365                         if type in map:
366                                 print("    %-8s %s;" % (map[type],name))
367                         if len(setting) > 0:
368                                 print("#endif")
369
370 def parseGroupInit(node):
371         map = { 'bool':'Bool', 'string':'String', 'enum':'Enum', 'int':'Int', 'list':'List' }
372         for n in node.childNodes:
373                 if n.nodeType == Node.ELEMENT_NODE:
374                         setting = n.getAttribute('setting')
375                         if len(setting) > 0:
376                                 print("#if %s" % (setting))
377                         type = n.getAttribute('type')
378                         name = n.getAttribute('id')
379                         if type in map:
380                                 print("  %-25s = ConfigImpl::instance()->get%s(__FILE__,__LINE__,\"%s\");" % (name,map[type],name))
381                         if len(setting) > 0:
382                                 print("#endif")
383
384 def parseGroupMapInit(node):
385         map = { 'bool':'Bool', 'string':'String', 'enum':'String', 'int':'Int', 'list':'List' }
386         for n in node.childNodes:
387                 if n.nodeType == Node.ELEMENT_NODE:
388                         setting = n.getAttribute('setting')
389                         if len(setting) > 0:
390                                 print("#if %s" % (setting))
391                         type = n.getAttribute('type')
392                         name = n.getAttribute('id')
393                         if type in map:
394                                 print("  m_map.insert(\"%s\",new Info%s(&ConfigValues::%s));" % (name,map[type],name))
395                         if len(setting) > 0:
396                                 print("#endif")
397
398 def parseGroupCDocs(node):
399         for n in node.childNodes:
400                 if n.nodeType == Node.ELEMENT_NODE:
401                         type = n.getAttribute('type')
402                         name = n.getAttribute('id')
403                         docC = prepCDocs(n);
404                         if type != 'obsolete':
405                                 print("  doc->add(")
406                                 print("              \"%s\"," % (name))
407                                 rng = len(docC)
408                                 for i in range(rng):
409                                         line = docC[i]
410                                         if i != rng - 1:  # since we go from 0 to rng-1
411                                                 print("              \"%s\\n\"" % (line))
412                                         else:
413                                                 print("              \"%s\"" % (line))
414                                 print("          );")
415
416 def parseOptionDoc(node, first):
417         # Handling part for documentation
418         name = node.getAttribute('id')
419         type = node.getAttribute('type')
420         format = node.getAttribute('format')
421         defval = node.getAttribute('defval')
422         adefval = node.getAttribute('altdefval')
423         depends = node.getAttribute('depends')
424         setting = node.getAttribute('setting')
425         doc = ""
426         if (type != 'obsolete'):
427                 for n in node.childNodes:
428                         if (n.nodeName == "docs"):
429                                 if (n.getAttribute('documentation') != "0"):
430                                         if n.nodeType == Node.ELEMENT_NODE:
431                                                 doc += parseDocs(n)
432                 if (first):
433                         print(" \\anchor cfg_%s" % (name.lower()))
434                         print("<dl>")
435                         print("")
436                         print("<dt>\\c %s <dd>" % (name))
437                 else:
438                         print(" \\anchor cfg_%s" % (name.lower()))
439                         print("<dt>\\c %s <dd>" % (name))
440                 print(" \\addindex %s" % (name))
441                 print(doc)
442                 if (type == 'enum'):
443                         values = collectValues(node)
444                         print("")
445                         print("Possible values are: ")
446                         rng = len(values)
447                         for i in range(rng):
448                                 val = values[i]
449                                 if i == rng - 2:
450                                         print("%s and " % (val))
451                                 elif i == rng - 1:
452                                         print("%s." % (val))
453                                 else:
454                                         print("%s, " % (val))
455                         if (defval != ""):
456                                 print("")
457                                 print("")
458                                 print("The default value is: <code>%s</code>." % (defval))
459                         print("")
460                 elif (type == 'int'):
461                         minval = node.getAttribute('minval')
462                         maxval = node.getAttribute('maxval')
463                         print("")
464                         print("")
465                         print("%s: %s%s%s, %s: %s%s%s, %s: %s%s%s." % (
466                                          " Minimum value", "<code>", minval, "</code>", 
467                                          "maximum value", "<code>", maxval, "</code>",
468                                          "default value", "<code>", defval, "</code>"))
469                         print("")
470                 elif (type == 'bool'):
471                         print("")
472                         print("")
473                         if (node.hasAttribute('altdefval')):
474                                 print("The default value is: system dependent.")
475                         else:
476                                 print("The default value is: <code>%s</code>." % (
477                                         "YES" if (defval == "1") else "NO"))
478                         print("")
479                 elif (type == 'list'):
480                         if format == 'string':
481                                 values = collectValues(node)
482                                 rng = len(values)
483                                 for i in range(rng):
484                                         val = values[i]
485                                         if i == rng - 2:
486                                                 print("%s and " % (val))
487                                         elif i == rng - 1:
488                                                 print("%s." % (val))
489                                         else:
490                                                 print("%s, " % (val))
491                         print("")
492                 elif (type == 'string'):
493                         if format == 'dir':
494                                 if defval != '':
495                                         print("")
496                                         print("The default directory is: <code>%s</code>." % (
497                                                 defval))
498                         elif format == 'file':
499                                 abspath = node.getAttribute('abspath')
500                                 if defval != '':
501                                         print("")
502                                         if abspath != '1':
503                                                 print("The default file is: <code>%s</code>." % (
504                                                         defval))
505                                         else:
506                                                 print("%s: %s%s%s." % (
507                                                         "The default file (with absolute path) is",
508                                                         "<code>",defval,"</code>"))
509                                 else:
510                                         if abspath == '1':
511                                                 print("")
512                                                 print("The file has to be specified with full path.")
513                         elif format =='image':
514                                 abspath = node.getAttribute('abspath')
515                                 if defval != '':
516                                         print("")
517                                         if abspath != '1':
518                                                 print("The default image is: <code>%s</code>." % (
519                                                         defval))
520                                         else:
521                                                 print("%s: %s%s%s." % (
522                                                         "The default image (with absolute path) is",
523                                                         "<code>",defval,"</code>"))
524                                 else:
525                                         if abspath == '1':
526                                                 print("")
527                                                 print("The image has to be specified with full path.")
528                         else: # format == 'string':
529                                 if defval != '':
530                                         print("")
531                                         print("The default value is: <code>%s</code>." % (
532                                                 defval.replace('\\','\\\\')))
533                         print("")
534                 # depends handling
535                 if (node.hasAttribute('depends')):
536                         depends = node.getAttribute('depends')
537                         print("")
538                         print("%s \\ref cfg_%s \"%s\" is set to \\c YES." % (
539                                 "This tag requires that the tag", depends.lower(), depends.upper()))
540                 return False
541
542
543 def parseGroupsDoc(node):
544         name = node.getAttribute('name')
545         doc = node.getAttribute('docs')
546         print("\section config_%s %s" % (name.lower(), doc))
547         # Start of list has been moved to the first option for better
548         # anchor placement
549         #  print "<dl>"
550         #  print ""
551         first = True
552         for n in node.childNodes:
553                 if n.nodeType == Node.ELEMENT_NODE:
554                         first = parseOptionDoc(n, first)
555         if (not first):
556                 print("</dl>")
557
558
559 def parseGroupsList(node, commandsList):
560         list = ()
561         for n in node.childNodes:
562                 if n.nodeType == Node.ELEMENT_NODE:
563                         type = n.getAttribute('type')
564                         if type != 'obsolete':
565                                 commandsList = commandsList + (n.getAttribute('id'),)
566         return commandsList
567
568
569 def parseDocs(node):
570         doc = ""
571         for n in node.childNodes:
572                 if n.nodeType == Node.TEXT_NODE:
573                         doc += n.nodeValue.strip()
574                 if n.nodeType == Node.CDATA_SECTION_NODE:
575                         doc += n.nodeValue.rstrip("\r\n ").lstrip("\r\n")
576         #doc += "<br>"
577         return doc
578
579
580 def parseHeaderDoc(node):
581         doc = ""
582         for n in node.childNodes:
583                 if n.nodeType == Node.ELEMENT_NODE:
584                         if (n.nodeName == "docs"):
585                                 if (n.getAttribute('documentation') != "0"):
586                                         doc += parseDocs(n)
587         print(doc)
588
589
590 def parseFooterDoc(node):
591         doc = ""
592         for n in node.childNodes:
593                 if n.nodeType == Node.ELEMENT_NODE:
594                         if (n.nodeName == "docs"):
595                                 if (n.getAttribute('documentation') != "0"):
596                                         doc += parseDocs(n)
597         print(doc)
598
599
600 def main():
601         if len(sys.argv)<3 or (not sys.argv[1] in ['-doc','-cpp','-wiz','-maph','-maps']):
602                 sys.exit('Usage: %s -doc|-cpp|-wiz|-maph|-maps config.xml' % sys.argv[0])
603         try:
604                 doc = xml.dom.minidom.parse(sys.argv[2])
605         except Exception as inst:
606                 sys.stdout = sys.stderr
607                 print("")
608                 print(inst)
609                 print("")
610                 sys.exit(1)
611         elem = doc.documentElement
612         if (sys.argv[1] == "-doc"):
613                 print("/* WARNING: This file is generated!")
614                 print(" * Do not edit this file, but edit config.xml instead and run")
615                 print(" * python configgen.py -doc config.xml to regenerate this file!")
616                 print(" */")
617                 # process header
618                 for n in elem.childNodes:
619                         if n.nodeType == Node.ELEMENT_NODE:
620                                 if (n.nodeName == "header"):
621                                         parseHeaderDoc(n)
622                 # generate list with all commands
623                 commandsList = ()
624                 for n in elem.childNodes:
625                         if n.nodeType == Node.ELEMENT_NODE:
626                                 if (n.nodeName == "group"):
627                                         commandsList = parseGroupsList(n, commandsList)
628                 print("\\secreflist")
629                 for x in sorted(commandsList):
630                         print("\\refitem cfg_%s %s" % (x.lower(), x))
631                 print("\\endsecreflist")
632                 # process groups and options
633                 for n in elem.childNodes:
634                         if n.nodeType == Node.ELEMENT_NODE:
635                                 if (n.nodeName == "group"):
636                                         parseGroupsDoc(n)
637                 # process footers
638                 for n in elem.childNodes:
639                         if n.nodeType == Node.ELEMENT_NODE:
640                                 if (n.nodeName == "footer"):
641                                         parseFooterDoc(n)
642         elif (sys.argv[1] == "-maph"):
643                 print("/* WARNING: This file is generated!")
644                 print(" * Do not edit this file, but edit config.xml instead and run")
645                 print(" * python configgen.py -map config.xml to regenerate this file!")
646                 print(" */")
647                 print("#ifndef CONFIGVALUES_H")
648                 print("#define CONFIGVALUES_H")
649                 print("")
650                 print("#include <qdict.h>")
651                 print("#include <qstrlist.h>")
652                 print("#include <qcstring.h>")
653                 print("#include \"settings.h\"")
654                 print("")
655                 print("class ConfigValues")
656                 print("{")
657                 print("  public:")
658                 print("    static ConfigValues &instance() { static ConfigValues theInstance; return theInstance; }")
659                 for n in elem.childNodes:
660                         if n.nodeType == Node.ELEMENT_NODE:
661                                 if (n.nodeName == "group"):
662                                         parseGroupMap(n)
663                 print("    void init();")
664                 print("    struct Info")
665                 print("    {")
666                 print("      enum Type { Bool, Int, String, List, Unknown };")
667                 print("      Info(Type t) : type(t) {}")
668                 print("      virtual ~Info() {}")
669                 print("      Type type;")
670                 print("    };")
671                 print("    struct InfoBool : public Info")
672                 print("    {")
673                 print("      InfoBool(bool ConfigValues::*ptm) : Info(Info::Bool), item(ptm) {}")
674                 print("      bool ConfigValues::*item;")
675                 print("    };")
676                 print("    struct InfoInt : public Info")
677                 print("    {")
678                 print("      InfoInt(int ConfigValues::*ptm) : Info(Info::Int), item(ptm) {}")
679                 print("      int ConfigValues::*item;")
680                 print("    };")
681                 print("    struct InfoString : public Info")
682                 print("    {")
683                 print("      InfoString(QCString ConfigValues::*ptm) : Info(Info::String), item(ptm) {}")
684                 print("      QCString ConfigValues::*item;")
685                 print("    };")
686                 print("    struct InfoList : public Info")
687                 print("    {")
688                 print("      InfoList(QStrList ConfigValues::*ptm) : Info(Info::List), item(ptm) {}")
689                 print("      QStrList ConfigValues::*item;")
690                 print("    };")
691                 print("    const Info *get(const char *tag) const")
692                 print("    {")
693                 print("      return m_map.find(tag);")
694                 print("    }")
695                 print("  private:")
696                 print("    ConfigValues();")
697                 print("    QDict<Info> m_map;")
698                 print("};")
699                 print("")
700                 print("#endif")
701         elif (sys.argv[1] == "-maps"):
702                 print("/* WARNING: This file is generated!")
703                 print(" * Do not edit this file, but edit config.xml instead and run")
704                 print(" * python configgen.py -maps config.xml to regenerate this file!")
705                 print(" */")
706                 print("#include \"configvalues.h\"")
707                 print("#include \"configimpl.h\"")
708                 print("")
709                 print("ConfigValues::ConfigValues() : m_map(257)")
710                 print("{")
711                 print("  m_map.setAutoDelete(TRUE);")
712                 for n in elem.childNodes:
713                         if n.nodeType == Node.ELEMENT_NODE:
714                                 if (n.nodeName == "group"):
715                                         parseGroupMapInit(n)
716                 print("}")
717                 print("")
718                 print("void ConfigValues::init()")
719                 print("{")
720                 for n in elem.childNodes:
721                         if n.nodeType == Node.ELEMENT_NODE:
722                                 if (n.nodeName == "group"):
723                                         parseGroupInit(n)
724                 print("}")
725         elif (sys.argv[1] == "-cpp"):
726                 print("/* WARNING: This file is generated!")
727                 print(" * Do not edit this file, but edit config.xml instead and run")
728                 print(" * python configgen.py -cpp config.xml to regenerate this file!")
729                 print(" */")
730                 print("")
731                 print("#include \"configoptions.h\"")
732                 print("#include \"configimpl.h\"")
733                 print("#include \"portable.h\"")
734                 print("#include \"settings.h\"")
735                 print("")
736                 print("void addConfigOptions(ConfigImpl *cfg)")
737                 print("{")
738                 print("  ConfigString *cs;")
739                 print("  ConfigEnum   *ce;")
740                 print("  ConfigList   *cl;")
741                 print("  ConfigInt    *ci;")
742                 print("  ConfigBool   *cb;")
743                 print("")
744                 # process header
745                 for n in elem.childNodes:
746                         if n.nodeType == Node.ELEMENT_NODE:
747                                 if (n.nodeName == "header"):
748                                         parseHeader(n,'cfg')
749                 for n in elem.childNodes:
750                         if n.nodeType == Node.ELEMENT_NODE:
751                                 if (n.nodeName == "group"):
752                                         parseGroups(n)
753                 print("}")
754         elif (sys.argv[1] == "-wiz"):
755                 print("/* WARNING: This file is generated!")
756                 print(" * Do not edit this file, but edit config.xml instead and run")
757                 print(" * python configgen.py -wiz config.xml to regenerate this file!")
758                 print(" */")
759                 print("#include \"configdoc.h\"")
760                 print("#include \"docintf.h\"")
761                 print("")
762                 print("void addConfigDocs(DocIntf *doc)")
763                 print("{")
764                 for n in elem.childNodes:
765                         if n.nodeType == Node.ELEMENT_NODE:
766                                 if (n.nodeName == "header"):
767                                         parseHeader(n,'doc')
768                 for n in elem.childNodes:
769                         if n.nodeType == Node.ELEMENT_NODE:
770                                 if (n.nodeName == "group"):
771                                         parseGroupCDocs(n)
772                 print("}")
773
774 if __name__ == '__main__':
775         main()