Skip to content

Commit a2a1230

Browse files
authored
Update sphinx theme (#1937)
* Docs: update theme, resolve warnings * Remove sphinx-colorschemed-images (unused) * Ruff changes to docs/conf.py * ruff lint ignore UP031 in examples/* * ruff lint ignore UP031 in src/* * Extend typos ignore to test_buffer.py
1 parent e02b171 commit a2a1230

File tree

5 files changed

+126
-46
lines changed

5 files changed

+126
-46
lines changed

docs/conf.py

Lines changed: 115 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@
2525
# Add any Sphinx extension module names here, as strings. They can be
2626
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2727
# ones.
28-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.graphviz", "sphinx_copybutton"]
28+
extensions = [
29+
"sphinx.ext.autodoc",
30+
"sphinx.ext.graphviz",
31+
"sphinx_copybutton",
32+
]
2933

3034
# Add any paths that contain templates here, relative to this directory.
3135
# templates_path = ["_templates"]
3236

3337
# The suffix of source filenames.
34-
source_suffix = ".rst"
38+
source_suffix = {".rst": "restructuredtext"}
3539

3640
# The encoding of source files.
3741
# source_encoding = 'utf-8-sig'
@@ -47,10 +51,21 @@
4751
# |version| and |release|, also used in various other places throughout the
4852
# built documents.
4953
#
54+
# ---------------------------------------------------------------------
55+
# Versions.
5056
# The short X.Y version.
5157
version = "3.0.48"
5258
# The full version, including alpha/beta/rc tags.
5359
release = "3.0.48"
60+
# The URL pattern to match releases to ReadTheDocs URLs.
61+
docs_fmt_url = "https://python-prompt-toolkit.readthedocs.io/en/{release}/"
62+
# The list of releases to include in the dropdown.
63+
releases = [
64+
"latest",
65+
release,
66+
"2.0.9",
67+
"1.0.15",
68+
]
5469

5570
# The language for content autogenerated by Sphinx. Refer to documentation
5671
# for a list of supported languages.
@@ -82,8 +97,7 @@
8297
# show_authors = False
8398

8499
# The name of the Pygments (syntax highlighting) style to use.
85-
pygments_style = "pastie"
86-
pygments_dark_style = "dracula"
100+
# pygments_style = "pastie" # Provided as a theme option below.
87101

88102
# A list of ignored prefixes for module index sorting.
89103
# modindex_common_prefix = []
@@ -107,38 +121,103 @@
107121

108122
# on_rtd = os.environ.get("READTHEDOCS", None) == "True"
109123

110-
try:
111-
import sphinx_nefertiti
112-
113-
html_theme = "sphinx_nefertiti"
114-
html_theme_path = [sphinx_nefertiti.get_html_theme_path()]
115-
html_theme_options = {
116-
# "style" can take the following values: "blue", "indigo", "purple",
117-
# "pink", "red", "orange", "yellow", "green", "tail", and "default".
118-
"style": "default",
119-
# Fonts are customizable (and are not retrieved online).
120-
# https://sphinx-nefertiti.readthedocs.io/en/latest/users-guide/customization/fonts.html
121-
# "documentation_font": "Open Sans",
122-
# "monospace_font": "Ubuntu Mono",
123-
# "monospace_font_size": "1.1rem",
124-
"logo": "logo_400px.png",
125-
"logo_alt": "python-prompt-toolkit",
126-
"logo_width": "36",
127-
"logo_height": "36",
128-
"repository_url": "https://github.com/prompt-toolkit/python-prompt-toolkit",
129-
"repository_name": "python-prompt-toolkit",
130-
"footer_links": ",".join(
131-
[
132-
"Documentation|https://python-prompt-toolkit.readthedocs.io/",
133-
"Package|https://pypi.org/project/prompt-toolkit/",
134-
"Repository|https://github.com/prompt-toolkit/python-prompt-toolkit",
135-
"Issues|https://github.com/prompt-toolkit/python-prompt-toolkit/issues",
136-
]
137-
),
138-
}
139-
140-
except ImportError:
141-
html_theme = "pyramid"
124+
html_theme = "sphinx_nefertiti"
125+
# html_theme_path = [sphinx_nefertiti.get_html_theme_path()]
126+
html_theme_options = {
127+
"documentation_font": "Open Sans",
128+
"monospace_font": "Ubuntu Mono",
129+
"monospace_font_size": "1.1rem",
130+
# "style" can take the following values: "blue", "indigo", "purple",
131+
# "pink", "red", "orange", "yellow", "green", "tail", and "default".
132+
"style": "blue",
133+
"pygments_light_style": "pastie",
134+
"pygments_dark_style": "dracula",
135+
# Fonts are customizable (and are not retrieved online).
136+
# https://sphinx-nefertiti.readthedocs.io/en/latest/users-guide/customization/fonts.html
137+
"logo": "logo_400px.png",
138+
"logo_alt": "python-prompt-toolkit",
139+
"logo_width": "36",
140+
"logo_height": "36",
141+
"repository_url": "https://github.com/prompt-toolkit/python-prompt-toolkit",
142+
"repository_name": "python-prompt-toolkit",
143+
"current_version": "latest",
144+
"versions": [(item, docs_fmt_url.format(release=item)) for item in releases],
145+
"header_links": [
146+
{"text": "Getting started", "link": "pages/getting_started"},
147+
{
148+
"text": "Tutorials",
149+
"match": "/tutorials/*",
150+
"dropdown": (
151+
{"text": "Build an SQLite REPL", "link": "pages/tutorials/repl"},
152+
),
153+
},
154+
{
155+
"text": "Advanced",
156+
"link": "pages/advanced_topics/index",
157+
"match": "/advanced_topics/*",
158+
"dropdown": (
159+
{
160+
"text": "More about key bindings",
161+
"link": "pages/advanced_topics/key_bindings",
162+
},
163+
{
164+
"text": "More about styling",
165+
"link": "pages/advanced_topics/styling",
166+
},
167+
{
168+
"text": "Filters",
169+
"link": "pages/advanced_topics/filters",
170+
},
171+
{
172+
"text": "The rendering flow",
173+
"link": "pages/advanced_topics/rendering_flow",
174+
},
175+
{
176+
"text": "Running on top of the asyncio event loop",
177+
"link": "pages/advanced_topics/asyncio",
178+
},
179+
{
180+
"text": "Unit testing",
181+
"link": "pages/advanced_topics/unit_testing",
182+
},
183+
{
184+
"text": "Input hooks",
185+
"link": "pages/advanced_topics/input_hooks",
186+
},
187+
{
188+
"text": "Architecture",
189+
"link": "pages/advanced_topics/architecture",
190+
},
191+
{
192+
"text": "The rendering pipeline",
193+
"link": "pages/advanced_topics/rendering_pipeline",
194+
},
195+
),
196+
},
197+
{
198+
"text": "Reference",
199+
"link": "pages/reference",
200+
},
201+
],
202+
"footer_links": [
203+
{
204+
"text": "Documentation",
205+
"link": "https://python-prompt-toolkit.readthedocs.io/",
206+
},
207+
{
208+
"text": "Package",
209+
"link": "https://pypi.org/project/prompt-toolkit/",
210+
},
211+
{
212+
"text": "Repository",
213+
"link": "https://github.com/prompt-toolkit/python-prompt-toolkit",
214+
},
215+
{
216+
"text": "Issues",
217+
"link": "https://github.com/prompt-toolkit/python-prompt-toolkit/issues",
218+
},
219+
],
220+
}
142221

143222

144223
# Theme options are theme-specific and customize the look and feel of a theme

docs/pages/reference.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,11 @@ Filters
301301

302302
.. autoclass:: prompt_toolkit.filters.Filter
303303
:members:
304+
:no-index:
304305

305306
.. autoclass:: prompt_toolkit.filters.Condition
306307
:members:
308+
:no-index:
307309

308310
.. automodule:: prompt_toolkit.filters.utils
309311
:members:
@@ -334,7 +336,7 @@ Eventloop
334336

335337
.. automodule:: prompt_toolkit.eventloop
336338
:members: run_in_executor_with_context, call_soon_threadsafe,
337-
get_traceback_from_context, get_event_loop
339+
get_traceback_from_context
338340

339341
.. automodule:: prompt_toolkit.eventloop.inputhook
340342
:members:

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Sphinx<7
1+
Sphinx>=8,<9
22
wcwidth<1
33
pyperclip<2
4-
sphinx_copybutton>=0.5.0,<1.0.0
5-
sphinx-nefertiti>=0.2.1
4+
sphinx_copybutton>=0.5.2,<1.0.0
5+
sphinx-nefertiti>=0.6.0

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ lint.ignore = [
2020
"E741", # Ambiguous variable name.
2121
]
2222

23-
2423
[tool.ruff.lint.per-file-ignores]
25-
"examples/*" = ["T201"] # Print allowed in examples.
24+
"examples/*" = ["UP031", "T201"] # Print allowed in examples.
2625
"src/prompt_toolkit/application/application.py" = ["T100", "T201", "F821"] # pdb and print allowed.
2726
"src/prompt_toolkit/contrib/telnet/server.py" = ["T201"] # Print allowed.
2827
"src/prompt_toolkit/key_binding/bindings/named_commands.py" = ["T201"] # Print allowed.
@@ -31,8 +30,7 @@ lint.ignore = [
3130
"src/prompt_toolkit/filters/__init__.py" = ["F403", "F405"] # Possibly undefined due to star import.
3231
"src/prompt_toolkit/filters/cli.py" = ["F403", "F405"] # Possibly undefined due to star import.
3332
"src/prompt_toolkit/shortcuts/progress_bar/formatters.py" = ["UP031"] # %-style formatting.
34-
"src/*" = ["UP032"] # f-strings instead of format calls.
35-
33+
"src/*" = ["UP031", "UP032"] # f-strings instead of format calls.
3634

3735
[tool.ruff.lint.isort]
3836
known-first-party = ["prompt_toolkit"]
@@ -63,6 +61,7 @@ locale = 'en-us' # US English.
6361

6462
[tool.typos.files]
6563
extend-exclude = [
64+
"tests/test_buffer.py",
6665
"tests/test_cli.py",
6766
"tests/test_regular_languages.py",
6867
]

src/prompt_toolkit/application/current.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ def create_app_session(
143143
"""
144144
Create a separate AppSession.
145145
146-
This is useful if there can be multiple individual `AppSession`s going on.
147-
Like in the case of an Telnet/SSH server.
146+
This is useful if there can be multiple individual ``AppSession``'s going
147+
on. Like in the case of a Telnet/SSH server.
148148
"""
149149
# If no input/output is specified, fall back to the current input/output,
150150
# if there was one that was set/created for the current session.

0 commit comments

Comments
 (0)