|
1
|
1 |
|
from typing import Any |
|
2
|
|
|
|
|
3
|
1 |
|
from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter |
|
4
|
1 |
|
from sdoc.sdoc2.node.Node import Node |
|
5
|
1 |
|
from sdoc.sdoc2.NodeStore import NodeStore |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
1 |
View Code Duplication |
class UnknownHtmlFormatter(HtmlFormatter): |
|
|
|
|
|
|
9
|
|
|
""" |
|
10
|
|
|
HtmlFormatter for unknown SDoc2 node types. |
|
11
|
|
|
""" |
|
12
|
|
|
|
|
13
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
14
|
1 |
|
def generate(self, node: Node, file: Any) -> None: |
|
15
|
|
|
""" |
|
16
|
|
|
Generates the HTML code for an unknown node. |
|
17
|
|
|
|
|
18
|
|
|
:param Node node: The unknown node. |
|
19
|
|
|
:param any file: The output file. |
|
20
|
|
|
""" |
|
21
|
1 |
|
self.write_into_file(node) |
|
22
|
|
|
|
|
23
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
24
|
1 |
|
def generate_chapter(self, node: Node, file: Any) -> None: |
|
25
|
|
|
""" |
|
26
|
|
|
Generates the HTML code for an unknown node. |
|
27
|
|
|
|
|
28
|
|
|
:param Node node: The unknown node. |
|
29
|
|
|
:param any file: The output file. |
|
30
|
|
|
""" |
|
31
|
|
|
if file: |
|
32
|
|
|
self.write_into_file(node) |
|
33
|
|
|
|
|
34
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
35
|
1 |
|
def write_into_file(self, node: Node): |
|
36
|
|
|
""" |
|
37
|
|
|
Writes into opened file. |
|
38
|
|
|
|
|
39
|
|
|
:param Node node: The unknown node. |
|
40
|
|
|
""" |
|
41
|
1 |
|
self.error('Unknown SDoc2 command {0}'.format(node.name), node) |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
45
|
|
|
NodeStore.register_formatter('unknown', 'html', UnknownHtmlFormatter) |
|
46
|
|
|
|