11import os
2- import re
32import subprocess
43import sys
54from pathlib import Path
@@ -148,6 +147,18 @@ def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
148147 self .report .logger .debug (
149148 f"Section directory already existed: { section_dir_path } "
150149 )
150+ # add an overview page to section of components exist
151+ if section .components :
152+ subsection_file_path = (
153+ Path (section_name_var )
154+ / f"0_overview_{ section .title .lower ()} .py"
155+ ).as_posix () # Make sure it's Posix Paths
156+
157+ # Create a Page object for each subsection and add it to the home page content
158+ report_manag_content .append (
159+ f"{ section_name_var } _overview = st.Page('{ subsection_file_path } ', title='Overview { section .title } ')"
160+ )
161+ subsection_page_vars .append (f"{ section_name_var } _overview" )
151162
152163 for subsection in section .subsections :
153164 # ! could add a non-integer to ensure it's a valid identifier
@@ -386,6 +397,25 @@ def _generate_sections(self, output_dir: str) -> None:
386397 f"Processing section '{ section .id } ': '{ section .title } ' - { len (section .subsections )} subsection(s)"
387398 )
388399
400+ if section .components :
401+ # add an section overview page
402+ section_content , section_imports , _ = self ._combine_components (
403+ section .components
404+ )
405+ _filepath_overview = (
406+ Path (output_dir )
407+ / section_name_var
408+ / f"0_overview_{ section .title .lower ()} .py"
409+ # ! tighly coupled to generate_report fct:
410+ # ! check how to pass file names
411+ )
412+
413+ write_python_file (
414+ fpath = _filepath_overview ,
415+ imports = section_imports ,
416+ contents = section_content ,
417+ )
418+
389419 if not section .subsections :
390420 self .report .logger .warning (
391421 f"No subsections found in section: '{ section .title } '. "
@@ -394,6 +424,7 @@ def _generate_sections(self, output_dir: str) -> None:
394424 continue
395425
396426 # Iterate through subsections and integrate them into the section file
427+ # subsection should have the subsection_file_path as file_path?
397428 for subsection in section .subsections :
398429 self .report .logger .debug (
399430 f"Processing subsection '{ subsection .id } ': '{ subsection .title } -"
0 commit comments