StrictDoc Documentation
strictdoc/features/tree_map/view_object.py
Source file coverage
Path:
strictdoc/features/tree_map/view_object.py
Lines:
47
Non-empty lines:
38
Non-empty lines covered with requirements:
38 / 38 (100.0%)
Functions:
6
Functions covered by requirements:
6 / 6 (100.0%)
1
"""
2
@relation(SDOC-SRS-157, scope=file)
3
"""
4
 
5
from markupsafe import Markup
6
 
7
from strictdoc import __version__
8
from strictdoc.core.project_config import ProjectConfig
9
from strictdoc.core.traceability_index import TraceabilityIndex
10
from strictdoc.export.html.html_templates import JinjaEnvironment
11
from strictdoc.export.html.renderers.link_renderer import LinkRenderer
12
from strictdoc.features.tree_map.plotly_js import PLOTLY_JS_EXTENSION
13
 
14
 
15
class TreeMapViewObject:
16
    def __init__(
17
        self,
18
        *,
19
        traceability_index: TraceabilityIndex,
20
        project_config: ProjectConfig,
21
        body: str,
22
    ) -> None:
23
        self.traceability_index: TraceabilityIndex = traceability_index
24
        self.project_config: ProjectConfig = project_config
25
        self.body: Markup = Markup(body)
26
        self.link_renderer: LinkRenderer = LinkRenderer(
27
            root_path="", static_path=project_config.dir_for_sdoc_assets
28
        )
29
        self.is_running_on_server: bool = project_config.is_running_on_server
30
        self.strictdoc_version = __version__
31
 
32
        self.plotly_js_extension: Markup = PLOTLY_JS_EXTENSION
33
 
34
    def get_document_level(self) -> int:
35
        return 0
36
 
37
    def render_screen(self, jinja_environment: JinjaEnvironment) -> Markup:
38
        return jinja_environment.render_template_as_markup(
39
            "features/tree_map/index.jinja", view_object=self
40
        )
41
 
42
    def render_static_url(self, url: str) -> str:
43
        return self.link_renderer.render_static_url(url)
44
 
45
    def render_url(self, url: str) -> str:
46
        # FIXME: Switch to Markup(...).
47
        return self.link_renderer.render_url(url)