paul@333 | 1 | #!/usr/bin/env python |
paul@333 | 2 | |
paul@333 | 3 | """ |
paul@333 | 4 | Prettyprinted text serialiser for Graphviz nodes. |
paul@333 | 5 | |
paul@333 | 6 | Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> |
paul@333 | 7 | |
paul@333 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@333 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@333 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@333 | 11 | version. |
paul@333 | 12 | |
paul@333 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@333 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@333 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@333 | 16 | details. |
paul@333 | 17 | |
paul@333 | 18 | You should have received a copy of the GNU General Public License along with |
paul@333 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@333 | 20 | """ |
paul@333 | 21 | |
paul@333 | 22 | from moinformat.serialisers.pretty.common import Serialiser |
paul@333 | 23 | |
paul@333 | 24 | class GraphvizSerialiser(Serialiser): |
paul@333 | 25 | |
paul@333 | 26 | "Serialisation of Graphviz nodes for inspection." |
paul@333 | 27 | |
paul@333 | 28 | input_formats = ["dot", "graphviz"] |
paul@333 | 29 | formats = ["pretty"] |
paul@333 | 30 | |
paul@333 | 31 | # Node handler methods. |
paul@333 | 32 | |
paul@342 | 33 | def block(self, block): |
paul@342 | 34 | self.out("%sBlock\n" % self.output.indent) |
paul@342 | 35 | self.container(block) |
paul@342 | 36 | |
paul@333 | 37 | def directive(self, directive): |
paul@333 | 38 | self.out("%sDirective: key=%r value=%r directive=%r\n" % ( |
paul@333 | 39 | self.output.indent, directive.key, directive.value, |
paul@333 | 40 | directive.directive)) |
paul@333 | 41 | |
paul@342 | 42 | def text(self, text): |
paul@342 | 43 | self.out("%sText: %r\n" % (self.output.indent, text.s)) |
paul@342 | 44 | |
paul@333 | 45 | serialiser = GraphvizSerialiser |
paul@333 | 46 | |
paul@333 | 47 | # vim: tabstop=4 expandtab shiftwidth=4 |