File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -295,7 +295,11 @@ def app_choose_core_or_express(
295295
296296def get_decorated_source_directory (func : FuncType ) -> str :
297297 if hasattr (func , "__module__" ):
298- path = os .path .abspath (str (sys .modules [func .__module__ ].__file__ ))
298+ m = func .__module__
299+ # If function/object is defined in shiny, we use the module's file path.
300+ # Otherwise, we use the file path of the main shiny module.
301+ m2 = m if m .startswith ("shiny." ) else "shiny"
302+ path = os .path .abspath (str (sys .modules [m2 ].__file__ ))
299303 else :
300304 path = os .path .abspath (func .__code__ .co_filename )
301305
Original file line number Diff line number Diff line change 22from shinychat .express import Chat as ChatExpress
33from shinychat .types import ChatMessageDict
44
5+ from .._docstring import add_example
6+
57__all__ = (
68 "Chat" ,
79 "ChatExpress" ,
810 "chat_ui" ,
911 "ChatMessageDict" ,
1012)
13+
14+ Chat = add_example (
15+ app_file = "app-core.py" ,
16+ ex_dir = "../shiny/api-examples/Chat" ,
17+ )(Chat )
18+
19+ ChatExpress = add_example (
20+ app_file = "app-express.py" ,
21+ ex_dir = "../shiny/api-examples/Chat" ,
22+ )(ChatExpress )
23+
24+ chat_ui = add_example (
25+ app_file = "app-core.py" ,
26+ ex_dir = "../shiny/api-examples/Chat" ,
27+ )(chat_ui )
Original file line number Diff line number Diff line change 11from shinychat import MarkdownStream , output_markdown_stream
22from shinychat .express import MarkdownStream as ExpressMarkdownStream
33
4+ from .._docstring import add_example
5+
46__all__ = (
57 "output_markdown_stream" ,
68 "MarkdownStream" ,
79 "ExpressMarkdownStream" ,
810)
11+
12+ MarkdownStream = add_example (
13+ app_file = "app-core.py" ,
14+ ex_dir = "../shiny/api-examples/MarkdownStream" ,
15+ )(MarkdownStream )
16+
17+ ExpressMarkdownStream = add_example (
18+ app_file = "app-express.py" ,
19+ ex_dir = "../shiny/api-examples/MarkdownStream" ,
20+ )(ExpressMarkdownStream )
21+
22+ output_markdown_stream = add_example (
23+ app_file = "app-core.py" ,
24+ ex_dir = "../shiny/api-examples/MarkdownStream" ,
25+ )(output_markdown_stream )
You can’t perform that action at this time.
0 commit comments