UnknownHtmlFormatter.write_into_file()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 7
loc 7
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nop 2
crap 1
1 1
from typing import Any
2
3 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
4 1
from sdoc.sdoc2.node.Node import Node
5 1
from sdoc.sdoc2.NodeStore import NodeStore
6
7
8 1 View Code Duplication
class UnknownHtmlFormatter(HtmlFormatter):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9
    """
10
    HtmlFormatter for unknown SDoc2 node types.
11
    """
12
13
    # ------------------------------------------------------------------------------------------------------------------
14 1
    def generate(self, node: Node, file: Any) -> None:
15
        """
16
        Generates the HTML code for an unknown node.
17
18
        :param Node node: The unknown node.
19
        :param any file: The output file.
20
        """
21 1
        self.write_into_file(node)
22
23
    # ------------------------------------------------------------------------------------------------------------------
24 1
    def generate_chapter(self, node: Node, file: Any) -> None:
25
        """
26
        Generates the HTML code for an unknown node.
27
28
        :param Node node: The unknown node.
29
        :param any file: The output file.
30
        """
31
        if file:
32
            self.write_into_file(node)
33
34
    # ------------------------------------------------------------------------------------------------------------------
35 1
    def write_into_file(self, node: Node):
36
        """
37
        Writes into opened file.
38
39
        :param Node node: The unknown node.
40
        """
41 1
        self.error('Unknown SDoc2 command {0}'.format(node.name), node)
42
43
44
# ----------------------------------------------------------------------------------------------------------------------
45
NodeStore.register_formatter('unknown', 'html', UnknownHtmlFormatter)
46