SDoc /
py-sdoc
| 1 | 1 | from typing import Any |
|
| 2 | |||
| 3 | 1 | from sdoc.helper.Html import Html |
|
| 4 | 1 | from sdoc.sdoc2.formatter.html.HtmlFormatter import HtmlFormatter |
|
| 5 | 1 | from sdoc.sdoc2.node.IconNode import IconNode |
|
| 6 | 1 | from sdoc.sdoc2.NodeStore import NodeStore |
|
| 7 | |||
| 8 | |||
| 9 | 1 | View Code Duplication | class IconHtmlFormatter(HtmlFormatter): |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
| 10 | """ |
||
| 11 | HtmlFormatter for icons in HTML representation. |
||
| 12 | """ |
||
| 13 | |||
| 14 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 15 | 1 | def generate(self, node: IconNode, file: Any) -> None: |
|
| 16 | """ |
||
| 17 | Generates the HTML code for an icon node. |
||
| 18 | |||
| 19 | :param IconNode node: The icon node. |
||
| 20 | :param any file: The output file. |
||
| 21 | """ |
||
| 22 | attributes = IconNode.get_definition(node.argument) |
||
| 23 | |||
| 24 | if attributes: |
||
| 25 | img_element = Html.generate_void_element('img', attributes) |
||
| 26 | file.write(img_element) |
||
| 27 | else: |
||
| 28 | NodeStore.error("There is no definition for icon with name '{}'".format(node.argument), node) |
||
| 29 | |||
| 30 | |||
| 31 | # ---------------------------------------------------------------------------------------------------------------------- |
||
| 32 | NodeStore.register_formatter('icon', 'html', IconHtmlFormatter) |
||
| 33 |