sdoc.sdoc2.formatter.html.HyperlinkHtmlFormatter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 37
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A HyperlinkHtmlFormatter.generate() 0 8 1
A HyperlinkHtmlFormatter.get_html() 0 8 1
1 1
from typing import Any
2
3 1
from sdoc.helper.Html import Html
4 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
5 1
from sdoc.sdoc2.node.HyperlinkNode import HyperlinkNode
6 1
from sdoc.sdoc2.NodeStore import NodeStore
7
8
9 1
class HyperlinkHtmlFormatter(HtmlFormatter):
10
    """
11
    HtmlFormatter for generating HTML code for hyperlinks.
12
    """
13
14
    # ------------------------------------------------------------------------------------------------------------------
15 1
    def generate(self, node: HyperlinkNode, file: Any) -> None:
16
        """
17
        Generates the HTML code for a hyperlink node.
18
19
        :param HyperlinkNode node: The hyperlink node.
20
        :param any file: The output file.
21
        """
22
        file.write(HyperlinkHtmlFormatter.get_html(node))
23
24
    # ------------------------------------------------------------------------------------------------------------------
25 1
    @staticmethod
26 1
    def get_html(node: HyperlinkNode) -> str:
27
        """
28
        Returns string with generated HTML tag.
29
30
        :param HyperlinkNode node: The hyperlink node.
31
        """
32
        return Html.generate_element('a', node.get_html_attributes(), node.argument)
33
34
35
# ----------------------------------------------------------------------------------------------------------------------
36
NodeStore.register_formatter('hyperlink', 'html', HyperlinkHtmlFormatter)
37