# HG changeset patch # User Goffi # Date 1313150875 -7200 # Node ID aa2cd6639e001c176f4f609e85dea0b871c126aa # Parent 9ffae6abdb05fc3c53b6d8f6da771476136fc6d4 Bridge Constructor: added anchor link in mediawiki constructor diff -r 9ffae6abdb05 -r aa2cd6639e00 src/bridge/bridge_constructor/bridge_contructor.py --- a/src/bridge/bridge_constructor/bridge_contructor.py Thu Aug 11 18:36:22 2011 +0200 +++ b/src/bridge/bridge_constructor/bridge_contructor.py Fri Aug 12 14:07:55 2011 +0200 @@ -226,6 +226,19 @@ self.core_template="mediawiki_template.tpl" self.core_dest="mediawiki.wiki" + def _addTextDecorations(self, text): + """Add text decorations like coloration or shortcuts""" + + def anchor_link(match): + link = match.group(1) + #we add anchor_link for [method_name] syntax: + if link in self.bridge_template.sections(): + return "[[#%s|%s]]" % (link, link) + print ("WARNING: found an anchor link to an unknown method") + return link + + return re.sub(r"\[(\w+)\]", anchor_link, text) + def _wikiParameter(self, name, sig_in): """Format parameters with the wiki syntax @param name: name of the function @@ -240,7 +253,7 @@ if arg_doc.has_key(i): name,doc=arg_doc[i] doc='\n:'.join(doc.rstrip('\n').split('\n')) - wiki.append("; %s: %s" % (name, doc)) + wiki.append("; %s: %s" % (name, self._addTextDecorations(doc))) else: wiki.append("; arg_%d: " % i) if arg_default.has_key(i): @@ -255,7 +268,7 @@ wiki=[] if arg_doc.has_key('return'): wiki.append('\n|-\n! scope=row | return value\n|') - wiki.append('
\n'.join(arg_doc['return'].rstrip('\n').split('\n'))) + wiki.append('
\n'.join(self._addTextDecorations(arg_doc['return']).rstrip('\n').split('\n'))) return "\n".join(wiki) def generateCoreSide(self):