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

sdoc.sdoc2.formatter.html.DocumentHtmlFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %
Metric Value
dl 0
loc 31
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 16 1
A generate_chapter() 0 8 1
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 DocumentHtmlFormatter(HtmlFormatter):
14
    """
15
    HtmlFormatter for generating HTML code for document.
16
    """
17
    # ------------------------------------------------------------------------------------------------------------------
18
    def generate(self, node, file):
19
        """
20
        Generates the HTML code for a document node.
21
22
        :param sdoc.sdoc2.node.DocumentNode.DocumentNode node: The document node.
23
        :param file file: The output file.
24
        """
25
        file.write('<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="NL" lang="NL">')
26
        file.write('<head><meta charset="UTF-8"/><title>sdoc</title></head>')
27
        file.write('<body>')
28
29
        super().generate(node, file)
30
31
        file.write('</body>')
32
        file.write('</html>')
33
        file.close()
34
35
    # ------------------------------------------------------------------------------------------------------------------
36
    def generate_chapter(self, node, file):
37
        """
38
        Passing the document node, because not used in generating chapters of a document.
39
40
        :param sdoc.sdoc2.node.DocumentNode.DocumentNode node: The document node.
41
        :param file file: The output file.
42
        """
43
        super().generate_chapter(node, file)
44
45
# ----------------------------------------------------------------------------------------------------------------------
46
node_store.register_formatter('document', 'html', DocumentHtmlFormatter)
47