1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# Copyright (c) 2007-2010 testdoc authors. See LICENSE for details.
"""Formatters for creating documents.
A formatter is an object which accepts an output stream (usually a file or
standard output) and then provides a structured way for writing to that stream.
All formatters should provide 'title', 'section', 'subsection' and 'paragraph'
methods which write to the stream.
"""
class WikiFormatter(object):
"""Moin formatter."""
def __init__(self, stream):
self.stream = stream
def writeln(self, line):
self.stream.write('%s\n' % (line,))
def title(self, name):
self.writeln('= %s =\n' % (name,))
def section(self, name):
self.writeln('')
self.writeln('== %s ==\n' % (name,))
def subsection(self, name):
self.writeln('=== %s ===\n' % (name,))
def paragraph(self, text):
self.writeln('%s\n' % (text.strip(),))
|