ItemHtmlFormatter.generate()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 6
dl 13
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nop 3
crap 1
1 1
from typing import Any
2
3 1
from sdoc.helper.Html import Html
4 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
5 1
from sdoc.sdoc2.node.ItemNode import ItemNode
6 1
from sdoc.sdoc2.NodeStore import NodeStore
7
8
9 1 View Code Duplication
class ItemHtmlFormatter(HtmlFormatter):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10
    """
11
    HtmlFormatter for generating HTML code for items.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def generate(self, node: ItemNode, file: Any) -> None:
16
        """
17
        Generates the HTML code for an item node.
18
19
        :param ItemNode node: The item node.
20
        :param any file: The output file.
21
        """
22 1
        attributes = {'id': node.get_option_value('id')}
23
24 1
        file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id'])))
25 1
        node.prepare_content_tree()
26 1
        HtmlFormatter.generate(self, node, file)
27 1
        file.write('</li>')
28
29
30
# ----------------------------------------------------------------------------------------------------------------------
31
NodeStore.register_formatter('item', 'html', ItemHtmlFormatter)
32