Improve DokuWiki formatting.

This commit is contained in:
Stefan Rado 2014-02-19 01:54:01 +01:00
parent 8d41155fb6
commit ec78fcf2b9
1 changed files with 18 additions and 23 deletions

View File

@ -3,11 +3,14 @@ import codecs
class DokuWikiTablesOutput(): class DokuWikiTablesOutput():
def __init__(self, groups): def __init__(self, groups):
result = "====== Parameter Reference ======\nThis list is auto-generated every few minutes and contains the most recent parameter names and default values.\n\n" result = ("====== Parameter Reference ======\n"
"<note>**This list is auto-generated from the source code** and contains the most recent parameter documentation.</note>\n"
"\n")
for group in groups: for group in groups:
result += "==== %s ====\n\n" % group.GetName() result += "==== %s ====\n\n" % group.GetName()
result += "|< 100% 20% 20% 10% 10% 10% 30%>|\n" result += "|< 100% 25% 45% 10% 10% 10% >|\n"
result += "^ Name ^ Description ^ Min ^ Max ^ Default ^ Comment ^\n" result += "^ Name ^ Description ^ Min ^ Max ^ Default ^\n"
result += "^ ::: ^ Comment ^^^^\n"
for param in group.GetParams(): for param in group.GetParams():
code = param.GetFieldValue("code") code = param.GetFieldValue("code")
name = param.GetFieldValue("short_desc") name = param.GetFieldValue("short_desc")
@ -16,31 +19,23 @@ class DokuWikiTablesOutput():
def_val = param.GetFieldValue("default") def_val = param.GetFieldValue("default")
long_desc = param.GetFieldValue("long_desc") long_desc = param.GetFieldValue("long_desc")
name = name.replace("\n", " ") if name == code:
result += "| %s | %s |" % (code, name) name = ""
if min_val is not None:
result += " %s |" % min_val
else: else:
result += " |" name = name.replace("\n", " ")
name = name.replace("|", "%%|%%")
name = name.replace("^", "%%^%%")
if max_val is not None: result += "| **%s** |" % code
result += " %s |" % max_val result += " %s |" % name
else: result += " %s |" % (min_val or "")
result += " |" result += " %s |" % (max_val or "")
result += " %s |" % (def_val or "")
if def_val is not None: result += "\n"
result += " %s |" % def_val
else:
result += " |"
if long_desc is not None: if long_desc is not None:
long_desc = long_desc.replace("\n", " ") result += "| ::: | <div>%s</div> ||||\n" % long_desc
result += " %s |" % long_desc
else:
result += " |"
result += "\n"
result += "\n" result += "\n"
self.output = result; self.output = result;