Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion streamlitfront/elements/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def render_views(self):

class View(FrontContainerBase):
def render(self):
st.markdown(f"""## **{self.name}**""")
st.markdown(f"""## **{self.name}**""", help=self.tooltip)
self._render_children()


Expand Down Expand Up @@ -150,6 +150,7 @@ def __init__(
use_expander: bool = True,
submit_button_label: str = "Submit",
authentification: bool = False,
tooltip: str = None,
):
super().__init__(
obj=obj,
Expand All @@ -159,6 +160,7 @@ def __init__(
display=display,
auto_submit=auto_submit,
on_submit=on_submit,
tooltip=tooltip,
)
self.use_expander = use_expander
self.submit_button_label = submit_button_label
Expand Down Expand Up @@ -272,6 +274,7 @@ def _widget_on_change(self):
label="name",
key="view_key",
value="view_value",
help="tooltip",
on_change="_widget_on_change",
**input_mapping,
)
Expand Down
1 change: 1 addition & 0 deletions streamlitfront/spec_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ELEMENT_KEY: App,
Callable: {
ELEMENT_KEY: View,
"tooltips": True,
"description": {
ELEMENT_KEY: TextSection,
},
Expand Down
26 changes: 26 additions & 0 deletions streamlitfront/tests/test_tooltips.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Docs of a function flow into streamlit's ``help=`` (streamlitfront#26)."""

from streamlit.testing.v1 import AppTest

_SCRIPT = '''
from streamlitfront import mk_app

def foo(a: int = 1, b: str = "x"):
"""Summary line.

:param a: the a
:param b: the b
"""
return a

mk_app([foo])()
'''


def test_docs_become_help():
at = AppTest.from_string(_SCRIPT)
at.run()
assert not at.exception
assert at.number_input[0].help == "the a"
assert at.text_input[0].help == "the b"
assert any(m.help == "Summary line." for m in at.markdown)
Loading