Skip to content

Commit 647f5b0

Browse files
committed
Merge branch 'main' into fix150_multiline_description
2 parents 2c02135 + 01dd9c5 commit 647f5b0

File tree

11 files changed

+60
-3
lines changed

11 files changed

+60
-3
lines changed
270 KB
Loading

src/vuegen/config_manager.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,28 @@ def _read_description_file(self, folder_path: Path) -> str:
215215
return f"{ret}\n"
216216
return ""
217217

218+
def _read_home_image_file(self, folder_path: Path) -> str:
219+
"""
220+
Looks for an image file named 'home_image' with any supported image extension
221+
in the given folder.
222+
223+
Parameters
224+
----------
225+
folder_path : Path
226+
Path to the folder where the 'home_image' file might be located.
227+
228+
Returns
229+
-------
230+
str
231+
Path to the 'home_image' image file as a string if found, otherwise an
232+
empty string.
233+
"""
234+
for image_format in r.ImageFormat:
235+
candidate = folder_path / f"home_image{image_format.value_with_dot}"
236+
if candidate.exists() and candidate.is_file():
237+
return str(candidate)
238+
return ""
239+
218240
def _create_subsect_config_fromdir(
219241
self, subsection_dir_path: Path, level: int = 2
220242
) -> Dict[str, Union[str, List[Dict]]]:
@@ -334,7 +356,7 @@ def create_yamlconfig_fromdir(
334356
# This will be used for the home section of a report
335357
"title": self._create_title_fromdir(base_dir_path.name),
336358
"description": self._read_description_file(base_dir_path),
337-
"graphical_abstract": "",
359+
"graphical_abstract": self._read_home_image_file(base_dir_path),
338360
"logo": "",
339361
},
340362
"sections": [],
@@ -358,8 +380,11 @@ def create_yamlconfig_fromdir(
358380
# could be single plots?
359381
else:
360382
file_in_main_section_dir = section_dir
361-
if file_in_main_section_dir.name.lower() == "description.md":
362-
continue # Skip description files in the main section
383+
if (
384+
file_in_main_section_dir.name.lower() == "description.md"
385+
or "home_image" in file_in_main_section_dir.name.lower()
386+
):
387+
continue # Skip description file and home_image in the main section
363388
component_config = self._create_component_config_fromfile(
364389
file_in_main_section_dir
365390
)

src/vuegen/report.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ def value_with_dot(self):
100100
return f".{self.name.lower()}"
101101

102102

103+
class ImageFormat(StrEnum):
104+
"""Enum representing supported image file formats."""
105+
106+
PNG = auto()
107+
JPG = auto()
108+
JPEG = auto()
109+
SVG = auto()
110+
GIF = auto()
111+
WEBP = auto()
112+
113+
@property
114+
def value_with_dot(self):
115+
"""Return the file extension with the dot."""
116+
return f".{self.name.lower()}"
117+
118+
103119
@dataclass
104120
class Component:
105121
"""

tests/report_examples/Basic_example_vuegen_demo_notebook/docx/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ to be integrated into VueGen.
3232

3333
Check our tests folder for examples of report files used to generate actual reports.
3434

35+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
36+
3537
# Plots
3638
## Interactive Plots
3739
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/html/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ to be integrated into VueGen.
5858

5959
Check our tests folder for examples of report files used to generate actual reports.
6060

61+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
62+
6163
# Plots
6264
## Interactive Plots
6365
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/jupyter/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ to be integrated into VueGen.
5858

5959
Check our tests folder for examples of report files used to generate actual reports.
6060

61+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
62+
6163
# Plots
6264
## Interactive Plots
6365
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/odt/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ to be integrated into VueGen.
3232

3333
Check our tests folder for examples of report files used to generate actual reports.
3434

35+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
36+
3537
# Plots
3638
## Interactive Plots
3739
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/pdf/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ to be integrated into VueGen.
4444

4545
Check our tests folder for examples of report files used to generate actual reports.
4646

47+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
48+
4749
# Plots
4850
## Interactive Plots
4951
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/pptx/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ to be integrated into VueGen.
3333

3434
Check our tests folder for examples of report files used to generate actual reports.
3535

36+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
37+
3638
# Plots
3739
## Interactive Plots
3840
Optional description for section.

tests/report_examples/Basic_example_vuegen_demo_notebook/revealjs/quarto_report/quarto_report.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ to be integrated into VueGen.
5959

6060
Check our tests folder for examples of report files used to generate actual reports.
6161

62+
![](../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/home_image.png){fig-alt= width=90%}
63+
6264
# Plots
6365
## Interactive Plots
6466
Optional description for section.

0 commit comments

Comments
 (0)