1
|
|
|
""" |
2
|
|
|
SDoc |
3
|
|
|
|
4
|
|
|
Copyright 2016 Set Based IT Consultancy |
5
|
|
|
|
6
|
|
|
Licence MIT |
7
|
|
|
""" |
8
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
9
|
1 |
|
from sdoc.sdoc2.NodeStore import NodeStore |
10
|
1 |
|
from sdoc.sdoc2.node.HeadingNode import HeadingNode |
11
|
1 |
|
from sdoc.sdoc2.helper.Enumerable import Enumerable |
12
|
|
|
|
13
|
|
|
|
14
|
1 |
|
class PartNode(HeadingNode): |
15
|
|
|
""" |
16
|
|
|
SDoc2 node for parts. |
17
|
|
|
""" |
18
|
|
|
|
19
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
20
|
1 |
|
def __init__(self, io, options, argument): |
21
|
|
|
""" |
22
|
|
|
PartNode constructor |
23
|
|
|
|
24
|
|
|
:param None|cleo.styles.output_style.OutputStyle io: The IO object. |
25
|
|
|
:param dict[str, str] options: The options of this part. |
26
|
|
|
:param str argument: The title of this part. |
27
|
|
|
""" |
28
|
|
|
super().__init__(io, 'part', options, argument) |
29
|
|
|
|
30
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
31
|
1 |
|
def get_command(self): |
32
|
|
|
""" |
33
|
|
|
Returns command of this node (i.e. 'part'). |
34
|
|
|
|
35
|
|
|
:rtype: str |
36
|
|
|
""" |
37
|
|
|
return 'part' |
38
|
|
|
|
39
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
40
|
1 |
|
def get_hierarchy_level(self, parent_hierarchy_level=-1): |
41
|
|
|
""" |
42
|
|
|
Returns 0. |
43
|
|
|
|
44
|
|
|
:rtype: int |
45
|
|
|
""" |
46
|
|
|
return 0 |
47
|
|
|
|
48
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
49
|
1 |
|
def number(self, enumerable_numbers): |
50
|
|
|
""" |
51
|
|
|
Sets number of heading nodes. |
52
|
|
|
|
53
|
|
|
:param dict[str,sdoc.sdoc2.helper.Enumerable.Enumerable] enumerable_numbers: |
54
|
|
|
""" |
55
|
|
|
if 'part' not in enumerable_numbers: |
56
|
|
|
enumerable_numbers['part'] = Enumerable() |
57
|
|
|
|
58
|
|
|
enumerable_numbers['part'].generate_numeration(self.get_hierarchy_level()) |
59
|
|
|
enumerable_numbers['part'].increment_last_level() |
60
|
|
|
enumerable_numbers['part'].remove_starting_zeros() |
61
|
|
|
|
62
|
|
|
super().number(enumerable_numbers) |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
66
|
|
|
NodeStore.register_inline_command('part', PartNode) |
67
|
|
|
|