|
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.node.Node import Node |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class DocumentNode(Node): |
|
14
|
|
|
""" |
|
15
|
|
|
SDoc2 node for documents. |
|
16
|
|
|
""" |
|
17
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
18
|
|
|
def __init__(self, options): |
|
19
|
|
|
""" |
|
20
|
|
|
Object constructor. |
|
21
|
|
|
|
|
22
|
|
|
:param dict[str,str] options: The options of this document. |
|
23
|
|
|
""" |
|
24
|
|
|
super().__init__('document', options) |
|
25
|
|
|
|
|
26
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
27
|
|
|
def get_command(self): |
|
28
|
|
|
""" |
|
29
|
|
|
Returns the command of this node, i.e. document. |
|
30
|
|
|
|
|
31
|
|
|
:rtype: str |
|
32
|
|
|
""" |
|
33
|
|
|
return 'document' |
|
34
|
|
|
|
|
35
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
36
|
|
|
def get_hierarchy_level(self, parent_hierarchy_level=-1): |
|
37
|
|
|
""" |
|
38
|
|
|
Returns 0. |
|
39
|
|
|
|
|
40
|
|
|
:rtype: int |
|
41
|
|
|
""" |
|
42
|
|
|
return 1 |
|
43
|
|
|
|
|
44
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
45
|
|
|
def get_hierarchy_name(self): |
|
46
|
|
|
""" |
|
47
|
|
|
Returns 'sectioning'. |
|
48
|
|
|
|
|
49
|
|
|
:rtype: str |
|
50
|
|
|
""" |
|
51
|
|
|
return 'sectioning' |
|
52
|
|
|
|
|
53
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
54
|
|
|
def is_block_command(self): |
|
55
|
|
|
""" |
|
56
|
|
|
Returns True. |
|
57
|
|
|
|
|
58
|
|
|
:rtype: bool |
|
59
|
|
|
""" |
|
60
|
|
|
return True |
|
61
|
|
|
|
|
62
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
63
|
|
|
def is_document_root(self): |
|
64
|
|
|
""" |
|
65
|
|
|
Returns True. |
|
66
|
|
|
:rtype: bool |
|
67
|
|
|
""" |
|
68
|
|
|
return True |
|
69
|
|
|
|
|
70
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
71
|
|
|
def is_inline_command(self): |
|
72
|
|
|
""" |
|
73
|
|
|
Returns False. |
|
74
|
|
|
|
|
75
|
|
|
:rtype: bool |
|
76
|
|
|
""" |
|
77
|
|
|
return False |
|
78
|
|
|
|
|
79
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
80
|
|
|
def is_phrasing(self): |
|
81
|
|
|
""" |
|
82
|
|
|
Returns False. |
|
83
|
|
|
|
|
84
|
|
|
:rtype: bool |
|
85
|
|
|
""" |
|
86
|
|
|
return False |
|
87
|
|
|
|
|
88
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
89
|
|
|
node_store.register_block_command('document', DocumentNode) |
|
90
|
|
|
|