Completed
Push — master ( d0bff5...613540 )
by P.R.
02:06
created

UnknownHtmlFormatter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
dl 0
loc 34
ccs 6
cts 8
cp 0.75
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 8 1
A write_into_file() 0 7 1
A generate_chapter() 0 9 2
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9 1
from sdoc.sdoc2.NodeStore import NodeStore
10 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
11
12
13 1
class UnknownHtmlFormatter(HtmlFormatter):
14
    """
15
    HtmlFormatter for unknown SDoc2 node types.
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19 1
    def generate(self, node, file):
20
        """
21
        Generates the HTML code for a paragraph node.
22
23
        :param sdoc.sdoc2.node.Node.Node node: The unknown node.
24
        :param file file: The output file.
25
        """
26 1
        self.write_into_file(node)
27
28
    # ------------------------------------------------------------------------------------------------------------------
29 1
    def generate_chapter(self, node, file):
30
        """
31
        Generates the HTML code for a paragraph node.
32
33
        :param sdoc.sdoc2.node.Node.Node node: The unknown node.
34
        :param file file: The output file.
35
        """
36
        if file:
37
            self.write_into_file(node)
38
39
    # ------------------------------------------------------------------------------------------------------------------
40 1
    def write_into_file(self, node):
41
        """
42
        Writes into opened file.
43
44
        :param sdoc.sdoc2.node.Node.Node node: The unknown node.
45
        """
46 1
        self.error('Unknown SDoc2 command {0}'.format(node.name), node)
47
48
49
# ----------------------------------------------------------------------------------------------------------------------
50
NodeStore.register_formatter('unknown', 'html', UnknownHtmlFormatter)
51