comparison MoinMoin/formatter/text_html.py @ 490:ca35d9e6d63e

eypdoc comments: fixed some warnings/errors imported from: moin--main--1.5--patch-494
author Thomas Waldmann <tw@waldmann-edv.de>
date Wed, 22 Mar 2006 09:03:08 +0000
parents 72e96d74f98d
children 1b9f0d6b9f48
comparison
equal deleted inserted replaced
489:9082a95430db 490:ca35d9e6d63e
49 _common_attributes = Set(['accesskey', 'class', 'dir', 'disabled', 'id', 'lang', 49 _common_attributes = Set(['accesskey', 'class', 'dir', 'disabled', 'id', 'lang',
50 'style', 'tabindex', 'title']) 50 'style', 'tabindex', 'title'])
51 51
52 52
53 def rewrite_attribute_name(name, default_namespace='html'): 53 def rewrite_attribute_name(name, default_namespace='html'):
54 """Takes an attribute name and tries to make it HTML correct. 54 """
55 Takes an attribute name and tries to make it HTML correct.
55 56
56 This function takes an attribute name as a string, as it may be 57 This function takes an attribute name as a string, as it may be
57 passed in to a formatting method using a keyword-argument syntax, 58 passed in to a formatting method using a keyword-argument syntax,
58 and tries to convert it into a real attribute name. This is 59 and tries to convert it into a real attribute name. This is
59 necessary because some attributes may conflict with Python 60 necessary because some attributes may conflict with Python
209 Must be used on all block elements - div, p, table, etc. 210 Must be used on all block elements - div, p, table, etc.
210 @param lang: if defined, will return attributes for lang. if not 211 @param lang: if defined, will return attributes for lang. if not
211 defined, will return attributes only if the current lang is 212 defined, will return attributes only if the current lang is
212 different from the content lang. 213 different from the content lang.
213 @rtype: dict 214 @rtype: dict
214 @retrun: language attributes 215 @return: language attributes
215 """ 216 """
216 if not lang: 217 if not lang:
217 lang = self.request.current_lang 218 lang = self.request.current_lang
218 # Actions that generate content in user language should change 219 # Actions that generate content in user language should change
219 # the content lang from the default defined in cfg. 220 # the content lang from the default defined in cfg.
228 def _formatAttributes(self, attr=None, allowed_attrs=None, **kw): 229 def _formatAttributes(self, attr=None, allowed_attrs=None, **kw):
229 """ Return HTML attributes formatted as a single string. (INTERNAL USE BY HTML FORMATTER ONLY!) 230 """ Return HTML attributes formatted as a single string. (INTERNAL USE BY HTML FORMATTER ONLY!)
230 231
231 @param attr: dict containing keys and values 232 @param attr: dict containing keys and values
232 @param allowed_attrs: A list of allowable attribute names 233 @param allowed_attrs: A list of allowable attribute names
233 @param **kw: other arbitrary attributes expressed as keyword arguments. 234 @param kw: other arbitrary attributes expressed as keyword arguments.
234 @rtype: string 235 @rtype: string
235 @return: formated attributes or empty string 236 @return: formated attributes or empty string
236 237
237 The attributes and their values can either be given in the 238 The attributes and their values can either be given in the
238 'attr' dictionary, or as extra keyword arguments. They are 239 'attr' dictionary, or as extra keyword arguments. They are
520 html_class = 'interwiki' 521 html_class = 'interwiki'
521 title = kw.get('title', wikitag) 522 title = kw.get('title', wikitag)
522 return self.url(1, href, title=title, do_escape=1, css=html_class) # interwiki links with umlauts 523 return self.url(1, href, title=title, do_escape=1, css=html_class) # interwiki links with umlauts
523 524
524 def url(self, on, url=None, css=None, do_escape=0, **kw): 525 def url(self, on, url=None, css=None, do_escape=0, **kw):
525 """ Inserts an <a> element. 526 """
526 527 Inserts an <a> element.
527 Call once with on=1 to start the link, and again with on=0 528
528 to end it (no other arguments are needed when on==0). 529 Call once with on=1 to start the link, and again with on=0
529 530 to end it (no other arguments are needed when on==0).
530 do_escape: XXX doesn't work yet 531
531 532 do_escape: XXX doesn't work yet
532 Keyword params: 533
533 url - the URL to link to; will go through Wiki URL mapping. 534 Keyword params:
534 css - a space-separated list of CSS classes 535 url - the URL to link to; will go through Wiki URL mapping.
535 attrs - just include this string verbatim inside 536 css - a space-separated list of CSS classes
536 the <a> element; can be used for arbitrary attrs; 537 attrs - just include this string verbatim inside
537 all escaping and quoting is the caller's responsibility. 538 the <a> element; can be used for arbitrary attrs;
538 539 all escaping and quoting is the caller's responsibility.
539 Note that the 'attrs' keyword argument is for backwards compatibility 540
540 only. It should not be used for new code--instead just pass 541 Note that the 'attrs' keyword argument is for backwards compatibility
541 any attributes in as separate keyword arguments. 542 only. It should not be used for new code--instead just pass
543 any attributes in as separate keyword arguments.
542 """ 544 """
543 if not on: 545 if not on:
544 return self._close('a') 546 return self._close('a')
545 attrs = self._langAttr() 547 attrs = self._langAttr()
546 548
1245 1247
1246 Convert from wikitable attributes to html 4 attributes. 1248 Convert from wikitable attributes to html 4 attributes.
1247 1249
1248 @param attrs: attribute dict 1250 @param attrs: attribute dict
1249 @param prefix: used in wiki table attributes 1251 @param prefix: used in wiki table attributes
1250 @rtyp: dict 1252 @rtype: dict
1251 @return: valid table attributes 1253 @return: valid table attributes
1252 """ 1254 """
1253 if not attrs: 1255 if not attrs:
1254 return {} 1256 return {}
1255 1257