Completed
Pull Request — master (#49)
by Oleg
02:14
created

VersionHtmlFormatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 17
ccs 2
cts 5
cp 0.4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 11 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 VersionHtmlFormatter(HtmlFormatter):
15
    """
16
    HtmlFormatter for generating HTML code for version of SDoc document.
17
    """
18
19
    # ------------------------------------------------------------------------------------------------------------------
20 1
    def generate(self, node, file):
21
        """
22
        Generates HTML code for a version node.
23
24
        :param sdoc.sdoc2.node.VersionNode.VersionNode node: The version node.
25
        :param file file: The output file.
26
        """
27
        text = 'Version: {}'.format(node.argument)
28
        html_code = Html.generate_element('h3', {}, text)
29
30
        file.write(html_code)
31
32
# ----------------------------------------------------------------------------------------------------------------------
33
NodeStore.register_formatter('version', 'html', VersionHtmlFormatter)
34