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.Node import Node |
11
|
|
|
|
12
|
|
|
|
13
|
1 |
|
class IconNode(Node): |
14
|
|
|
""" |
15
|
|
|
The class for icons in sdoc2. |
16
|
|
|
""" |
17
|
|
|
|
18
|
1 |
|
_definitions = {} |
19
|
|
|
""" |
20
|
|
|
The static attribute with definitions of icons |
21
|
|
|
|
22
|
|
|
:type: dict[str, list[mixed]] |
23
|
|
|
""" |
24
|
|
|
|
25
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
26
|
1 |
|
def __init__(self, io, options, argument): |
27
|
|
|
""" |
28
|
|
|
Object constructor. |
29
|
|
|
|
30
|
|
|
:param None|cleo.styles.output_style.OutputStyle io: The IO object. |
31
|
|
|
:param dict[str,str] options: The options of this figure. |
32
|
|
|
:param str argument: Not used. |
33
|
|
|
""" |
34
|
|
|
super().__init__(io, 'icon', options, argument) |
35
|
|
|
|
36
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
37
|
1 |
|
def get_command(self): |
38
|
|
|
""" |
39
|
|
|
Returns the command of this node, i.e. icon. |
40
|
|
|
|
41
|
|
|
:rtype: str |
42
|
|
|
""" |
43
|
|
|
return 'icon' |
44
|
|
|
|
45
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
46
|
1 |
|
def is_block_command(self): |
47
|
|
|
""" |
48
|
|
|
Returns False. |
49
|
|
|
|
50
|
|
|
:rtype: bool |
51
|
|
|
""" |
52
|
|
|
return False |
53
|
|
|
|
54
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
55
|
1 |
|
def is_inline_command(self): |
56
|
|
|
""" |
57
|
|
|
Returns True. |
58
|
|
|
|
59
|
|
|
:rtype: bool |
60
|
|
|
""" |
61
|
|
|
return True |
62
|
|
|
|
63
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
64
|
1 |
|
@staticmethod |
65
|
|
|
def add_definition(name, attributes): |
66
|
|
|
""" |
67
|
|
|
Adds definition of an icon into static attribute. |
68
|
|
|
|
69
|
|
|
:param str name: The name of a reference to icon definition. |
70
|
|
|
:param dict[str, list[mixed] attributes: The attributes. |
71
|
|
|
""" |
72
|
|
|
IconNode._definitions[name] = attributes |
73
|
|
|
|
74
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
75
|
1 |
|
@staticmethod |
76
|
|
|
def get_definition(name): |
77
|
|
|
""" |
78
|
|
|
Returns the attributes of a definition, if name of definition is exists. |
79
|
|
|
|
80
|
|
|
:param str name: The name of a definition |
81
|
|
|
|
82
|
|
|
:rtype: list[mixed] |
83
|
|
|
""" |
84
|
|
|
if name in IconNode._definitions: |
85
|
|
|
return IconNode._definitions[name] |
86
|
|
|
|
87
|
|
|
else: |
88
|
|
|
return None |
89
|
|
|
|
90
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
91
|
|
|
NodeStore.register_inline_command('icon', IconNode) |
92
|
|
|
|