Skip to content

Commit 06eddac

Browse files
committed
Add caption formating for streamlit report
1 parent f0dfcd8 commit 06eddac

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

report_metadata_micw2graph.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ report:
1111
and potential ecological functions.
1212
graphical_abstract: "example_data/MicW2Graph/Methods_MicW2Graph.png"
1313
logo: "example_data/mona_logo.png"
14-
report_type: "document"
15-
report_format: "html"
14+
report_type: "streamlit"
15+
report_format: ""
1616
sections:
1717
- title: "Exploratory Data Analysis"
1818
subsections:

vuegen/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
report_config = load_yaml_config(config_path)
88

99
# Define logger suffix based on report engine, type and name
10-
report_engine = "quarto"
10+
report_engine = "streamlit"
1111
report_type = report_config['report'].get('report_type')
1212
report_format = report_config['report'].get('report_format')
1313
report_name = report_config['report'].get('name')

vuegen/streamlit_reportview.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ def _format_text(self, text: str, type: str, level: int = 1, color: str = '#0000
138138
tag = f"h{level}"
139139
elif type == 'paragraph':
140140
tag = 'p'
141+
elif type == 'caption':
142+
tag = 'figcaption'
141143

142144
return f"""st.markdown('''<{tag} style='text-align: {text_align}; color: {color};'>{text}</{tag}>''', unsafe_allow_html=True)"""
143145

@@ -336,7 +338,7 @@ def _generate_plot_content(self, plot, static_dir: str = STATIC_FILES_DIR) -> Li
336338
raise
337339
# Add caption if available
338340
if plot.caption:
339-
plot_content.append(self._format_text(text=plot.caption, type='paragraph', text_align="left"))
341+
plot_content.append(self._format_text(text=plot.caption, type='caption', text_align="left"))
340342

341343
self.report.logger.info(f"Successfully generated content for plot '{plot.id}': '{plot.title}'")
342344
return plot_content
@@ -414,7 +416,7 @@ def _generate_dataframe_content(self, dataframe) -> List[str]:
414416

415417
# Add caption if available
416418
if dataframe.caption:
417-
dataframe_content.append(self._format_text(text=dataframe.caption, type='paragraph', text_align="left"))
419+
dataframe_content.append(self._format_text(text=dataframe.caption, type='caption', text_align="left"))
418420

419421
self.report.logger.info(f"Successfully generated content for DataFrame: '{dataframe.title}'")
420422
return dataframe_content
@@ -447,7 +449,7 @@ def _generate_markdown_content(self, markdown) -> List[str]:
447449

448450
# Add caption if available
449451
if markdown.caption:
450-
markdown_content.append(self._format_text(text=markdown.caption, type='paragraph', text_align="left"))
452+
markdown_content.append(self._format_text(text=markdown.caption, type='caption', text_align="left"))
451453

452454
self.report.logger.info(f"Successfully generated content for Markdown: '{markdown.title}'")
453455
return markdown_content
@@ -479,7 +481,7 @@ def _generate_apicall_content(self, apicall) -> List[str]:
479481

480482
# Add caption if available
481483
if apicall.caption:
482-
apicall_content.append(self._format_text(text=apicall.caption, type='paragraph', text_align="left"))
484+
apicall_content.append(self._format_text(text=apicall.caption, type='caption', text_align="left"))
483485

484486
self.report.logger.info(f"Successfully generated content for APICall: '{apicall.title}'")
485487
return apicall_content
@@ -511,7 +513,7 @@ def _generate_chatbot_content(self, chatbot) -> List[str]:
511513

512514
# Add caption if available
513515
if chatbot.caption:
514-
chatbot_content.append(self._format_text(text=chatbot.caption, type='paragraph', text_align="left"))
516+
chatbot_content.append(self._format_text(text=chatbot.caption, type='caption', text_align="left"))
515517

516518
self.report.logger.info(f"Successfully generated content for APICall: '{chatbot.title}'")
517519
return chatbot_content

0 commit comments

Comments
 (0)