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

DateHtmlFormatter.generate()   A

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.4218

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 1
cts 4
cp 0.25
rs 9.4285
cc 1
crap 1.4218
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 DateHtmlFormatter(HtmlFormatter):
15
    """
16
    HtmlFormatter for generating HTML code for date of SDoc document.
17
    """
18
19
    # ------------------------------------------------------------------------------------------------------------------
20 1
    def generate(self, node, file):
21
        """
22
        Generates HTML code for a date node.
23
24
        :param sdoc.sdoc2.node.DateNode.DateNode node: The date node.
25
        :param file file: The output file.
26
        """
27
        text = 'Date: {}'.format(node.argument)
28
        html_code = Html.generate_element('h3', {}, text)
29
30
        file.write(html_code)
31
32
# ----------------------------------------------------------------------------------------------------------------------
33
NodeStore.register_formatter('date', 'html', DateHtmlFormatter)
34