Skip to content

Commit 84c8bf1

Browse files
committed
Get docs building
1 parent f83eca4 commit 84c8bf1

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

shiny/_docstring.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ def app_choose_core_or_express(
295295

296296
def 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

shiny/ui/_chat.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@
22
from shinychat.express import Chat as ChatExpress
33
from 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)

shiny/ui/_markdown_stream.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
from shinychat import MarkdownStream, output_markdown_stream
22
from 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)

0 commit comments

Comments
 (0)