66from typing import Callable , Generator , TypeVar , overload
77
88from .. import ui
9+ from .._deprecated import warn_deprecated
910from .._typing_extensions import ParamSpec
1011from ..render .renderer import RendererBase , RendererBaseT
1112from ..render .transformer import OutputRenderer
1213from ..render .transformer ._transformer import OT
1314
1415__all__ = (
1516 "ui_kwargs" ,
17+ "hide" ,
1618 "suspend_display" ,
1719)
1820
@@ -98,29 +100,29 @@ def wrapper(renderer: OutputRenderer[OT]) -> OutputRenderer[OT]:
98100
99101
100102@overload
101- def suspend_display (fn : CallableT ) -> CallableT :
103+ def hide (fn : CallableT ) -> CallableT :
102104 ...
103105
104106
105107@overload
106- def suspend_display (fn : RendererBaseT ) -> RendererBaseT :
108+ def hide (fn : RendererBaseT ) -> RendererBaseT :
107109 ...
108110
109111
110112@overload
111- def suspend_display () -> AbstractContextManager [None ]:
113+ def hide () -> AbstractContextManager [None ]:
112114 ...
113115
114116
115- def suspend_display (
117+ def hide (
116118 fn : Callable [P , R ] | RendererBaseT | None = None
117119) -> Callable [P , R ] | RendererBaseT | AbstractContextManager [None ]:
118- """Suppresses the display of UI elements in various ways.
120+ """Prevent the display of UI elements in various ways.
119121
120- If used as a context manager (`with suspend_display ():`), it suppresses the display
121- of all UI elements within the context block. (This is useful when you want to
122- temporarily suppress the display of a large number of UI elements, or when you want
123- to suppress the display of UI elements that are not directly under your control.)
122+ If used as a context manager (`with hide ():`), it prevents the display of all UI
123+ elements within the context block. (This is useful when you want to temporarily
124+ prevent the display of a large number of UI elements, or when you want to prevent
125+ the display of UI elements that are not directly under your control.)
124126
125127 If used as a decorator (without parentheses) on a Shiny rendering function, it
126128 prevents that function from automatically outputting itself at the point of its
@@ -134,19 +136,19 @@ def suspend_display(
134136 Parameters
135137 ----------
136138 fn
137- The function to decorate. If `None`, returns a context manager that suppresses
138- the display of UI elements within the context block.
139+ The function to decorate. If `None`, returns a context manager that prevents the
140+ display of UI elements within the context block.
139141
140142 Returns
141143 -------
142144 :
143- If `fn` is `None`, returns a context manager that suppresses the display of UI
145+ If `fn` is `None`, returns a context manager that prevents the display of UI
144146 elements within the context block. Otherwise, returns a decorated version of
145147 `fn`.
146148 """
147149
148150 if fn is None :
149- return suspend_display_ctxmgr ()
151+ return hide_ctxmgr ()
150152
151153 # Special case for RendererBase; when we decorate those, we just mean "don't
152154 # display yourself"
@@ -155,11 +157,21 @@ def suspend_display(
155157 fn .default_ui = null_ui
156158 return fn
157159
158- return suspend_display_ctxmgr ()(fn )
160+ return hide_ctxmgr ()(fn )
161+
162+
163+ def suspend_display (
164+ fn : Callable [P , R ] | RendererBaseT | None = None
165+ ) -> Callable [P , R ] | RendererBaseT | AbstractContextManager [None ]:
166+ warn_deprecated (
167+ "`suspend_display` is deprecated. Please use `hide` instead. "
168+ "It has a new name, but the exact same functionality."
169+ )
170+ return hide (fn ) # type: ignore
159171
160172
161173@contextlib .contextmanager
162- def suspend_display_ctxmgr () -> Generator [None , None , None ]:
174+ def hide_ctxmgr () -> Generator [None , None , None ]:
163175 oldhook = sys .displayhook
164176 sys .displayhook = null_displayhook
165177 try :
0 commit comments