From 8437480d4857c079d4061c5bee607d35a06eb9c4 Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 13:05:41 +0100 Subject: [PATCH 1/6] Docs: update theme, resolve warnings --- docs/conf.py | 162 +++++++++++++++++----- docs/pages/reference.rst | 4 +- docs/requirements.txt | 7 +- src/prompt_toolkit/application/current.py | 4 +- 4 files changed, 135 insertions(+), 42 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a5d1f1608..c1d02d4de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,13 +25,18 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.autodoc", "sphinx.ext.graphviz", "sphinx_copybutton"] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.graphviz", + "sphinx_copybutton", + "sphinx_colorschemed_images", +] # Add any paths that contain templates here, relative to this directory. # templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = ".rst" +source_suffix = {'.rst': 'restructuredtext'} # The encoding of source files. # source_encoding = 'utf-8-sig' @@ -47,10 +52,21 @@ # |version| and |release|, also used in various other places throughout the # built documents. # +# --------------------------------------------------------------------- +# Versions. # The short X.Y version. version = "3.0.48" # The full version, including alpha/beta/rc tags. release = "3.0.48" +# The URL pattern to match releases to ReadTheDocs URLs. +docs_fmt_url = "https://python-prompt-toolkit.readthedocs.io/en/{release}/" +# The list of releases to include in the dropdown. +releases = [ + "latest", + release, + "2.0.9", + "1.0.15", +] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -82,8 +98,7 @@ # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = "pastie" -pygments_dark_style = "dracula" +# pygments_style = "pastie" # Provided as a theme option below. # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -107,38 +122,113 @@ # on_rtd = os.environ.get("READTHEDOCS", None) == "True" -try: - import sphinx_nefertiti - - html_theme = "sphinx_nefertiti" - html_theme_path = [sphinx_nefertiti.get_html_theme_path()] - html_theme_options = { - # "style" can take the following values: "blue", "indigo", "purple", - # "pink", "red", "orange", "yellow", "green", "tail", and "default". - "style": "default", - # Fonts are customizable (and are not retrieved online). - # https://sphinx-nefertiti.readthedocs.io/en/latest/users-guide/customization/fonts.html - # "documentation_font": "Open Sans", - # "monospace_font": "Ubuntu Mono", - # "monospace_font_size": "1.1rem", - "logo": "logo_400px.png", - "logo_alt": "python-prompt-toolkit", - "logo_width": "36", - "logo_height": "36", - "repository_url": "https://github.com/prompt-toolkit/python-prompt-toolkit", - "repository_name": "python-prompt-toolkit", - "footer_links": ",".join( - [ - "Documentation|https://python-prompt-toolkit.readthedocs.io/", - "Package|https://pypi.org/project/prompt-toolkit/", - "Repository|https://github.com/prompt-toolkit/python-prompt-toolkit", - "Issues|https://github.com/prompt-toolkit/python-prompt-toolkit/issues", - ] - ), - } - -except ImportError: - html_theme = "pyramid" +html_theme = "sphinx_nefertiti" +# html_theme_path = [sphinx_nefertiti.get_html_theme_path()] +html_theme_options = { + "documentation_font": "Open Sans", + "monospace_font": "Ubuntu Mono", + "monospace_font_size": "1.1rem", + + # "style" can take the following values: "blue", "indigo", "purple", + # "pink", "red", "orange", "yellow", "green", "tail", and "default". + "style": "blue", + "pygments_light_style": "pastie", + "pygments_dark_style": "dracula", + + # Fonts are customizable (and are not retrieved online). + # https://sphinx-nefertiti.readthedocs.io/en/latest/users-guide/customization/fonts.html + "logo": "logo_400px.png", + "logo_alt": "python-prompt-toolkit", + "logo_width": "36", + "logo_height": "36", + "repository_url": "https://github.com/prompt-toolkit/python-prompt-toolkit", + "repository_name": "python-prompt-toolkit", + "current_version": "latest", + "versions": [ + (item, docs_fmt_url.format(release=item)) for item in releases + ], + "header_links": [ + { + "text": "Getting started", + "link": "pages/getting_started" + }, + { + "text": "Tutorials", + "match": "/tutorials/*", + "dropdown": ( + { + "text": "Build an SQLite REPL", + "link": "pages/tutorials/repl" + }, + ) + }, + { + "text": "Advanced", + "link": "pages/advanced_topics/index", + "match": "/advanced_topics/*", + "dropdown": ( + { + "text": "More about key bindings", + "link": "pages/advanced_topics/key_bindings", + }, + { + "text": "More about styling", + "link": "pages/advanced_topics/styling", + }, + { + "text": "Filters", + "link": "pages/advanced_topics/filters", + }, + { + "text": "The rendering flow", + "link": "pages/advanced_topics/rendering_flow", + }, + { + "text": "Running on top of the asyncio event loop", + "link": "pages/advanced_topics/asyncio", + }, + { + "text": "Unit testing", + "link": "pages/advanced_topics/unit_testing", + }, + { + "text": "Input hooks", + "link": "pages/advanced_topics/input_hooks", + }, + { + "text": "Architecture", + "link": "pages/advanced_topics/architecture", + }, + { + "text": "The rendering pipeline", + "link": "pages/advanced_topics/rendering_pipeline" + } + ) + }, + { + "text": "Reference", + "link": "pages/reference", + }, + ], + "footer_links": [ + { + "text": "Documentation", + "link": "https://python-prompt-toolkit.readthedocs.io/", + }, + { + "text": "Package", + "link": "https://pypi.org/project/prompt-toolkit/", + }, + { + "text": "Repository", + "link": "https://github.com/prompt-toolkit/python-prompt-toolkit", + }, + { + "text": "Issues", + "link": "https://github.com/prompt-toolkit/python-prompt-toolkit/issues", + } + ] +} # Theme options are theme-specific and customize the look and feel of a theme diff --git a/docs/pages/reference.rst b/docs/pages/reference.rst index d8a705ea4..a8c777535 100644 --- a/docs/pages/reference.rst +++ b/docs/pages/reference.rst @@ -301,9 +301,11 @@ Filters .. autoclass:: prompt_toolkit.filters.Filter :members: + :no-index: .. autoclass:: prompt_toolkit.filters.Condition :members: + :no-index: .. automodule:: prompt_toolkit.filters.utils :members: @@ -334,7 +336,7 @@ Eventloop .. automodule:: prompt_toolkit.eventloop :members: run_in_executor_with_context, call_soon_threadsafe, - get_traceback_from_context, get_event_loop + get_traceback_from_context .. automodule:: prompt_toolkit.eventloop.inputhook :members: diff --git a/docs/requirements.txt b/docs/requirements.txt index beb1c314b..be1fc3b5c 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,6 @@ -Sphinx<7 +Sphinx>=8,<9 wcwidth<1 pyperclip<2 -sphinx_copybutton>=0.5.0,<1.0.0 -sphinx-nefertiti>=0.2.1 +sphinx-colorschemed-images>=0.2.2 +sphinx_copybutton>=0.5.2,<1.0.0 +sphinx-nefertiti>=0.6.0 \ No newline at end of file diff --git a/src/prompt_toolkit/application/current.py b/src/prompt_toolkit/application/current.py index 7e2cf480b..3f7eb4bd4 100644 --- a/src/prompt_toolkit/application/current.py +++ b/src/prompt_toolkit/application/current.py @@ -143,8 +143,8 @@ def create_app_session( """ Create a separate AppSession. - This is useful if there can be multiple individual `AppSession`s going on. - Like in the case of an Telnet/SSH server. + This is useful if there can be multiple individual ``AppSession``'s going + on. Like in the case of a Telnet/SSH server. """ # If no input/output is specified, fall back to the current input/output, # if there was one that was set/created for the current session. From 5b1ead16edbb700792c8811f3a4ec34f46ba3407 Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 13:17:44 +0100 Subject: [PATCH 2/6] Remove sphinx-colorschemed-images (unused) --- docs/conf.py | 1 - docs/requirements.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index c1d02d4de..eb0aa71de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -29,7 +29,6 @@ "sphinx.ext.autodoc", "sphinx.ext.graphviz", "sphinx_copybutton", - "sphinx_colorschemed_images", ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/requirements.txt b/docs/requirements.txt index be1fc3b5c..844bca89d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,6 +1,5 @@ Sphinx>=8,<9 wcwidth<1 pyperclip<2 -sphinx-colorschemed-images>=0.2.2 sphinx_copybutton>=0.5.2,<1.0.0 sphinx-nefertiti>=0.6.0 \ No newline at end of file From edab90c4731092265185a00d258826102d32846d Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 13:25:35 +0100 Subject: [PATCH 3/6] Ruff changes to docs/conf.py --- docs/conf.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index eb0aa71de..13c50e804 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,7 +35,7 @@ # templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = {'.rst': 'restructuredtext'} +source_suffix = {".rst": "restructuredtext"} # The encoding of source files. # source_encoding = 'utf-8-sig' @@ -127,13 +127,11 @@ "documentation_font": "Open Sans", "monospace_font": "Ubuntu Mono", "monospace_font_size": "1.1rem", - # "style" can take the following values: "blue", "indigo", "purple", # "pink", "red", "orange", "yellow", "green", "tail", and "default". "style": "blue", "pygments_light_style": "pastie", "pygments_dark_style": "dracula", - # Fonts are customizable (and are not retrieved online). # https://sphinx-nefertiti.readthedocs.io/en/latest/users-guide/customization/fonts.html "logo": "logo_400px.png", @@ -143,23 +141,15 @@ "repository_url": "https://github.com/prompt-toolkit/python-prompt-toolkit", "repository_name": "python-prompt-toolkit", "current_version": "latest", - "versions": [ - (item, docs_fmt_url.format(release=item)) for item in releases - ], + "versions": [(item, docs_fmt_url.format(release=item)) for item in releases], "header_links": [ - { - "text": "Getting started", - "link": "pages/getting_started" - }, + {"text": "Getting started", "link": "pages/getting_started"}, { "text": "Tutorials", "match": "/tutorials/*", "dropdown": ( - { - "text": "Build an SQLite REPL", - "link": "pages/tutorials/repl" - }, - ) + {"text": "Build an SQLite REPL", "link": "pages/tutorials/repl"}, + ), }, { "text": "Advanced", @@ -200,9 +190,9 @@ }, { "text": "The rendering pipeline", - "link": "pages/advanced_topics/rendering_pipeline" - } - ) + "link": "pages/advanced_topics/rendering_pipeline", + }, + ), }, { "text": "Reference", @@ -225,8 +215,8 @@ { "text": "Issues", "link": "https://github.com/prompt-toolkit/python-prompt-toolkit/issues", - } - ] + }, + ], } From 679a733a3f0200d6923046917342e85eb2da8367 Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 14:37:03 +0100 Subject: [PATCH 4/6] ruff lint ignore UP031 in examples/* --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index caba4fd11..7fb1b4309 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ lint.ignore = [ [tool.ruff.lint.per-file-ignores] -"examples/*" = ["T201"] # Print allowed in examples. +"examples/*" = ["UP031", "T201"] # Print allowed in examples. "src/prompt_toolkit/application/application.py" = ["T100", "T201", "F821"] # pdb and print allowed. "src/prompt_toolkit/contrib/telnet/server.py" = ["T201"] # Print allowed. "src/prompt_toolkit/key_binding/bindings/named_commands.py" = ["T201"] # Print allowed. From ac67b765a0750a2425935e4eceb438ade7fd18be Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 14:42:36 +0100 Subject: [PATCH 5/6] ruff lint ignore UP031 in src/* --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7fb1b4309..bf1535281 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ lint.ignore = [ "E741", # Ambiguous variable name. ] - [tool.ruff.lint.per-file-ignores] "examples/*" = ["UP031", "T201"] # Print allowed in examples. "src/prompt_toolkit/application/application.py" = ["T100", "T201", "F821"] # pdb and print allowed. @@ -31,8 +30,7 @@ lint.ignore = [ "src/prompt_toolkit/filters/__init__.py" = ["F403", "F405"] # Possibly undefined due to star import. "src/prompt_toolkit/filters/cli.py" = ["F403", "F405"] # Possibly undefined due to star import. "src/prompt_toolkit/shortcuts/progress_bar/formatters.py" = ["UP031"] # %-style formatting. -"src/*" = ["UP032"] # f-strings instead of format calls. - +"src/*" = ["UP031", "UP032"] # f-strings instead of format calls. [tool.ruff.lint.isort] known-first-party = ["prompt_toolkit"] From 52f3b679d106a51a4f154b6340800b36ba56ed26 Mon Sep 17 00:00:00 2001 From: Daniela Rus Morales Date: Fri, 29 Nov 2024 14:47:06 +0100 Subject: [PATCH 6/6] Extend typos ignore to test_buffer.py --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index bf1535281..57fc2d9f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,7 @@ locale = 'en-us' # US English. [tool.typos.files] extend-exclude = [ + "tests/test_buffer.py", "tests/test_cli.py", "tests/test_regular_languages.py", ]