From 92798a2f314891cea062010aa3e7faba17f586f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:37:59 +0100 Subject: [PATCH 1/2] Hide some members from the public docs. See relevant issue: #3076. Some methods need to be implemented to make the widget work but the user doesn't really care about them. For that matter, we can hide them from the public documentation. --- docs/api/widget.md | 4 ++++ mkdocs-common.yml | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/api/widget.md b/docs/api/widget.md index 3888a30d8f..072e9625e0 100644 --- a/docs/api/widget.md +++ b/docs/api/widget.md @@ -1 +1,5 @@ ::: textual.widget + options: + filters: + - "!^_" + - "^__init__$" diff --git a/mkdocs-common.yml b/mkdocs-common.yml index 0d59822f6a..f343b61694 100644 --- a/mkdocs-common.yml +++ b/mkdocs-common.yml @@ -78,6 +78,16 @@ plugins: - "!^_" - "^__init__$" - "!^can_replace$" + # Hide some methods that Widget subclasses implement but that we don't want + # to be shown in the docs. + # This is then overridden in widget.md so that it shows in the base class. + - "!^compose$" + - "!^render$" + - "!^render_line$" + - "!^render_lines$" + - "!^get_content_width$" + - "!^get_content_height$" + - "!^on_mount$" watch: - mkdocs-common.yml - mkdocs-nav.yml From bc596a398baefa2447d006cc7cf7e72533bcde21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gir=C3=A3o=20Serr=C3=A3o?= <5621605+rodrigogiraoserrao@users.noreply.github.com> Date: Wed, 9 Aug 2023 13:24:29 +0100 Subject: [PATCH 2/2] Use private handler to hide from docs. Related comments: https://github.com/Textualize/textual/pull/3080#issuecomment-1671129733 --- mkdocs-common.yml | 1 - src/textual/widgets/_placeholder.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdocs-common.yml b/mkdocs-common.yml index f343b61694..aa3584c523 100644 --- a/mkdocs-common.yml +++ b/mkdocs-common.yml @@ -87,7 +87,6 @@ plugins: - "!^render_lines$" - "!^get_content_width$" - "!^get_content_height$" - - "!^on_mount$" watch: - mkdocs-common.yml - mkdocs-nav.yml diff --git a/src/textual/widgets/_placeholder.py b/src/textual/widgets/_placeholder.py index a6ac37302f..21367631ea 100644 --- a/src/textual/widgets/_placeholder.py +++ b/src/textual/widgets/_placeholder.py @@ -120,7 +120,7 @@ def __init__( while next(self._variants_cycle) != self.variant: pass - def on_mount(self) -> None: + def _on_mount(self) -> None: """Set the color for this placeholder.""" colors = Placeholder._COLORS.setdefault( self.app, cycle(_PLACEHOLDER_BACKGROUND_COLORS)