1
|
from haizea.core.configfile import HaizeaConfig
|
2
|
from haizea.common.config import OPTTYPE_INT, OPTTYPE_FLOAT, OPTTYPE_STRING, OPTTYPE_BOOLEAN, OPTTYPE_DATETIME, OPTTYPE_TIMEDELTA
|
3
|
from docutils.core import publish_string
|
4
|
import re
|
5
|
|
6
|
for s in HaizeaConfig.sections:
|
7
|
print "\\section{Section \\texttt{[%s]}}" % s.name
|
8
|
print
|
9
|
print s.get_doc()
|
10
|
print
|
11
|
if s.required:
|
12
|
print "\\emph{This section is required}"
|
13
|
else:
|
14
|
if s.required_if:
|
15
|
print "This section is required when:"
|
16
|
print "\\begin{itemize}"
|
17
|
for r in s.required_if:
|
18
|
sec,opt = r[0]
|
19
|
val = r[1]
|
20
|
print "\\item"
|
21
|
print "Option \\texttt{%s} (in section \\texttt{[%s]})" % (opt,sec)
|
22
|
print "is set to \\texttt{%s}" % val
|
23
|
print "\\end{itemize}"
|
24
|
else:
|
25
|
print "This section is optional."
|
26
|
print
|
27
|
|
28
|
for opt in s.options:
|
29
|
print "\\subsection{Option \\texttt{%s}}" % opt.name
|
30
|
print "\\begin{description}"
|
31
|
print "\\item[Valid values:]"
|
32
|
if opt.valid:
|
33
|
print ", ".join(["\\texttt{%s}" % v for v in opt.valid])
|
34
|
else:
|
35
|
if opt.type == OPTTYPE_INT:
|
36
|
print "An integer number"
|
37
|
elif opt.type == OPTTYPE_FLOAT:
|
38
|
print "A real number"
|
39
|
elif opt.type == OPTTYPE_STRING:
|
40
|
print "Any string"
|
41
|
elif opt.type == OPTTYPE_BOOLEAN:
|
42
|
print "\\texttt{True} or \\texttt{False}"
|
43
|
elif opt.type == OPTTYPE_DATETIME:
|
44
|
print "An ISO timestamp: i.e., \\texttt{YYYY-MM-DD HH:MM:SS}"
|
45
|
elif opt.type == OPTTYPE_TIMEDELTA:
|
46
|
print "A duration in the format \\texttt{HH:MM:SS}"
|
47
|
|
48
|
print "\\item[Required:]"
|
49
|
if opt.required:
|
50
|
print "Yes"
|
51
|
else:
|
52
|
if opt.required_if:
|
53
|
print "Only if"
|
54
|
print "\\begin{itemize}"
|
55
|
for r in opt.required_if:
|
56
|
sec,o = r[0]
|
57
|
val = r[1]
|
58
|
print "\\item"
|
59
|
print "Option \\texttt{%s} (in section \\texttt{[%s]})" % (o,sec)
|
60
|
print "is set to \\texttt{%s}" % val
|
61
|
print "\\end{itemize}"
|
62
|
else:
|
63
|
print "No"
|
64
|
if opt.default:
|
65
|
print "(default is \\texttt{%s})" % opt.default
|
66
|
|
67
|
print "\\item[Description:]"
|
68
|
optdoc = opt.get_doc()
|
69
|
latexoptdoc = publish_string(optdoc, writer_name="latex")
|
70
|
latexoptdoc = re.compile("\\\\begin{document}\n\n\\\\setlength{\\\\locallinewidth}{\\\\linewidth}\n\n(.*)\\\\end{document}", flags=re.DOTALL).search(latexoptdoc)
|
71
|
print latexoptdoc.group(1)
|
72
|
print "\\end{description}"
|
73
|
print
|
74
|
|