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

sdoc.format.HtmlFormat.one_file()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 8
rs 9.4285
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8
# ----------------------------------------------------------------------------------------------------------------------
9
from sdoc.error import SDocError
10
from sdoc.format.Format import Format
11
12
13
class HtmlFormat(Format):
14
    """
15
    Class for generating HTML
16
    """
17
18
    # ------------------------------------------------------------------------------------------------------------------
19
    def __init__(self, config):
20
        """
21
        Object constructor.
22
23
        :param configparser.SectionProxy config: The section in the config file for the target_format.
24
        """
25
        super().__init__(config)
26
27
        self._enumerate = True
28
        """
29
        If set chapters, sections, etc. must be numbered.
30
31
        :type: bool
32
        """
33
34
        self._file_per_chapter = False
35
        """
36
        If set, will generate multiple .html files for each chapter.
37
38
        :type: bool
39
        """
40
41
        self._one_file = True
42
        """
43
        If set, will generate one .html file.
44
45
        :type: bool
46
        """
47
48
        self._read_configuration(config)
49
50
    # ------------------------------------------------------------------------------------------------------------------
51
    def _read_configuration(self, config):
52
        """
53
        Reads the configuration for this formatter.
54
55
        :param configparser.SectionProxy config: The section in the config file for the target_format.
56
        """
57
        try:
58
            self._enumerate = config.getboolean('enumerate', fallback=self._enumerate)
59
        except ValueError:
60
            raise SDocError("Option 'enumerate' not set correctly")
61
62
        try:
63
            self._file_per_chapter = config.getboolean('file_per_chapter', fallback=self._file_per_chapter)
64
        except ValueError:
65
            raise SDocError("Option 'file_per_chapter' not set correctly")
66
67
        try:
68
            self._one_file = config.getboolean('one_file', fallback=self._one_file)
69
        except ValueError:
70
            raise SDocError("Option 'one_file' not set correctly")
71
72
    # ------------------------------------------------------------------------------------------------------------------
73
    @property
74
    def enumerate(self):
75
        """
76
        Getter for enumerate attribute.
77
78
        :rtype: bool
79
        """
80
        return self._enumerate
81
82
    # ------------------------------------------------------------------------------------------------------------------
83
    @property
84
    def file_per_chapter(self):
85
        """
86
        Getter for file_per_chapter attribute.
87
88
        :rtype: bool
89
        """
90
        return self._file_per_chapter
91
92
    # ------------------------------------------------------------------------------------------------------------------
93
    @property
94
    def one_file(self):
95
        """
96
        Getter for one_file attribute.
97
98
        :rtype: bool
99
        """
100
        return self._one_file
101
102
    # ------------------------------------------------------------------------------------------------------------------
103
    def generate(self):
104
        pass
105
106
# ----------------------------------------------------------------------------------------------------------------------
107