parameter metadata parser: escape wiki characters

This commit is contained in:
Andreas M. Antonopoulos 2012-07-04 20:55:55 -07:00
parent a71f567d28
commit 6509ed74cd
1 changed files with 10 additions and 2 deletions

View File

@ -19,16 +19,23 @@ def camelcase_escape(word):
else: else:
return word return word
def wikichars_escape(text):
for c in "*,{,},[,],_,=,#,^,~,!,@,$,|,<,>,&,|,\,/".split(','):
text = re.sub("\\"+c, '`'+c+'`', text)
return text
def wiki_parameters(g, f): def wiki_parameters(g, f):
t = "\n\n== %s Parameters ==\n" % (camelcase_escape(g.name)) t = "\n\n== %s Parameters ==\n" % (camelcase_escape(g.name))
for param in g.params: for param in g.params:
t += "\n\n=== %s (%s) ===" % (camelcase_escape(param.DisplayName),camelcase_escape(param.name)) t += "\n\n=== %s (%s) ===" % (camelcase_escape(param.DisplayName),camelcase_escape(param.name))
t += "\n\n_%s_\n" % param.Description t += "\n\n_%s_\n" % wikichars_escape(param.Description)
for field in param.__dict__.keys(): for field in param.__dict__.keys():
if field not in ['name', 'DisplayName', 'Description', 'User'] and field in known_param_fields: if field not in ['name', 'DisplayName', 'Description', 'User'] and field in known_param_fields:
t += " * %s: %s\n" % (camelcase_escape(field), param.__dict__[field]) t += " * %s: %s\n" % (camelcase_escape(field), wikichars_escape(param.__dict__[field]))
#print t #print t
f.write(t) f.write(t)
@ -146,3 +153,4 @@ for library in libraries:
wiki_parameters(library, f) wiki_parameters(library, f)
f.close f.close