|
1
|
|
|
from typing import Dict |
|
2
|
|
|
|
|
3
|
|
|
from cleo.styles import OutputStyle |
|
4
|
|
|
|
|
5
|
|
|
from sdoc.sdoc2.node.IconNode import IconNode |
|
6
|
|
|
from sdoc.sdoc2.node.Node import Node |
|
7
|
|
|
from sdoc.sdoc2.NodeStore import NodeStore |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
View Code Duplication |
class IconDefNode(Node): |
|
|
|
|
|
|
11
|
|
|
""" |
|
12
|
|
|
The class for definition of icons in sdoc2. |
|
13
|
|
|
""" |
|
14
|
|
|
|
|
15
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
16
|
|
|
def __init__(self, io: OutputStyle, options: Dict[str, str], argument: str): |
|
17
|
|
|
""" |
|
18
|
|
|
Object constructor. |
|
19
|
|
|
|
|
20
|
|
|
:param OutputStyle io: The IO object. |
|
21
|
|
|
:param dict[str,str] options: The options of this figure. |
|
22
|
|
|
:param str argument: Not used. |
|
23
|
|
|
""" |
|
24
|
|
|
super().__init__(io, 'icon_def', options, argument) |
|
25
|
|
|
|
|
26
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
27
|
|
|
def get_command(self) -> str: |
|
28
|
|
|
""" |
|
29
|
|
|
Returns the command of this node, i.e. icondef. |
|
30
|
|
|
""" |
|
31
|
|
|
return 'icondef' |
|
32
|
|
|
|
|
33
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
34
|
|
|
def is_block_command(self) -> bool: |
|
35
|
|
|
""" |
|
36
|
|
|
Returns False. |
|
37
|
|
|
""" |
|
38
|
|
|
return False |
|
39
|
|
|
|
|
40
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
41
|
|
|
def is_inline_command(self) -> bool: |
|
42
|
|
|
""" |
|
43
|
|
|
Returns True. |
|
44
|
|
|
""" |
|
45
|
|
|
return True |
|
46
|
|
|
|
|
47
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
48
|
|
|
def prepare_content_tree(self) -> None: |
|
49
|
|
|
""" |
|
50
|
|
|
Prepares this node for further processing. |
|
51
|
|
|
""" |
|
52
|
|
|
reference_name = self.argument |
|
53
|
|
|
attributes = self._options |
|
54
|
|
|
|
|
55
|
|
|
IconNode.add_definition(reference_name, attributes) |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
59
|
|
|
NodeStore.register_inline_command('icondef', IconDefNode) |
|
60
|
|
|
|