@@ -127,11 +127,14 @@ def generate_report(self, output_dir: str = SECTIONS_DIR) -> None:
127127 report_manag_content .append ("\n sections_pages = {}" )
128128
129129 # Generate the home page and update the report manager content
130+ # ! top level files (compontents) are added to the home page
130131 self ._generate_home_section (
131- output_dir = output_dir , report_manag_content = report_manag_content
132+ output_dir = output_dir ,
133+ report_manag_content = report_manag_content ,
134+ home_section = self .report .sections [0 ],
132135 )
133136
134- for section in self .report .sections :
137+ for section in self .report .sections [ 1 :]: # skip home section components
135138 # Create a folder for each section
136139 subsection_page_vars = []
137140 section_name_var = section .title .replace (" " , "_" )
@@ -293,7 +296,10 @@ def _format_text(
293296 return f"""st.markdown('''<{ tag } style='text-align: { text_align } ; color: { color } ;'>{ text } </{ tag } >''', unsafe_allow_html=True)"""
294297
295298 def _generate_home_section (
296- self , output_dir : str , report_manag_content : list
299+ self ,
300+ output_dir : str ,
301+ report_manag_content : list ,
302+ home_section : r .Section ,
297303 ) -> None :
298304 """
299305 Generates the homepage for the report and updates the report manager content.
@@ -306,6 +312,13 @@ def _generate_home_section(
306312 A list to store the content that will be written to the report manager file.
307313 """
308314 self .report .logger .debug ("Processing home section." )
315+ all_components = []
316+ subsection_imports = []
317+ if home_section .components :
318+ # some assert on title?
319+ all_components , subsection_imports , _ = self ._combine_components (
320+ home_section .components
321+ )
309322
310323 try :
311324 # Create folder for the home page
@@ -320,6 +333,8 @@ def _generate_home_section(
320333 # Create the home page content
321334 home_content = []
322335 home_content .append (f"import streamlit as st" )
336+ if subsection_imports :
337+ home_content .extend (subsection_imports )
323338 if self .report .description :
324339 home_content .append (
325340 self ._format_text (text = self .report .description , type = "paragraph" )
@@ -329,6 +344,10 @@ def _generate_home_section(
329344 f"\n st.image('{ self .report .graphical_abstract } ', use_column_width=True)"
330345 )
331346
347+ # add components content to page (if any)
348+ if all_components :
349+ home_content .extend (all_components )
350+
332351 # Define the footer variable and add it to the home page content
333352 home_content .append ("footer = '''" + generate_footer () + "'''\n " )
334353 home_content .append ("st.markdown(footer, unsafe_allow_html=True)\n " )
@@ -361,7 +380,7 @@ def _generate_sections(self, output_dir: str) -> None:
361380 self .report .logger .info ("Starting to generate sections for the report." )
362381
363382 try :
364- for section in self .report .sections :
383+ for section in self .report .sections [ 1 :] :
365384 section_name_var = section .title .replace (" " , "_" )
366385 self .report .logger .debug (
367386 f"Processing section '{ section .id } ': '{ section .title } ' - { len (section .subsections )} subsection(s)"
0 commit comments