From 27ab81ef2e34bcf8f47ea1e50352b160c728008e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Tue, 19 Sep 2023 10:22:35 +0100 Subject: [PATCH] Module docs --- docs/api/logger.md | 4 ++++ src/textual/app.py | 4 ++++ src/textual/errors.py | 5 +++++ src/textual/filter.py | 13 +++++++++++++ src/textual/fuzzy.py | 7 +++++++ src/textual/message_pump.py | 7 ++++++- src/textual/pilot.py | 8 +++++++- src/textual/suggester.py | 6 ++++++ 8 files changed, 52 insertions(+), 2 deletions(-) diff --git a/docs/api/logger.md b/docs/api/logger.md index bd76afceca..096ca3011c 100644 --- a/docs/api/logger.md +++ b/docs/api/logger.md @@ -1 +1,5 @@ +# Logger + +A [logger class](/guide/devtools/#logging-handler) that logs to the Textual [console](/guide/devtools#console). + ::: textual.Logger diff --git a/src/textual/app.py b/src/textual/app.py index e89a74cc80..ee5ce3d0a6 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -1198,6 +1198,10 @@ async def run_test( ) -> AsyncGenerator[Pilot, None]: """An asynchronous context manager for testing apps. + !!! tip + + See the guide for [testing](/guide/testing) Textual apps. + Use this to run your app in "headless" mode (no output) and drive the app via a [Pilot][textual.pilot.Pilot] object. Example: diff --git a/src/textual/errors.py b/src/textual/errors.py index 021bcff0fa..034139e204 100644 --- a/src/textual/errors.py +++ b/src/textual/errors.py @@ -1,3 +1,8 @@ +""" +General exception classes. + +""" + from __future__ import annotations diff --git a/src/textual/filter.py b/src/textual/filter.py index 65378818eb..7494d9a52a 100644 --- a/src/textual/filter.py +++ b/src/textual/filter.py @@ -1,3 +1,16 @@ +"""Filter classes. + +!!! note + + Filters are used internally, and not recommended for use by Textual app developers. + +Filters are used internally to process terminal output after it has been rendered. +Currently this is used internally to convert the application to monochrome, when the NO_COLOR env var is set. + +In the future, this system will be used to implement accessibility features. + +""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/src/textual/fuzzy.py b/src/textual/fuzzy.py index 3fa4b0094f..6ee7940854 100644 --- a/src/textual/fuzzy.py +++ b/src/textual/fuzzy.py @@ -1,3 +1,10 @@ +""" +Fuzzy matcher. + +This class is used by the [command palette](guide/command) to match search terms. + +""" + from __future__ import annotations from re import IGNORECASE, compile, escape diff --git a/src/textual/message_pump.py b/src/textual/message_pump.py index 7ed468dca2..3d49080a6a 100644 --- a/src/textual/message_pump.py +++ b/src/textual/message_pump.py @@ -1,6 +1,11 @@ """ -A message pump is a base class for any object which processes messages, which includes Widget, Screen, and App. +A `MessagePump` is a base class for any object which processes messages, which includes Widget, Screen, and App. + +!!! tip + + Most of the method here are useful in general app development. + """ from __future__ import annotations diff --git a/src/textual/pilot.py b/src/textual/pilot.py index 685186d5eb..c3c64d2e9a 100644 --- a/src/textual/pilot.py +++ b/src/textual/pilot.py @@ -1,6 +1,9 @@ """ The pilot object is used by [App.run_test][textual.app.App.run_test] to programmatically operate an app. + +See the guide on how to [test Textual apps](/guide/testing). + """ from __future__ import annotations @@ -42,7 +45,10 @@ def _get_mouse_message_arguments( class WaitForScreenTimeout(Exception): - pass + """Exception raised if messages aren't being processed quickly enough. + + If this occurs, the most likely explanation is some kind of deadlock in the app code. + """ @rich.repr.auto(angular=True) diff --git a/src/textual/suggester.py b/src/textual/suggester.py index 362fe89f6d..505993b43a 100644 --- a/src/textual/suggester.py +++ b/src/textual/suggester.py @@ -1,3 +1,9 @@ +""" + +The `Suggester` class is used by the [Input](/widgets/input) widget. + +""" + from __future__ import annotations from abc import ABC, abstractmethod