Completed
Push — master ( 793cf7...172351 )
by P.R.
04:33
created

DocumentHtmlFormatter.generate_chapter()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 1
cts 2
cp 0.5
rs 9.4285
c 0
b 0
f 0
cc 1
crap 1.125
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9 1
from sdoc.sdoc2 import node_store
10 1
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter
11
12
13 1
class DocumentHtmlFormatter(HtmlFormatter):
14
    """
15
    HtmlFormatter for generating HTML code for document.
16
    """
17
    # ------------------------------------------------------------------------------------------------------------------
18 1
    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
        HtmlFormatter.generate(self, node, file)
30
31
        file.write('</body>')
32
        file.write('</html>')
33
        file.close()
34
35
# ----------------------------------------------------------------------------------------------------------------------
36
node_store.register_formatter('document', 'html', DocumentHtmlFormatter)
37