diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2018-05-22 23:14:26 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2018-05-22 23:14:35 +0200 |
commit | 1d3991df3305ee20534326efdd433e021650c642 (patch) | |
tree | 9913c9053a69b92ce04eb57a71d74ed06eb2f9fb | |
parent | 529edb45efadfc732f84791f6a835a0dc9f5467b (diff) |
A couple of small docstring improvements.
-rw-r--r-- | prompt_toolkit/application/current.py | 25 | ||||
-rw-r--r-- | prompt_toolkit/application/dummy.py | 5 | ||||
-rw-r--r-- | prompt_toolkit/key_binding/key_bindings.py | 19 |
3 files changed, 27 insertions, 22 deletions
diff --git a/prompt_toolkit/application/current.py b/prompt_toolkit/application/current.py index 86f3e935..4cda648f 100644 --- a/prompt_toolkit/application/current.py +++ b/prompt_toolkit/application/current.py @@ -15,25 +15,28 @@ _current_app = TaskLocal() def get_app(raise_exception=False, return_none=False): """ Get the current active (running) Application. - An `Application` is active during the `Application.run_async` call. + An :class:`.Application` is active during the + :meth:`.Application.run_async` call. We assume that there can only be one :class:`.Application` active at the same time. There is only one terminal window, with only one stdin and stdout. This makes the code significantly easier than passing around the - `Application` everywhere. + :class:`.Application` everywhere. - If no `Application` is running, then return by default a - `DummyApplication`. For practical reasons, we prefer to not raise an - exception. This way, we don't have to check all over the place whether an - actual `Application` was returned. + If no :class:`.Application` is running, then return by default a + :class:`.DummyApplication`. For practical reasons, we prefer to not raise + an exception. This way, we don't have to check all over the place whether + an actual `Application` was returned. (For applications like pymux where we can have more than one `Application`, we'll use a work-around to handle that.) - :param raise_exception: When `True`, raise `NoRunningApplicationError` - instead of returning a `DummyApplication` if no application is running. + :param raise_exception: When `True`, raise + :class:`.NoRunningApplicationError` instead of returning a + :class:`.DummyApplication` if no application is running. :param return_none: When `True`, return `None` - instead of returning a `DummyApplication` if no application is running. + instead of returning a :class:`.DummyApplication` if no application is + running. """ try: value = _current_app.get() @@ -52,7 +55,9 @@ def get_app(raise_exception=False, return_none=False): @contextmanager def set_app(app): """ - Context manager that sets the given Application active. + Context manager that sets the given :class:`.Application` active. + + (Usually, not needed to call outside of prompt_toolkit.) """ from .application import Application assert app is None or isinstance(app, Application) diff --git a/prompt_toolkit/application/dummy.py b/prompt_toolkit/application/dummy.py index 2d7edcda..ed20d7d3 100644 --- a/prompt_toolkit/application/dummy.py +++ b/prompt_toolkit/application/dummy.py @@ -10,9 +10,8 @@ __all__ = [ class DummyApplication(Application): """ - When no `Application` is running, - `prompt_toolkit.application.current.get_app` will run an instance of this - `Application`. + When no :class:`.Application` is running, + :func:`.get_app` will run an instance of this :class:`.DummyApplication` instead. """ def __init__(self): super(DummyApplication, self).__init__(output=DummyOutput(), input=DummyInput()) diff --git a/prompt_toolkit/key_binding/key_bindings.py b/prompt_toolkit/key_binding/key_bindings.py index e3af537a..2715af0f 100644 --- a/prompt_toolkit/key_binding/key_bindings.py +++ b/prompt_toolkit/key_binding/key_bindings.py @@ -57,7 +57,8 @@ class _Binding(object): """ (Immutable binding class.) - :param record_in_macro: When True, don't record this key binding when a macro is recorded. + :param record_in_macro: When True, don't record this key binding when a + macro is recorded. """ def __init__(self, keys, handler, filter=True, eager=False, is_global=False, save_before=None, record_in_macro=True): @@ -412,8 +413,8 @@ class ConditionalKeyBindings(_Proxy): When new key bindings are added to this object. They are also enable/disabled according to the given `filter`. - :param registries: List of `KeyBindings` objects. - :param filter: `Filter` object. + :param registries: List of :class:`.KeyBindings` objects. + :param filter: :class:`~prompt_toolkit.filters.Filter` object. """ def __init__(self, key_bindings, filter=True): assert isinstance(key_bindings, KeyBindingsBase) @@ -449,10 +450,10 @@ class _MergedKeyBindings(_Proxy): """ Merge multiple registries of key bindings into one. - This class acts as a proxy to multiple `KeyBindings` objects, but behaves as - if this is just one bigger `KeyBindings`. + This class acts as a proxy to multiple :class:`.KeyBindings` objects, but + behaves as if this is just one bigger :class:`.KeyBindings`. - :param registries: List of `KeyBindings` objects. + :param registries: List of :class:`.KeyBindings` objects. """ def __init__(self, registries): assert all(isinstance(r, KeyBindingsBase) for r in registries) @@ -478,7 +479,7 @@ class _MergedKeyBindings(_Proxy): def merge_key_bindings(bindings): """ - Merge multiple `Keybinding` objects together. + Merge multiple :class:`.Keybinding` objects together. Usage:: @@ -511,8 +512,8 @@ class DynamicKeyBindings(_Proxy): class GlobalOnlyKeyBindings(_Proxy): """ - Wrapper around a `KeyBindings` object that only exposes the global key - bindings. + Wrapper around a :class:`.KeyBindings` object that only exposes the global + key bindings. """ def __init__(self, key_bindings): assert isinstance(key_bindings, KeyBindingsBase) |