Completed
Push — master ( 57e7bf...8a74a7 )
by P.R.
01:36
created

ParagraphHtmlFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %
Metric Value
wmc 3
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 10 1
A generate_chapter() 0 13 2
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from sdoc.sdoc2 import node_store
10
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
11
12
13
class ParagraphHtmlFormatter(HtmlFormatter):
14
    """
15
    HtmlFormatter for generating HTML code for paragraph.
16
    """
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def generate(self, node, file):
19
        """
20
        Generates the HTML code for a paragraph node.
21
22
        :param sdoc.sdoc2.node.ParagraphNode.ParagraphNode node: The paragraph node.
23
        :param file file: The output file.
24
        """
25
        file.write('<p>')
26
        super().generate(node, file)
27
        file.write('</p>')
28
29
    # ------------------------------------------------------------------------------------------------------------------
30
    def generate_chapter(self, node, file):
31
        """
32
        Generates the HTML code for a paragraph node.
33
34
        :param sdoc.sdoc2.node.ParagraphNode.ParagraphNode node: The paragraph node.
35
        :param file file: The output file.
36
        """
37
        if file:
38
            file.write('<p>')
39
            super().generate_chapter(node, file)
40
            file.write('</p>')
41
        else:
42
            super().generate_chapter(node, file)
43
44
# ----------------------------------------------------------------------------------------------------------------------
45
node_store.register_formatter('paragraph', 'html', ParagraphHtmlFormatter)
46