UnknownHtmlFormatter.generate_chapter()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 3

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 1
CRAP Score 3.1852

Importance

Changes 0
Metric Value
eloc 3
dl 9
loc 9
ccs 1
cts 3
cp 0.3333
rs 10
c 0
b 0
f 0
cc 2
nop 3
crap 3.1852
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