MoinLight

Annotated moinformat/serialisers/moin/graphviz.py

188:524700c23195
2018-11-27 Paul Boddie Support serialisation of both forms of Graphviz region directive.
paul@101 1
#!/usr/bin/env python
paul@101 2
paul@101 3
"""
paul@101 4
Moin Graphviz region serialiser.
paul@101 5
paul@101 6
Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
paul@101 7
paul@101 8
This program is free software; you can redistribute it and/or modify it under
paul@101 9
the terms of the GNU General Public License as published by the Free Software
paul@101 10
Foundation; either version 3 of the License, or (at your option) any later
paul@101 11
version.
paul@101 12
paul@101 13
This program is distributed in the hope that it will be useful, but WITHOUT
paul@101 14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
paul@101 15
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
paul@101 16
details.
paul@101 17
paul@101 18
You should have received a copy of the GNU General Public License along with
paul@101 19
this program.  If not, see <http://www.gnu.org/licenses/>.
paul@101 20
"""
paul@101 21
paul@101 22
from moinformat.serialisers.common import Serialiser
paul@101 23
paul@101 24
class MoinGraphvizSerialiser(Serialiser):
paul@101 25
paul@101 26
    "Serialisation of the page."
paul@101 27
paul@101 28
    def start_block(self):
paul@101 29
        pass
paul@101 30
paul@101 31
    def end_block(self):
paul@101 32
        pass
paul@101 33
paul@188 34
    def directive(self, key, value, directive):
paul@188 35
        if directive:
paul@188 36
            self.out("#%s\n" % directive)
paul@188 37
        else:
paul@188 38
            self.out("//%s%s\n" % (value and "%s=" % key or key, value or ""))
paul@101 39
paul@101 40
    def text(self, text):
paul@101 41
        self.out(text)
paul@101 42
paul@101 43
serialiser = MoinGraphvizSerialiser
paul@101 44
paul@101 45
# vim: tabstop=4 expandtab shiftwidth=4