Cleaner way to register an extra
Replace this
__func__ = get_streamlit_faker
__title__ = "Streamlit Faker"
__desc__ = "Fake Streamlit commands at the speed of light! Great for prototyping apps."
__icon__ = "🥷"
__examples__ = [example]
__author__ = "Arnaud Miribel"
__github_repo__ = "arnaudmiribel/streamlit-faker"
__pypi_name__ = "streamlit-faker"
__package_name__ = "streamlit_faker"
__experimental_playground__ = False
With
from common import set_extra_gallery_config
extra_gallery_config: dict = set_extra_gallery_config(
func=get_streamlit_faker,
title="Streamlit Faker",
desc="Fake Streamlit commands at the speed of light! Great for prototyping apps.",
...
)
And consume that extra_gallery_config variable in gallery/streamlit_app.py.
Main perks:
- canonical definition of all potential config keys in
set_extra_gallery_config - auto-complete unlocked for all extra configs config
- makes it clear that this part in the init.py is for the gallery and has no impact whatsoever in the inner workings of the extra.
WDYT @blackary?
@arnaudmiribel To be honest, I like the dunder attributes better because it doesn't actually run anything when you import an extra.
What if you slightly modified this, and make a standardized required method called _get_extra_config() or something like that, which then calls (and returns the output of) set_extra_gallery_config inside of it? Then the gallery app would go through, make sure that _get_extra_config() is defined, and call it. I'm not 100% sure I'm sold on that, but I just would like us to stick to "imports don't have side-effects" as much as possible. WDYT?
Won't do more than the decorator for now