Mercurial > libervia-backend
comparison src/bridge/bridge_constructor/bridge_contructor.py @ 377:aa2cd6639e00
Bridge Constructor: added anchor link in mediawiki constructor
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Aug 2011 14:07:55 +0200 |
parents | 502489e17685 |
children | 3646f6b9adb6 |
comparison
equal
deleted
inserted
replaced
376:9ffae6abdb05 | 377:aa2cd6639e00 |
---|---|
224 def __init__(self, bridge_template, options): | 224 def __init__(self, bridge_template, options): |
225 Constructor.__init__(self, bridge_template, options) | 225 Constructor.__init__(self, bridge_template, options) |
226 self.core_template="mediawiki_template.tpl" | 226 self.core_template="mediawiki_template.tpl" |
227 self.core_dest="mediawiki.wiki" | 227 self.core_dest="mediawiki.wiki" |
228 | 228 |
229 def _addTextDecorations(self, text): | |
230 """Add text decorations like coloration or shortcuts""" | |
231 | |
232 def anchor_link(match): | |
233 link = match.group(1) | |
234 #we add anchor_link for [method_name] syntax: | |
235 if link in self.bridge_template.sections(): | |
236 return "[[#%s|%s]]" % (link, link) | |
237 print ("WARNING: found an anchor link to an unknown method") | |
238 return link | |
239 | |
240 return re.sub(r"\[(\w+)\]", anchor_link, text) | |
241 | |
229 def _wikiParameter(self, name, sig_in): | 242 def _wikiParameter(self, name, sig_in): |
230 """Format parameters with the wiki syntax | 243 """Format parameters with the wiki syntax |
231 @param name: name of the function | 244 @param name: name of the function |
232 @param sig_in: signature in | 245 @param sig_in: signature in |
233 @return: string of the formated parameters""" | 246 @return: string of the formated parameters""" |
238 wiki=[] | 251 wiki=[] |
239 for i in range(len(args)): | 252 for i in range(len(args)): |
240 if arg_doc.has_key(i): | 253 if arg_doc.has_key(i): |
241 name,doc=arg_doc[i] | 254 name,doc=arg_doc[i] |
242 doc='\n:'.join(doc.rstrip('\n').split('\n')) | 255 doc='\n:'.join(doc.rstrip('\n').split('\n')) |
243 wiki.append("; %s: %s" % (name, doc)) | 256 wiki.append("; %s: %s" % (name, self._addTextDecorations(doc))) |
244 else: | 257 else: |
245 wiki.append("; arg_%d: " % i) | 258 wiki.append("; arg_%d: " % i) |
246 if arg_default.has_key(i): | 259 if arg_default.has_key(i): |
247 wiki.append(":''DEFAULT: %s''" % arg_default[i]) | 260 wiki.append(":''DEFAULT: %s''" % arg_default[i]) |
248 return "\n".join(wiki) | 261 return "\n".join(wiki) |
253 """ | 266 """ |
254 arg_doc = self.getArgumentsDoc(name) | 267 arg_doc = self.getArgumentsDoc(name) |
255 wiki=[] | 268 wiki=[] |
256 if arg_doc.has_key('return'): | 269 if arg_doc.has_key('return'): |
257 wiki.append('\n|-\n! scope=row | return value\n|') | 270 wiki.append('\n|-\n! scope=row | return value\n|') |
258 wiki.append('<br />\n'.join(arg_doc['return'].rstrip('\n').split('\n'))) | 271 wiki.append('<br />\n'.join(self._addTextDecorations(arg_doc['return']).rstrip('\n').split('\n'))) |
259 return "\n".join(wiki) | 272 return "\n".join(wiki) |
260 | 273 |
261 def generateCoreSide(self): | 274 def generateCoreSide(self): |
262 signals_part = [] | 275 signals_part = [] |
263 methods_part = [] | 276 methods_part = [] |