Completed
Pull Request — master (#22)
by Oleg
01:36
created

generate_chapter()   A

Complexity

Conditions 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 9
rs 9.6666
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from sdoc.helper.Html import Html
10
from sdoc.sdoc2 import node_store
11
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
12
13
14
class HyperlinkHtmlFormatter(HtmlFormatter):
15
    """
16
    HtmlFormatter for generating HTML code for hyperlinks.
17
    """
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def generate(self, node, file):
20
        """
21
        Generates the HTML code for a hyperlink node.
22
23
        :param sdoc.sdoc2.node.HyperlinkNode.HyperlinkNode node: The hyperlink node.
24
        :param file file: The output file.
25
        """
26
        file.write(Html.generate_element('a', node.get_html_attributes(), node.argument))
27
28
    # ------------------------------------------------------------------------------------------------------------------
29
    def generate_chapter(self, node, file):
30
        """
31
        Generates the HTML code for a hyperlink node.
32
33
        :param sdoc.sdoc2.node.HyperlinkNode.HyperlinkNode node: The hyperlink node.
34
        :param file file: The output file.
35
        """
36
        if file:
37
            file.write(Html.generate_element('a', node.get_html_attributes(), node.argument))
38
39
# ----------------------------------------------------------------------------------------------------------------------
40
node_store.register_formatter('hyperlink', 'html', HyperlinkHtmlFormatter)
41