1414from strictdoc .backend .sdoc .models .document import SDocDocument
1515from strictdoc .backend .sdoc .models .document_view import ViewElement
1616from strictdoc .backend .sdoc .models .grammar_element import GrammarElement
17- from strictdoc .backend .sdoc .models .model import SDocElementIF
17+ from strictdoc .backend .sdoc .models .model import (
18+ SDocDocumentIF ,
19+ SDocElementIF ,
20+ SDocNodeIF ,
21+ )
1822from strictdoc .backend .sdoc .models .node import SDocNode , SDocNodeField
1923from strictdoc .core .document_iterator import DocumentIterationContext
2024from strictdoc .core .document_tree import DocumentTree
@@ -48,6 +52,7 @@ def __init__(
4852 project_config : ProjectConfig ,
4953 link_renderer : LinkRenderer ,
5054 markup_renderer : MarkupRenderer ,
55+ jinja_environment : JinjaEnvironment ,
5156 git_client : GitClient ,
5257 standalone : bool ,
5358 ):
@@ -58,6 +63,7 @@ def __init__(
5863 self .project_config : ProjectConfig = project_config
5964 self .link_renderer : LinkRenderer = link_renderer
6065 self .markup_renderer : MarkupRenderer = markup_renderer
66+ self .jinja_environment : JinjaEnvironment = jinja_environment
6167 self .git_client : GitClient = git_client
6268 self .standalone : bool = standalone
6369 self .document_iterator = self .traceability_index .get_document_iterator (
@@ -82,47 +88,45 @@ def __init__(
8288 def has_included_document (self ) -> bool :
8389 return len (self .document .included_documents ) > 0
8490
85- def render_screen (self , jinja_environment : JinjaEnvironment ) -> Markup :
91+ def render_screen (self ) -> Markup :
8692 if self .document_type .is_document ():
8793 if self .document .config .layout == "Website" :
88- return jinja_environment .render_template_as_markup (
94+ return self . jinja_environment .render_template_as_markup (
8995 "website/document/index.jinja" , view_object = self
9096 )
91- return jinja_environment .render_template_as_markup (
97+ return self . jinja_environment .render_template_as_markup (
9298 "screens/document/document/index.jinja" , view_object = self
9399 )
94100 elif self .document_type .is_table ():
95- return jinja_environment .render_template_as_markup (
101+ return self . jinja_environment .render_template_as_markup (
96102 "screens/document/table/index.jinja" , view_object = self
97103 )
98104 elif self .document_type .is_trace ():
99- return jinja_environment .render_template_as_markup (
105+ return self . jinja_environment .render_template_as_markup (
100106 "screens/document/traceability/index.jinja" , view_object = self
101107 )
102108 elif self .document_type .is_deeptrace ():
103- return jinja_environment .render_template_as_markup (
109+ return self . jinja_environment .render_template_as_markup (
104110 "screens/document/traceability_deep/index.jinja" ,
105111 view_object = self ,
106112 )
107113 elif self .document_type .is_pdf ():
108- return jinja_environment .render_template_as_markup (
114+ return self . jinja_environment .render_template_as_markup (
109115 "screens/document/pdf/index.jinja" , view_object = self
110116 )
111117 else :
112118 raise NotImplementedError (self .document_type ) # pragma: no cover
113119
114- def render_updated_screen (
115- self , jinja_environment : JinjaEnvironment
116- ) -> Markup :
117- output = jinja_environment .render_template_as_markup (
120+ def render_updated_screen (self ) -> Markup :
121+ output = self .jinja_environment .render_template_as_markup (
118122 "actions/"
119123 "document/"
120124 "create_requirement/"
121125 "stream_created_requirement.jinja.html" ,
122126 view_object = self ,
123127 )
124128
125- output += jinja_environment .render_template_as_markup (
129+ output += self . jinja_environment .render_template_as_markup (
126130 "actions/document/_shared/stream_updated_toc.jinja.html" ,
127131 view_object = self ,
128132 )
@@ -132,7 +136,6 @@ def render_updated_screen(
132136 def render_updated_nodes_and_toc (
133137 self ,
134138 nodes : Sequence [Union [SDocDocument , SDocNode ]],
135- jinja_environment : JinjaEnvironment ,
136139 ) -> str :
137140 output : str = ""
138141
@@ -147,7 +150,7 @@ def render_updated_nodes_and_toc(
147150 template_folder = "node_content"
148151 else :
149152 raise NotImplementedError
150- content = jinja_environment .render_template_as_markup (
153+ content = self . jinja_environment .render_template_as_markup (
151154 f"components/{ template_folder } /index_extends_node.jinja" ,
152155 view_object = self ,
153156 node = node_ ,
@@ -158,7 +161,7 @@ def render_updated_nodes_and_toc(
158161 target = f"article-{ node_ .reserved_mid } " ,
159162 )
160163
161- toc_content = jinja_environment .render_template_as_markup (
164+ toc_content = self . jinja_environment .render_template_as_markup (
162165 "screens/document/_shared/toc.jinja" , view_object = self
163166 )
164167 output += render_turbo_stream (
@@ -170,9 +173,9 @@ def render_updated_nodes_and_toc(
170173 return output
171174
172175 def render_update_document_content_with_moved_node (
173- self , jinja_environment : JinjaEnvironment , moved_node : Any
176+ self , moved_node : Any
174177 ) -> Markup :
175- content = jinja_environment .render_template_as_markup (
178+ content = self . jinja_environment .render_template_as_markup (
176179 "screens/document/document/frame_document_content.jinja.html" ,
177180 view_object = self ,
178181 )
@@ -181,7 +184,7 @@ def render_update_document_content_with_moved_node(
181184 action = "replace" ,
182185 target = "frame_document_content" ,
183186 )
184- toc_content = jinja_environment .render_template_as_markup (
187+ toc_content = self . jinja_environment .render_template_as_markup (
185188 "actions/document/_shared/stream_updated_toc.jinja.html" ,
186189 view_object = self ,
187190 last_moved_node_id = moved_node .reserved_mid ,
@@ -294,6 +297,26 @@ def render_node_field(self, node_field: SDocNodeField) -> Markup:
294297 self .document_type , node_field
295298 )
296299
300+ def render_issues (
301+ self ,
302+ node : Union [SDocNodeIF , SDocDocumentIF ],
303+ field : Optional [str ] = None ,
304+ ) -> str :
305+ issues = self .traceability_index .validation_index .get_issues (
306+ node , field = field
307+ )
308+ if issues is None :
309+ return ""
310+ issues_html = ""
311+ for issue_ in issues :
312+ issue_html = self .jinja_environment .render_template_as_markup (
313+ "components/issue/index.jinja" ,
314+ issue = issue_ ,
315+ view_object = self ,
316+ )
317+ issues_html += issue_html
318+ return issues_html
319+
297320 def get_page_title (self ) -> str :
298321 return self .document_type .get_page_title ()
299322
0 commit comments