Skip to content

Commit aa31b81

Browse files
committed
✨ add components from main and section folders
1 parent 8129c74 commit aa31b81

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/vuegen/quarto_reportview.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def generate_report(self, output_dir: Path = BASE_DIR) -> None:
111111

112112
# Create qmd content and imports for the report
113113
qmd_content = []
114-
report_imports = []
114+
report_imports = (
115+
[]
116+
) # only one global import list for a single report (different to streamlit)
115117

116118
# Add description of the report
117119
if self.report.description:
@@ -122,9 +124,23 @@ def generate_report(self, output_dir: Path = BASE_DIR) -> None:
122124
qmd_content.append(
123125
self._generate_image_content(self.report.graphical_abstract)
124126
)
127+
# ? Do we need to handle overview separately?
128+
main_section = self.report.sections[0]
129+
130+
if main_section.components:
131+
self.report.logger.debug(
132+
"Adding components of main section folder to the report as overall overview."
133+
)
134+
qmd_content.append("# General Overview")
135+
section_content, section_imports = self._combine_components(
136+
main_section.components
137+
)
138+
qmd_content.extend(section_content)
139+
report_imports.extend(section_imports)
140+
125141
# Add the sections and subsections to the report
126142
self.report.logger.info("Starting to generate sections for the report.")
127-
for section in self.report.sections:
143+
for section in self.report.sections[1:]:
128144
self.report.logger.debug(
129145
f"Processing section: '{section.title}' - {len(section.subsections)} subsection(s)"
130146
)
@@ -133,6 +149,18 @@ def generate_report(self, output_dir: Path = BASE_DIR) -> None:
133149
if section.description:
134150
qmd_content.append(f"""{section.description}\n""")
135151

152+
# Add components of section to the report
153+
if section.components:
154+
self.report.logger.debug(
155+
"Adding components of section folder to the report."
156+
)
157+
qmd_content.append(f"## Overview {section.title}".strip())
158+
section_content, section_imports = self._combine_components(
159+
section.components
160+
)
161+
qmd_content.extend(section_content)
162+
report_imports.extend(section_imports)
163+
136164
if section.subsections:
137165
# Iterate through subsections and integrate them into the section file
138166
for subsection in section.subsections:
@@ -147,7 +175,9 @@ def generate_report(self, output_dir: Path = BASE_DIR) -> None:
147175
)
148176
)
149177
qmd_content.extend(subsection_content)
150-
report_imports.extend(subsection_imports)
178+
report_imports.extend(
179+
subsection_imports
180+
) # even easier as it's global
151181
else:
152182
self.report.logger.warning(
153183
f"No subsections found in section: '{section.title}'. To show content in the report, add subsections to the section."

0 commit comments

Comments
 (0)