@@ -145,41 +145,14 @@ def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
145145
146146 # Generate the home page and update the report manager content
147147 # ! top level files (compontents) are added to the home page
148- home_section = self .report .sections [0 ]
149148 self ._generate_home_section (
150149 output_dir = output_dir ,
151150 report_manag_content = report_manag_content ,
152- home_section = home_section ,
153151 )
154152 # ! move this into the _generate_home_section method
155153 subsection_page_vars = []
156154
157- for subsection in home_section .subsections :
158- # ! could add a non-integer to ensure it's a valid identifier
159- subsection_name_var = make_valid_identifier (subsection .title )
160- if not subsection_name_var .isidentifier ():
161- self .report .logger .warning (
162- f"Subsection name '{ subsection_name_var } ' is not a valid identifier."
163- )
164- raise ValueError (
165- f"Subsection name is not a valid Python identifier: { subsection_name_var } "
166- )
167- subsection_file_path = (
168- Path ("Home" ) / f"{ subsection_name_var } .py"
169- ).as_posix () # Make sure it's Posix Paths
170- subsection .file_path = subsection_file_path
171- # Create a Page object for each subsection and add it to the home page content
172- report_manag_content .append (
173- f"{ subsection_name_var } = st.Page('{ subsection_file_path } ', title='{ subsection .title } ')"
174- )
175- subsection_page_vars .append (subsection_name_var )
176-
177- # Add all subsection Page objects to the corresponding section
178- report_manag_content .append (
179- f"sections_pages['Home'] = [homepage,{ ', ' .join (subsection_page_vars )} ]\n "
180- )
181-
182- for section in self .report .sections [1 :]: # skip home section components
155+ for section in self .report .sections : # skip home section components
183156 # Create a folder for each section
184157 subsection_page_vars = []
185158 section_name_var = make_valid_identifier (
@@ -376,7 +349,6 @@ def _generate_home_section(
376349 self ,
377350 output_dir : str ,
378351 report_manag_content : list ,
379- home_section : r .Section ,
380352 ) -> None :
381353 """
382354 Generates the homepage for the report and updates the report manager content.
@@ -388,14 +360,7 @@ def _generate_home_section(
388360 report_manag_content : list
389361 A list to store the content that will be written to the report manager file.
390362 """
391- self .report .logger .debug ("Processing home section." )
392- all_components = []
393- subsection_imports = []
394- if home_section .components :
395- # some assert on title?
396- all_components , subsection_imports , _ = self ._combine_components (
397- home_section .components
398- )
363+ self .report .logger .debug ("Processing home section." ))
399364
400365 try :
401366 # Create folder for the home page
@@ -410,8 +375,6 @@ def _generate_home_section(
410375 # Create the home page content
411376 home_content = []
412377 home_content .append ("import streamlit as st" )
413- if subsection_imports :
414- home_content .extend (subsection_imports )
415378 if self .report .description :
416379 home_content .append (
417380 self ._format_text (text = self .report .description , type = "paragraph" )
@@ -422,8 +385,6 @@ def _generate_home_section(
422385 )
423386
424387 # add components content to page (if any)
425- if all_components :
426- home_content .extend (all_components )
427388
428389 # Define the footer variable and add it to the home page content
429390 home_content .append ("footer = '''" + generate_footer () + "'''\n " )
@@ -456,12 +417,11 @@ def _generate_sections(self, output_dir: str) -> None:
456417 """
457418 self .report .logger .info ("Starting to generate sections for the report." )
458419 try :
459- for section_no , section in enumerate ( self .report .sections ) :
420+ for section in self .report .sections :
460421 self .report .logger .debug (
461422 f"Processing section '{ section .id } ': '{ section .title } ' - { len (section .subsections )} subsection(s)"
462423 )
463- # ! skip first section components as it's predefined as homepage
464- if section_no and section .components :
424+ if section .components :
465425 # add an section overview page
466426 section_content , section_imports , _ = self ._combine_components (
467427 section .components
0 commit comments