Completed
Push — master ( 793cf7...172351 )
by P.R.
04:33
created

ItemHtmlFormatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 28.57%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 18
ccs 2
cts 7
cp 0.2857
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 import node_store
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 1
    def generate(self, node, file):
20
        """
21
        Generates the HTML code for an item node.
22
23
        :param sdoc.sdoc2.node.ItemNode.ItemNode node: The item node.
24
        :param file file: The output file.
25
        """
26
        attributes = {'id': node.get_option_value('id')}
27
28
        file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id'])))
29
        node.prepare_content_tree()
30
        HtmlFormatter.generate(self, node, file)
31
        file.write('</li>')
32
33
# ----------------------------------------------------------------------------------------------------------------------
34
node_store.register_formatter('item', 'html', ItemHtmlFormatter)
35