5959from strictdoc .helpers .git_client import GitClient
6060from strictdoc .helpers .mid import MID
6161from strictdoc .helpers .parallelizer import Parallelizer
62- from strictdoc .helpers .paths import SDocRelativePath
62+ from strictdoc .helpers .paths import SDocRelativePath , path_to_posix_path
6363from strictdoc .helpers .timing import measure_performance , timing_decorator
6464
6565
@@ -171,6 +171,9 @@ def export_complete_tree(
171171 if self .project_config .is_feature_activated (
172172 ProjectFeature .REQUIREMENT_TO_SOURCE_TRACEABILITY
173173 ):
174+ self .export_source_files_screens (
175+ traceability_index = traceability_index ,
176+ )
174177 self .export_source_coverage_screen (
175178 traceability_index = traceability_index ,
176179 )
@@ -579,7 +582,8 @@ def export_requirements_coverage_screen(
579582 ) as file :
580583 file .write (requirements_coverage_content )
581584
582- def export_source_coverage_screen (
585+ @timing_decorator ("Export source file pages" )
586+ def export_source_files_screens (
583587 self ,
584588 * ,
585589 traceability_index : TraceabilityIndex ,
@@ -601,6 +605,15 @@ def export_source_coverage_screen(
601605 html_templates = self .html_templates ,
602606 )
603607
608+ def export_source_coverage_screen (
609+ self ,
610+ * ,
611+ traceability_index : TraceabilityIndex ,
612+ ) -> None :
613+ assert isinstance (
614+ traceability_index .document_tree .source_tree , SourceTree
615+ ), traceability_index .document_tree .source_tree
616+
604617 source_coverage_content = SourceFileCoverageHTMLGenerator .export (
605618 project_config = self .project_config ,
606619 traceability_index = traceability_index ,
@@ -612,6 +625,47 @@ def export_source_coverage_screen(
612625 with open (output_html_source_coverage , "w" , encoding = "utf8" ) as file :
613626 file .write (source_coverage_content )
614627
628+ def export_single_source_file_screen (
629+ self ,
630+ * ,
631+ traceability_index : TraceabilityIndex ,
632+ path_to_source_file : str ,
633+ ) -> None :
634+ assert isinstance (
635+ traceability_index .document_tree .source_tree , SourceTree
636+ ), traceability_index .document_tree .source_tree
637+
638+ # FIXME: path_to_source_file must not enter this function with forward slashes.
639+ # Test and fix this on Windows.
640+ # https://github.com/strictdoc-project/strictdoc/issues/2068
641+ relative_path_to_source_file = path_to_posix_path (path_to_source_file )
642+ relative_path_to_source_file = (
643+ relative_path_to_source_file .removeprefix ("_source_files/" )
644+ )
645+ relative_path_to_source_file = (
646+ relative_path_to_source_file .removesuffix (".html" )
647+ )
648+
649+ for (
650+ source_file
651+ ) in traceability_index .document_tree .source_tree .source_files :
652+ if not source_file .is_referenced :
653+ continue
654+
655+ if (
656+ relative_path_to_source_file
657+ == source_file .in_doctree_source_file_rel_path_posix
658+ ):
659+ SourceFileViewHTMLGenerator .export_to_file (
660+ project_config = self .project_config ,
661+ source_file = source_file ,
662+ traceability_index = traceability_index ,
663+ html_templates = self .html_templates ,
664+ )
665+ return
666+
667+ raise FileNotFoundError
668+
615669 def export_project_statistics (
616670 self ,
617671 traceability_index : TraceabilityIndex ,
0 commit comments