Completed
Push — master ( 5db226...8f2faa )
by P.R.
03:03
created

ItemHtmlFormatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 1
c 2
b 1
f 0
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 13 1
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9 1
from sdoc.helper.Html import Html
10 1
from sdoc.sdoc2.NodeStore import NodeStore
11 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
12
13
14 1
class ItemHtmlFormatter(HtmlFormatter):
15
    """
16
    HtmlFormatter for generating HTML code for items.
17
    """
18
19
    # ------------------------------------------------------------------------------------------------------------------
20 1
    def generate(self, node, file):
21
        """
22
        Generates the HTML code for an item node.
23
24
        :param sdoc.sdoc2.node.ItemNode.ItemNode node: The item node.
25
        :param file file: The output file.
26
        """
27 1
        attributes = {'id': node.get_option_value('id')}
28
29 1
        file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id'])))
30 1
        node.prepare_content_tree()
31 1
        HtmlFormatter.generate(self, node, file)
32 1
        file.write('</li>')
33
34
35
# ----------------------------------------------------------------------------------------------------------------------
36
NodeStore.register_formatter('item', 'html', ItemHtmlFormatter)
37