File: pyevolve_tooltip.py

package info (click to toggle)
pyevolve 0.6~rc1%2Bsvn398%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,060 kB
  • ctags: 832
  • sloc: python: 5,119; xml: 183; sh: 71; makefile: 38
file content (20 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
    Tooltip Sphinx extension

    :copyright: Copyright 2010 by Christian S. Perone
    :license: PSF, see LICENSE for details.

"""
from sphinx.util.compat import Directive
from docutils import nodes
import re

def tip_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    matches = re.match("\<(?P<word>\w+)\> (?P<tip>.*)", text)
    matches_tuple = matches.group("tip"), matches.group("word")
    template = """<span class="ttip" title="%s">%s</span>""" % matches_tuple
    node = nodes.raw('', template, format='html')
    return [node], []

def setup(app):
    app.add_role('tip', tip_role)