Return to index

Module rstdoc.traclib.wiki_filter


Module wiki_filter

Convert TracLinks into RestructuredText roles. The following examples illustrate the use of TracLinks in Python DocStrings.

  • `AWikiPage`: A link to AWikiPage
  • #1: A link to a ticket #1
  • {1}: A link to a report {1}
  • r1 or [1]: A link to a change set r1 or [1]
  • r1:2 or [1:2]: A link to a revision log r1:2 or [1:2]
  • :browser:`trunk/some/file.py source repository`: A link to the source repository.

The preceeding can be escaped by prepending them with a '!' (bang). Note that change set and log links do not currently work for the bzr repository backend because they do not use numeric revisions.

Imports:
itertools, re, unittest
Methods:
testSuite():
wikiFilter(string): Convert Trac Wiki syntax to reStructured Text interpreted text roles.
Attributes:
escapes = [('(\\s|\\A)!`([^`]+)`', '\\1\\\\`\\2\\\\`'), ('!#(\\d+)([^:\\d])', '#\\1\\2'), ('!(\\{\\d+\\})', '\\1'), ('!(r\\d+:\\d+)', '\\1'), ('!(\\[\\d+:\\d+\\])', '\\1'), ('!(r\\d+)([^\\d:])', '\\1\\2'), ('!(\\[\\d+\\])', '\\1')]
escapes = [(re.compile(escape), replace) for (escape, replace) in escapes]
patterns = [('(\\s|\\A)`([^`]+)`', '\\1:wiki:`\\2`'), ('(\\s|\\A)#([\\d]+)([^:\\d])', '\\1:ticket:`\\2 #\\2`\\3'), ('(\\s|\\A)\\{(\\d+)\\}', '\\1:report:`\\2 {\\2}`'), ('(\\s|\\A)r(\\d+:\\d+)', '\\1:log:`\\2 r\\2`'), ('(\\s|\\A)\\[(\\d+:\\d+)\\]', '\\1:log:`\\2 [\\2]`'), ('(\\s|\\A)r(\\d+)[^\\d:]', '\\1:changeset:`\\2 r\\2`'), ('(\\s|\\A)\\[(\\d+)\\]', '\\1:changeset:`\\2 [\\2]`')]
patterns = [(re.compile(search), replace) for (search, replace) in patterns]

Method wiki_filter.testSuite

Back to wiki_filter

Arguments:
Imports:
doctest, test_wiki_filter