My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
configgen Namespace Reference

Functions

def transformDocs
 
def collectValues
 
def addValues
 
def parseHeader
 
def prepCDocs
 
def parseOption
 
def parseGroups
 
def parseGroupMap
 
def parseGroupInit
 
def parseGroupMapInit
 
def parseGroupCDocs
 
def parseOptionDoc
 
def parseGroupsDoc
 
def parseGroupsList
 
def parseDocs
 
def parseHeaderDoc
 
def parseFooterDoc
 
def main
 

Function Documentation

def configgen.addValues (   var,
  node 
)

Definition at line 110 of file configgen.py.

Referenced by parseOption().

111 def addValues(var, node):
112  for n in node.childNodes:
113  if (n.nodeName == "value"):
114  if n.nodeType == Node.ELEMENT_NODE:
115  name = n.getAttribute('name')
116  print(" %s->addValue(\"%s\");" % (var, name))
117 
def configgen.collectValues (   node)

Definition at line 95 of file configgen.py.

Referenced by parseOptionDoc(), and prepCDocs().

95 
96 def collectValues(node):
97  values = []
98  for n in node.childNodes:
99  if (n.nodeName == "value"):
100  if n.nodeType == Node.ELEMENT_NODE:
101  if n.getAttribute('name') != "":
102  if n.getAttribute('show_docu') != "NO":
103  name = "<code>" + n.getAttribute('name') + "</code>"
104  desc = n.getAttribute('desc')
105  if (desc != ""):
106  name += " " + desc
107  values.append(name)
108  return values
109 
def configgen.main ( )

Definition at line 600 of file configgen.py.

References parseFooterDoc(), parseGroupCDocs(), parseGroupInit(), parseGroupMap(), parseGroupMapInit(), parseGroups(), parseGroupsDoc(), parseGroupsList(), parseHeader(), and parseHeaderDoc().

601 def main():
602  if len(sys.argv)<3 or (not sys.argv[1] in ['-doc','-cpp','-wiz','-maph','-maps']):
603  sys.exit('Usage: %s -doc|-cpp|-wiz|-maph|-maps config.xml' % sys.argv[0])
604  try:
605  doc = xml.dom.minidom.parse(sys.argv[2])
606  except Exception as inst:
607  sys.stdout = sys.stderr
608  print("")
609  print(inst)
610  print("")
611  sys.exit(1)
612  elem = doc.documentElement
613  if (sys.argv[1] == "-doc"):
614  print("/* WARNING: This file is generated!")
615  print(" * Do not edit this file, but edit config.xml instead and run")
616  print(" * python configgen.py -doc config.xml to regenerate this file!")
617  print(" */")
618  # process header
619  for n in elem.childNodes:
620  if n.nodeType == Node.ELEMENT_NODE:
621  if (n.nodeName == "header"):
622  parseHeaderDoc(n)
623  # generate list with all commands
624  commandsList = ()
625  for n in elem.childNodes:
626  if n.nodeType == Node.ELEMENT_NODE:
627  if (n.nodeName == "group"):
628  commandsList = parseGroupsList(n, commandsList)
629  print("\\secreflist")
630  for x in sorted(commandsList):
631  print("\\refitem cfg_%s %s" % (x.lower(), x))
632  print("\\endsecreflist")
633  # process groups and options
634  for n in elem.childNodes:
635  if n.nodeType == Node.ELEMENT_NODE:
636  if (n.nodeName == "group"):
637  parseGroupsDoc(n)
638  # process footers
639  for n in elem.childNodes:
640  if n.nodeType == Node.ELEMENT_NODE:
641  if (n.nodeName == "footer"):
642  parseFooterDoc(n)
643  elif (sys.argv[1] == "-maph"):
644  print("/* WARNING: This file is generated!")
645  print(" * Do not edit this file, but edit config.xml instead and run")
646  print(" * python configgen.py -map config.xml to regenerate this file!")
647  print(" */")
648  print("#ifndef CONFIGVALUES_H")
649  print("#define CONFIGVALUES_H")
650  print("")
651  print("#include <qdict.h>")
652  print("#include <qstrlist.h>")
653  print("#include <qcstring.h>")
654  print("#include \"settings.h\"")
655  print("")
656  print("class ConfigValues")
657  print("{")
658  print(" public:")
659  print(" static ConfigValues &instance() { static ConfigValues theInstance; return theInstance; }")
660  for n in elem.childNodes:
661  if n.nodeType == Node.ELEMENT_NODE:
662  if (n.nodeName == "group"):
663  parseGroupMap(n)
664  print(" void init();")
665  print(" struct Info")
666  print(" {")
667  print(" enum Type { Bool, Int, String, List, Unknown };")
668  print(" Info(Type t) : type(t) {}")
669  print(" virtual ~Info() {}")
670  print(" Type type;")
671  print(" };")
672  print(" struct InfoBool : public Info")
673  print(" {")
674  print(" InfoBool(bool ConfigValues::*ptm) : Info(Info::Bool), item(ptm) {}")
675  print(" bool ConfigValues::*item;")
676  print(" };")
677  print(" struct InfoInt : public Info")
678  print(" {")
679  print(" InfoInt(int ConfigValues::*ptm) : Info(Info::Int), item(ptm) {}")
680  print(" int ConfigValues::*item;")
681  print(" };")
682  print(" struct InfoString : public Info")
683  print(" {")
684  print(" InfoString(QCString ConfigValues::*ptm) : Info(Info::String), item(ptm) {}")
685  print(" QCString ConfigValues::*item;")
686  print(" };")
687  print(" struct InfoList : public Info")
688  print(" {")
689  print(" InfoList(QStrList ConfigValues::*ptm) : Info(Info::List), item(ptm) {}")
690  print(" QStrList ConfigValues::*item;")
691  print(" };")
692  print(" const Info *get(const char *tag) const")
693  print(" {")
694  print(" return m_map.find(tag);")
695  print(" }")
696  print(" private:")
697  print(" ConfigValues();")
698  print(" QDict<Info> m_map;")
699  print("};")
700  print("")
701  print("#endif")
702  elif (sys.argv[1] == "-maps"):
703  print("/* WARNING: This file is generated!")
704  print(" * Do not edit this file, but edit config.xml instead and run")
705  print(" * python configgen.py -maps config.xml to regenerate this file!")
706  print(" */")
707  print("#include \"configvalues.h\"")
708  print("#include \"configimpl.h\"")
709  print("")
710  print("ConfigValues::ConfigValues() : m_map(257)")
711  print("{")
712  print(" m_map.setAutoDelete(TRUE);")
713  for n in elem.childNodes:
714  if n.nodeType == Node.ELEMENT_NODE:
715  if (n.nodeName == "group"):
717  print("}")
718  print("")
719  print("void ConfigValues::init()")
720  print("{")
721  for n in elem.childNodes:
722  if n.nodeType == Node.ELEMENT_NODE:
723  if (n.nodeName == "group"):
724  parseGroupInit(n)
725  print("}")
726  elif (sys.argv[1] == "-cpp"):
727  print("/* WARNING: This file is generated!")
728  print(" * Do not edit this file, but edit config.xml instead and run")
729  print(" * python configgen.py -cpp config.xml to regenerate this file!")
730  print(" */")
731  print("")
732  print("#include \"configoptions.h\"")
733  print("#include \"configimpl.h\"")
734  print("#include \"portable.h\"")
735  print("#include \"settings.h\"")
736  print("")
737  print("void addConfigOptions(ConfigImpl *cfg)")
738  print("{")
739  print(" ConfigString *cs;")
740  print(" ConfigEnum *ce;")
741  print(" ConfigList *cl;")
742  print(" ConfigInt *ci;")
743  print(" ConfigBool *cb;")
744  print("")
745  # process header
746  for n in elem.childNodes:
747  if n.nodeType == Node.ELEMENT_NODE:
748  if (n.nodeName == "header"):
749  parseHeader(n,'cfg')
750  for n in elem.childNodes:
751  if n.nodeType == Node.ELEMENT_NODE:
752  if (n.nodeName == "group"):
753  parseGroups(n)
754  print("}")
755  elif (sys.argv[1] == "-wiz"):
756  print("/* WARNING: This file is generated!")
757  print(" * Do not edit this file, but edit config.xml instead and run")
758  print(" * python configgen.py -wiz config.xml to regenerate this file!")
759  print(" */")
760  print("#include \"configdoc.h\"")
761  print("#include \"docintf.h\"")
762  print("")
763  print("void addConfigDocs(DocIntf *doc)")
764  print("{")
765  for n in elem.childNodes:
766  if n.nodeType == Node.ELEMENT_NODE:
767  if (n.nodeName == "header"):
768  parseHeader(n,'doc')
769  for n in elem.childNodes:
770  if n.nodeType == Node.ELEMENT_NODE:
771  if (n.nodeName == "group"):
772  parseGroupCDocs(n)
773  print("}")
def configgen.parseDocs (   node)

Definition at line 569 of file configgen.py.

Referenced by parseFooterDoc(), parseHeader(), parseHeaderDoc(), parseOptionDoc(), and prepCDocs().

570 def parseDocs(node):
571  doc = ""
572  for n in node.childNodes:
573  if n.nodeType == Node.TEXT_NODE:
574  doc += n.nodeValue.strip()
575  if n.nodeType == Node.CDATA_SECTION_NODE:
576  doc += n.nodeValue.rstrip("\r\n ").lstrip("\r\n")
577  #doc += "<br>"
578  return doc
579 
def configgen.parseFooterDoc (   node)

Definition at line 590 of file configgen.py.

References parseDocs().

Referenced by main().

591 def parseFooterDoc(node):
592  doc = ""
593  for n in node.childNodes:
594  if n.nodeType == Node.ELEMENT_NODE:
595  if (n.nodeName == "docs"):
596  if (n.getAttribute('documentation') != "0"):
597  doc += parseDocs(n)
598  print(doc)
599 
def configgen.parseGroupCDocs (   node)

Definition at line 398 of file configgen.py.

References prepCDocs().

Referenced by main().

399 def parseGroupCDocs(node):
400  for n in node.childNodes:
401  if n.nodeType == Node.ELEMENT_NODE:
402  type = n.getAttribute('type')
403  name = n.getAttribute('id')
404  docC = prepCDocs(n);
405  if type != 'obsolete':
406  print(" doc->add(")
407  print(" \"%s\"," % (name))
408  rng = len(docC)
409  for i in range(rng):
410  line = docC[i]
411  if i != rng - 1: # since we go from 0 to rng-1
412  print(" \"%s\\n\"" % (line))
413  else:
414  print(" \"%s\"" % (line))
415  print(" );")
def configgen.parseGroupInit (   node)

Definition at line 370 of file configgen.py.

Referenced by main().

371 def parseGroupInit(node):
372  map = { 'bool':'Bool', 'string':'String', 'enum':'Enum', 'int':'Int', 'list':'List' }
373  for n in node.childNodes:
374  if n.nodeType == Node.ELEMENT_NODE:
375  setting = n.getAttribute('setting')
376  if len(setting) > 0:
377  print("#if %s" % (setting))
378  type = n.getAttribute('type')
379  name = n.getAttribute('id')
380  if type in map:
381  print(" %-25s = ConfigImpl::instance()->get%s(__FILE__,__LINE__,\"%s\");" % (name,map[type],name))
382  if len(setting) > 0:
383  print("#endif")
def configgen.parseGroupMap (   node)

Definition at line 356 of file configgen.py.

Referenced by main().

357 def parseGroupMap(node):
358  map = { 'bool':'bool', 'string':'QCString', 'enum':'QCString', 'int':'int', 'list':'QStrList' }
359  for n in node.childNodes:
360  if n.nodeType == Node.ELEMENT_NODE:
361  setting = n.getAttribute('setting')
362  if len(setting) > 0:
363  print("#if %s" % (setting))
364  type = n.getAttribute('type')
365  name = n.getAttribute('id')
366  if type in map:
367  print(" %-8s %s;" % (map[type],name))
368  if len(setting) > 0:
369  print("#endif")
def configgen.parseGroupMapInit (   node)

Definition at line 384 of file configgen.py.

Referenced by main().

385 def parseGroupMapInit(node):
386  map = { 'bool':'Bool', 'string':'String', 'enum':'String', 'int':'Int', 'list':'List' }
387  for n in node.childNodes:
388  if n.nodeType == Node.ELEMENT_NODE:
389  setting = n.getAttribute('setting')
390  if len(setting) > 0:
391  print("#if %s" % (setting))
392  type = n.getAttribute('type')
393  name = n.getAttribute('id')
394  if type in map:
395  print(" m_map.insert(\"%s\",new Info%s(&ConfigValues::%s));" % (name,map[type],name))
396  if len(setting) > 0:
397  print("#endif")
def configgen.parseGroups (   node)

Definition at line 343 of file configgen.py.

References parseOption().

Referenced by main().

344 def parseGroups(node):
345  name = node.getAttribute('name')
346  doc = node.getAttribute('docs')
347  print("%s%s" % (" //-----------------------------------------",
348  "----------------------------------"))
349  print(" cfg->addInfo(\"%s\",\"%s\");" % (name, doc))
350  print("%s%s" % (" //-----------------------------------------",
351  "----------------------------------"))
352  print("")
353  for n in node.childNodes:
354  if n.nodeType == Node.ELEMENT_NODE:
355  parseOption(n)
def configgen.parseGroupsDoc (   node)

Definition at line 543 of file configgen.py.

References parseOptionDoc().

Referenced by main().

544 def parseGroupsDoc(node):
545  name = node.getAttribute('name')
546  doc = node.getAttribute('docs')
547  print("\section config_%s %s" % (name.lower(), doc))
548  # Start of list has been moved to the first option for better
549  # anchor placement
550  # print "<dl>"
551  # print ""
552  first = True
553  for n in node.childNodes:
554  if n.nodeType == Node.ELEMENT_NODE:
555  first = parseOptionDoc(n, first)
556  if (not first):
557  print("</dl>")
558 
def configgen.parseGroupsList (   node,
  commandsList 
)

Definition at line 559 of file configgen.py.

Referenced by main().

560 def parseGroupsList(node, commandsList):
561  list = ()
562  for n in node.childNodes:
563  if n.nodeType == Node.ELEMENT_NODE:
564  type = n.getAttribute('type')
565  if type != 'obsolete':
566  commandsList = commandsList + (n.getAttribute('id'),)
567  return commandsList
568 
def configgen.parseHeader (   node,
  objName 
)

Definition at line 118 of file configgen.py.

References parseDocs(), and transformDocs().

Referenced by main().

119 def parseHeader(node,objName):
120  doc = ""
121  for n in node.childNodes:
122  if n.nodeType == Node.ELEMENT_NODE:
123  if (n.nodeName == "docs"):
124  if (n.getAttribute('doxyfile') != "0"):
125  doc += parseDocs(n)
126  docC = transformDocs(doc)
127  print(" %s->setHeader(" % (objName))
128  rng = len(docC)
129  for i in range(rng):
130  line = docC[i]
131  if i != rng - 1: # since we go from 0 to rng-1
132  print(" \"%s\\n\"" % (line))
133  else:
134  print(" \"%s\"" % (line))
135  print(" );")
136 
def configgen.parseHeaderDoc (   node)

Definition at line 580 of file configgen.py.

References parseDocs().

Referenced by main().

581 def parseHeaderDoc(node):
582  doc = ""
583  for n in node.childNodes:
584  if n.nodeType == Node.ELEMENT_NODE:
585  if (n.nodeName == "docs"):
586  if (n.getAttribute('documentation') != "0"):
587  doc += parseDocs(n)
588  print(doc)
589 
def configgen.parseOption (   node)

Definition at line 230 of file configgen.py.

References addValues(), and prepCDocs().

Referenced by parseGroups().

231 def parseOption(node):
232  # Handling part for Doxyfile
233  name = node.getAttribute('id')
234  type = node.getAttribute('type')
235  format = node.getAttribute('format')
236  defval = node.getAttribute('defval')
237  adefval = node.getAttribute('altdefval')
238  depends = node.getAttribute('depends')
239  setting = node.getAttribute('setting')
240  docC = prepCDocs(node);
241  if len(setting) > 0:
242  print("#if %s" % (setting))
243  print(" //----")
244  if type == 'bool':
245  if len(adefval) > 0:
246  enabled = adefval
247  elif defval == '1':
248  enabled = "TRUE"
249  else:
250  enabled = "FALSE"
251  print(" cb = cfg->addBool(")
252  print(" \"%s\"," % (name))
253  rng = len(docC)
254  for i in range(rng):
255  line = docC[i]
256  if i != rng - 1: # since we go from 0 to rng-1
257  print(" \"%s\\n\"" % (line))
258  else:
259  print(" \"%s\"," % (line))
260  print(" %s" % (enabled))
261  print(" );")
262  if depends != '':
263  print(" cb->addDependency(\"%s\");" % (depends))
264  elif type == 'string':
265  print(" cs = cfg->addString(")
266  print(" \"%s\"," % (name))
267  rng = len(docC)
268  for i in range(rng):
269  line = docC[i]
270  if i != rng - 1: # since we go from 0 to rng-1
271  print(" \"%s\\n\"" % (line))
272  else:
273  print(" \"%s\"" % (line))
274  print(" );")
275  if defval != '':
276  print(" cs->setDefaultValue(\"%s\");" % (defval))
277  if format == 'file':
278  print(" cs->setWidgetType(ConfigString::File);")
279  elif format == 'image':
280  print(" cs->setWidgetType(ConfigString::Image);")
281  elif format == 'dir':
282  print(" cs->setWidgetType(ConfigString::Dir);")
283  if depends != '':
284  print(" cs->addDependency(\"%s\");" % (depends))
285  elif type == 'enum':
286  print(" ce = cfg->addEnum(")
287  print(" \"%s\"," % (name))
288  rng = len(docC)
289  for i in range(rng):
290  line = docC[i]
291  if i != rng - 1: # since we go from 0 to rng-1
292  print(" \"%s\\n\"" % (line))
293  else:
294  print(" \"%s\"," % (line))
295  print(" \"%s\"" % (defval))
296  print(" );")
297  addValues("ce", node)
298  if depends != '':
299  print(" ce->addDependency(\"%s\");" % (depends))
300  elif type == 'int':
301  minval = node.getAttribute('minval')
302  maxval = node.getAttribute('maxval')
303  print(" ci = cfg->addInt(")
304  print(" \"%s\"," % (name))
305  rng = len(docC)
306  for i in range(rng):
307  line = docC[i]
308  if i != rng - 1: # since we go from 0 to rng-1
309  print(" \"%s\\n\"" % (line))
310  else:
311  print(" \"%s\"," % (line))
312  print(" %s,%s,%s" % (minval, maxval, defval))
313  print(" );")
314  if depends != '':
315  print(" ci->addDependency(\"%s\");" % (depends))
316  elif type == 'list':
317  print(" cl = cfg->addList(")
318  print(" \"%s\"," % (name))
319  rng = len(docC)
320  for i in range(rng):
321  line = docC[i]
322  if i != rng - 1: # since we go from 0 to rng-1
323  print(" \"%s\\n\"" % (line))
324  else:
325  print(" \"%s\"" % (line))
326  print(" );")
327  addValues("cl", node)
328  if depends != '':
329  print(" cl->addDependency(\"%s\");" % (depends))
330  if format == 'file':
331  print(" cl->setWidgetType(ConfigList::File);")
332  elif format == 'dir':
333  print(" cl->setWidgetType(ConfigList::Dir);")
334  elif format == 'filedir':
335  print(" cl->setWidgetType(ConfigList::FileAndDir);")
336  elif type == 'obsolete':
337  print(" cfg->addObsolete(\"%s\");" % (name))
338  if len(setting) > 0:
339  print("#else")
340  print(" cfg->addDisabled(\"%s\");" % (name))
341  print("#endif")
342 
def configgen.parseOptionDoc (   node,
  first 
)

Definition at line 416 of file configgen.py.

References collectValues(), and parseDocs().

Referenced by parseGroupsDoc().

417 def parseOptionDoc(node, first):
418  # Handling part for documentation
419  name = node.getAttribute('id')
420  type = node.getAttribute('type')
421  format = node.getAttribute('format')
422  defval = node.getAttribute('defval')
423  adefval = node.getAttribute('altdefval')
424  depends = node.getAttribute('depends')
425  setting = node.getAttribute('setting')
426  doc = ""
427  if (type != 'obsolete'):
428  for n in node.childNodes:
429  if (n.nodeName == "docs"):
430  if (n.getAttribute('documentation') != "0"):
431  if n.nodeType == Node.ELEMENT_NODE:
432  doc += parseDocs(n)
433  if (first):
434  print(" \\anchor cfg_%s" % (name.lower()))
435  print("<dl>")
436  print("")
437  print("<dt>\\c %s <dd>" % (name))
438  else:
439  print(" \\anchor cfg_%s" % (name.lower()))
440  print("<dt>\\c %s <dd>" % (name))
441  print(" \\addindex %s" % (name))
442  print(doc)
443  if (type == 'enum'):
444  values = collectValues(node)
445  print("")
446  print("Possible values are: ")
447  rng = len(values)
448  for i in range(rng):
449  val = values[i]
450  if i == rng - 2:
451  print("%s and " % (val))
452  elif i == rng - 1:
453  print("%s." % (val))
454  else:
455  print("%s, " % (val))
456  if (defval != ""):
457  print("")
458  print("")
459  print("The default value is: <code>%s</code>." % (defval))
460  print("")
461  elif (type == 'int'):
462  minval = node.getAttribute('minval')
463  maxval = node.getAttribute('maxval')
464  print("")
465  print("")
466  print("%s: %s%s%s, %s: %s%s%s, %s: %s%s%s." % (
467  " Minimum value", "<code>", minval, "</code>",
468  "maximum value", "<code>", maxval, "</code>",
469  "default value", "<code>", defval, "</code>"))
470  print("")
471  elif (type == 'bool'):
472  print("")
473  print("")
474  if (node.hasAttribute('altdefval')):
475  print("The default value is: system dependent.")
476  else:
477  print("The default value is: <code>%s</code>." % (
478  "YES" if (defval == "1") else "NO"))
479  print("")
480  elif (type == 'list'):
481  if format == 'string':
482  values = collectValues(node)
483  rng = len(values)
484  for i in range(rng):
485  val = values[i]
486  if i == rng - 2:
487  print("%s and " % (val))
488  elif i == rng - 1:
489  print("%s." % (val))
490  else:
491  print("%s, " % (val))
492  print("")
493  elif (type == 'string'):
494  if format == 'dir':
495  if defval != '':
496  print("")
497  print("The default directory is: <code>%s</code>." % (
498  defval))
499  elif format == 'file':
500  abspath = node.getAttribute('abspath')
501  if defval != '':
502  print("")
503  if abspath != '1':
504  print("The default file is: <code>%s</code>." % (
505  defval))
506  else:
507  print("%s: %s%s%s." % (
508  "The default file (with absolute path) is",
509  "<code>",defval,"</code>"))
510  else:
511  if abspath == '1':
512  print("")
513  print("The file has to be specified with full path.")
514  elif format =='image':
515  abspath = node.getAttribute('abspath')
516  if defval != '':
517  print("")
518  if abspath != '1':
519  print("The default image is: <code>%s</code>." % (
520  defval))
521  else:
522  print("%s: %s%s%s." % (
523  "The default image (with absolute path) is",
524  "<code>",defval,"</code>"))
525  else:
526  if abspath == '1':
527  print("")
528  print("The image has to be specified with full path.")
529  else: # format == 'string':
530  if defval != '':
531  print("")
532  print("The default value is: <code>%s</code>." % (
533  defval))
534  print("")
535  # depends handling
536  if (node.hasAttribute('depends')):
537  depends = node.getAttribute('depends')
538  print("")
539  print("%s \\ref cfg_%s \"%s\" is set to \\c YES." % (
540  "This tag requires that the tag", depends.lower(), depends.upper()))
541  return False
542 
def configgen.prepCDocs (   node)

Definition at line 137 of file configgen.py.

References collectValues(), parseDocs(), and transformDocs().

Referenced by parseGroupCDocs(), and parseOption().

138 def prepCDocs(node):
139  type = node.getAttribute('type')
140  format = node.getAttribute('format')
141  defval = node.getAttribute('defval')
142  adefval = node.getAttribute('altdefval')
143  doc = "";
144  if (type != 'obsolete'):
145  for n in node.childNodes:
146  if (n.nodeName == "docs"):
147  if (n.getAttribute('doxyfile') != "0"):
148  if n.nodeType == Node.ELEMENT_NODE:
149  doc += parseDocs(n)
150  if (type == 'enum'):
151  values = collectValues(node)
152  doc += "<br/>Possible values are: "
153  rng = len(values)
154  for i in range(rng):
155  val = values[i]
156  if i == rng - 2:
157  doc += "%s and " % (val)
158  elif i == rng - 1:
159  doc += "%s." % (val)
160  else:
161  doc += "%s, " % (val)
162  if (defval != ""):
163  doc += "<br/>The default value is: <code>%s</code>." % (defval)
164  elif (type == 'int'):
165  minval = node.getAttribute('minval')
166  maxval = node.getAttribute('maxval')
167  doc += "<br/>%s: %s, %s: %s, %s: %s." % (" Minimum value", minval,
168  "maximum value", maxval,
169  "default value", defval)
170  elif (type == 'bool'):
171  if (node.hasAttribute('altdefval')):
172  doc += "<br/>%s: %s." % ("The default value is", "system dependent")
173  else:
174  doc += "<br/>%s: %s." % ("The default value is", "YES" if (defval == "1") else "NO")
175  elif (type == 'list'):
176  if format == 'string':
177  values = collectValues(node)
178  rng = len(values)
179  for i in range(rng):
180  val = values[i]
181  if i == rng - 2:
182  doc += "%s and " % (val)
183  elif i == rng - 1:
184  doc += "%s." % (val)
185  else:
186  doc += "%s, " % (val)
187  elif (type == 'string'):
188  if format == 'dir':
189  if defval != '':
190  doc += "<br/>The default directory is: <code>%s</code>." % (
191  defval)
192  elif format == 'file':
193  abspath = node.getAttribute('abspath')
194  if defval != '':
195  if abspath != '1':
196  doc += "<br/>The default file is: <code>%s</code>." % (
197  defval)
198  else:
199  doc += "<br/>%s: %s%s%s." % (
200  "The default file (with absolute path) is",
201  "<code>",defval,"</code>")
202  else:
203  if abspath == '1':
204  doc += "<br/>The file has to be specified with full path."
205  elif format =='image':
206  abspath = node.getAttribute('abspath')
207  if defval != '':
208  if abspath != '1':
209  doc += "<br/>The default image is: <code>%s</code>." % (
210  defval)
211  else:
212  doc += "<br/>%s: %s%s%s." % (
213  "The default image (with absolute path) is",
214  "<code>",defval,"</code>")
215  else:
216  if abspath == '1':
217  doc += "<br/>The image has to be specified with full path."
218  else: # format == 'string':
219  if defval != '':
220  doc += "<br/>The default value is: <code>%s</code>." % (
221  defval)
222  # depends handling
223  if (node.hasAttribute('depends')):
224  depends = node.getAttribute('depends')
225  doc += "<br/>%s \\ref cfg_%s \"%s\" is set to \\c YES." % (
226  "This tag requires that the tag", depends.lower(), depends.upper())
227 
228  docC = transformDocs(doc)
229  return docC;
def configgen.transformDocs (   doc)

Definition at line 21 of file configgen.py.

Referenced by parseHeader(), and prepCDocs().

21 
22 def transformDocs(doc):
23  # join lines, unless it is an empty line
24  # remove doxygen layout constructs
25  doc = doc.strip()
26  doc = doc.replace("\n", " ")
27  doc = doc.replace("\r", " ")
28  doc = doc.replace("\t", " ")
29  doc = doc.replace("\\&", "&")
30  doc = doc.replace("(\\c ", "(")
31  doc = doc.replace("\\c ", " ")
32  doc = doc.replace("\\b ", " ")
33  doc = doc.replace("\\e ", " ")
34  doc = doc.replace("\\$", "$")
35  doc = doc.replace("\\#include ", "#include ")
36  doc = doc.replace("\\#undef ", "#undef ")
37  doc = doc.replace("-# ", "\n - ")
38  doc = doc.replace(" - ", "\n - ")
39  doc = doc.replace("\\sa", "\nSee also: ")
40  doc = doc.replace("\\par", "\n")
41  doc = doc.replace("@note", "\nNote:")
42  doc = doc.replace("\\note", "\nNote:")
43  doc = doc.replace("\\verbatim", "\n")
44  doc = doc.replace("\\endverbatim", "\n")
45  doc = doc.replace("<code>", "")
46  doc = doc.replace("</code>", "")
47  doc = doc.replace("`", "")
48  doc = doc.replace("\\<", "<")
49  doc = doc.replace("\\>", ">")
50  doc = doc.replace("\\@", "@")
51  doc = doc.replace("\\\\", "\\")
52  # \ref name "description" -> description
53  doc = re.sub('\\\\ref +[^ ]* +"([^"]*)"', '\\1', doc)
54  # \ref specials
55  # \ref <key> -> description
56  doc = re.sub('\\\\ref +doxygen_usage', '"Doxygen usage"', doc)
57  doc = re.sub('\\\\ref +extsearch', '"External Indexing and Searching"',
58  doc)
59  doc = re.sub('\\\\ref +external', '"Linking to external documentation"',
60  doc)
61  # fallback for not handled
62  doc = re.sub('\\\\ref', '', doc)
63  #<a href="address">description</a> -> description (see: address)
64  doc = re.sub('<a +href="([^"]*)" *>([^<]*)</a>', '\\2 (see: \\1)', doc)
65  # LaTeX name as formula -> LaTeX
66  doc = doc.replace("\\f$\\mbox{\\LaTeX}\\f$", "LaTeX")
67  # Other forula's (now just 2) so explicitely mentioned.
68  doc = doc.replace("\\f$2^{(16+\\mbox{LOOKUP\\_CACHE\\_SIZE})}\\f$",
69  "2^(16+LOOKUP_CACHE_SIZE)")
70  doc = doc.replace("\\f$2^{16} = 65536\\f$", "2^16=65536")
71  # remove consecutive spaces
72  doc = re.sub(" +", " ", doc)
73  # a dirty trick to get an extra empty line in Doxyfile documentation.
74  # <br> will be removed later on again, we need it here otherwise splitlines
75  # will filter the extra line.
76  doc = doc.replace("<br>", "\n<br>\n")
77  # a dirty trick to go to the next line in Doxyfile documentation.
78  # <br/> will be removed later on again, we need it here otherwise splitlines
79  # will filter the line break.
80  doc = doc.replace("<br/>", "\n<br/>\n")
81  #
82  doc = doc.splitlines()
83  split_doc = []
84  for line in doc:
85  split_doc += textwrap.wrap(line, 78)
86  # replace \ by \\, replace " by \", and ' ' by a newline with end string
87  # and start string at next line
88  docC = []
89  for line in split_doc:
90  if (line.strip() != "<br/>"):
91  docC.append(line.strip().replace('\\', '\\\\').
92  replace('"', '\\"').replace("<br>", ""))
93  return docC
94