Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ dependencies = [

# Robot Framework dependencies
"robotframework >= 4.0.0",

# Tree map graphs.
"plotly",
"pandas"
]
# @sdoc[/SDOC-SRS-89]

Expand Down
1 change: 1 addition & 0 deletions strictdoc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ features = [
"HTML2PDF",
"DIFF",
"NESTOR",
"TREEMAP_SCREEN",
]

include_doc_paths = [
Expand Down
9 changes: 9 additions & 0 deletions strictdoc/backend/sdoc/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ def __init__(
# autogenerated code to disk.
self.autogen: bool = autogen

def get_total_size(self) -> int:
if self.section_contents is None or len(self.section_contents) == 0:
return 0
total_size = 0
for node_ in self.section_contents:
if isinstance(node_, SDocNode):
total_size += node_.get_total_size()
return total_size

def iterate_nodes(
self, element_type: Optional[str] = None
) -> Generator[SDocNodeIF, None, None]:
Expand Down
9 changes: 9 additions & 0 deletions strictdoc/backend/sdoc/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ def __init__(
# autogenerated code to disk.
self.autogen: bool = autogen

def get_total_size(self) -> int:
if self.section_contents is None or len(self.section_contents) == 0:
return 1
total_size = 0
for node_ in self.section_contents:
if isinstance(node_, SDocNode):
total_size += node_.get_total_size()
return total_size

@staticmethod
def get_type_string() -> str:
return "requirement"
Expand Down
23 changes: 12 additions & 11 deletions strictdoc/backend/sdoc/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,25 @@ def process_document_from_file(
self.parse_context.fragments_from_files.append(document_from_file)

def process_requirement(self, requirement: SDocNode) -> None:
self.parse_context.document_has_requirements = True

requirement.ng_document_reference = (
self.parse_context.document_reference
)
requirement.ng_including_document_reference = (
self.parse_context.context_document_reference
)

cursor: Union[SDocDocumentIF, SDocSectionIF, SDocNodeIF] = (
requirement.parent
)
while (
isinstance(cursor, (SDocSectionIF, SDocNodeIF))
and not cursor.ng_has_requirements
):
cursor.ng_has_requirements = True
cursor = cursor.parent
if requirement.node_type not in ("SECTION", "TEXT"):
self.parse_context.document_has_requirements = True

cursor: Union[SDocDocumentIF, SDocSectionIF, SDocNodeIF] = (
requirement.parent
)
while (
isinstance(cursor, (SDocSectionIF, SDocNodeIF))
and not cursor.ng_has_requirements
):
cursor.ng_has_requirements = True
cursor = cursor.parent

assert self.parse_context.document_config is not None
if (
Expand Down
4 changes: 4 additions & 0 deletions strictdoc/core/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ProjectFeature(str, Enum):
REQIF = "REQIF"
DIFF = "DIFF"
PROJECT_STATISTICS_SCREEN = "PROJECT_STATISTICS_SCREEN"
TREEMAP_SCREEN = "TREEMAP_SCREEN"
STANDALONE_DOCUMENT_SCREEN = "STANDALONE_DOCUMENT_SCREEN"
TRACEABILITY_MATRIX_SCREEN = "TRACEABILITY_MATRIX_SCREEN"
REQUIREMENT_TO_SOURCE_TRACEABILITY = "REQUIREMENT_TO_SOURCE_TRACEABILITY"
Expand Down Expand Up @@ -366,6 +367,9 @@ def is_activated_requirements_coverage(self) -> bool:
ProjectFeature.TRACEABILITY_MATRIX_SCREEN in self.project_features
)

def is_activated_tree_map(self) -> bool:
return ProjectFeature.TREEMAP_SCREEN in self.project_features

def is_activated_standalone_document(self) -> bool:
return (
ProjectFeature.STANDALONE_DOCUMENT_SCREEN in self.project_features
Expand Down
14 changes: 14 additions & 0 deletions strictdoc/export/html/html_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from strictdoc.export.html.renderers.link_renderer import LinkRenderer
from strictdoc.export.html.renderers.markup_renderer import MarkupRenderer
from strictdoc.export.html.tools.html_embedded import HTMLEmbedder
from strictdoc.features.tree_map.generator import TreeMapGenerator
from strictdoc.helpers.cast import assert_cast
from strictdoc.helpers.exception import StrictDocException
from strictdoc.helpers.file_modification_time import get_file_modification_time
Expand Down Expand Up @@ -149,6 +150,9 @@ def export_complete_tree(
# Export JavaScript map of the document tree (project map)
self.export_project_map(traceability_index=traceability_index)

if self.project_config.is_activated_tree_map():
self.export_tree_map_screen(traceability_index)

# Export project statistics.
if self.project_config.is_feature_activated(
ProjectFeature.PROJECT_STATISTICS_SCREEN
Expand Down Expand Up @@ -794,3 +798,13 @@ def default(obj: Any) -> Any:
)
with open(output_html_source_coverage, "wb") as file:
file.write(document_content)

def export_tree_map_screen(
self,
traceability_index: TraceabilityIndex,
) -> None:
TreeMapGenerator.export(
project_config=self.project_config,
traceability_index=traceability_index,
html_templates=self.html_templates,
)
11 changes: 11 additions & 0 deletions strictdoc/export/html/templates/_shared/nav.jinja.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,15 @@
</a>
{%- endif -%}

{%- if view_object.project_config.is_activated_tree_map() -%}
<a
data-link="tree_map"
class="nav_button"
href="{{ view_object.render_url('tree_map.html') }}"
title="Tree map"
data-testid="project-tree-link-tree-map"
>
M
</a>
{%- endif -%}
</div>
46 changes: 46 additions & 0 deletions strictdoc/export/html/templates/screens/tree_map/index.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends "base.jinja.html" %}
{% set template_type = "Tree map" %}

{% block head_css %}
{{ super() }}
<style>
h2.section {
text-align: center;
font-family: "Open Sans", verdana, arial, sans-serif';
}
</style>
{% endblock head_css %}

{% block head_scripts %}
{{ super() }}
<script defer>
{{view_object.plotly_js_extension}}
</script>
{% endblock head_scripts %}

{% block title %}
{{ view_object.project_config.project_title }} - {{ template_type }}
{% endblock title %}

{% block viewtype %}tree-map{% endblock viewtype %}

{% block layout_nav %}
{% include "_shared/nav.jinja.html" %}
{% endblock layout_nav %}

{% block toc_content %}
{% endblock toc_content %}

{% block header_content %}
{%- with header__pagetype=template_type -%}
{% include "components/header/index.jinja" %}
{%- endwith -%}
{% endblock header_content %}

{% block main_content %}
<div
class="main"
>
{{ view_object.body }}
</div>
{% endblock main_content %}
Loading
Loading