| Total Complexity | 1 |
| Total Lines | 32 |
| Duplicated Lines | 59.38 % |
| Coverage | 100% |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 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.ItemNode import ItemNode |
|
| 6 | 1 | from sdoc.sdoc2.NodeStore import NodeStore |
|
| 7 | |||
| 8 | |||
| 9 | 1 | View Code Duplication | class ItemHtmlFormatter(HtmlFormatter): |
|
|
|||
| 10 | """ |
||
| 11 | HtmlFormatter for generating HTML code for items. |
||
| 12 | """ |
||
| 13 | |||
| 14 | # ------------------------------------------------------------------------------------------------------------------ |
||
| 15 | 1 | def generate(self, node: ItemNode, file: Any) -> None: |
|
| 16 | """ |
||
| 17 | Generates the HTML code for an item node. |
||
| 18 | |||
| 19 | :param ItemNode node: The item node. |
||
| 20 | :param any file: The output file. |
||
| 21 | """ |
||
| 22 | 1 | attributes = {'id': node.get_option_value('id')} |
|
| 23 | |||
| 24 | 1 | file.write('<li {0}>'.format(Html.generate_attribute('id', attributes['id']))) |
|
| 25 | 1 | node.prepare_content_tree() |
|
| 26 | 1 | HtmlFormatter.generate(self, node, file) |
|
| 27 | 1 | file.write('</li>') |
|
| 28 | |||
| 29 | |||
| 30 | # ---------------------------------------------------------------------------------------------------------------------- |
||
| 31 | NodeStore.register_formatter('item', 'html', ItemHtmlFormatter) |
||
| 32 |