Add RTL support to python-docs-theme - #324
Conversation
Documentation build overview
69 files changed ·
|
|
I think it's better to do the font in a follow up, since I have some concerns about licensing and such things. |
Although I’m okay with leaving this for a follow-up, Vazirmatn is an open-source project, licensed under the SIL Open Font License. But if you still think this is better handled in a follow-up, I’ll do that. Thanks a lot! |
I'd prefer that, personally. |
|
Can you please update your branch to pull in the translation? |
|
Also, I tried to get Claude to look at this. Here's its analysis:
|
|
Thanks so much for the thorough review! I’ll work through these comments and send a patch soon. |
for more information, see https://pre-commit.ci
|
Hi @StanFromIreland, I addressed the review comments you left with Claude's help, built the docs locally to verify the changes, and all the issues you pointed out appear to be resolved. I also checked that the LTR version remains unaffected. |
Indeed, testing with the current patch, the only change is the addition of A selection of pagesdiff --git a/html/whatsnew/changelog.html b/base/html/whatsnew/changelog.html
index 903b246..c60dcd2 100644
--- a/html/whatsnew/changelog.html
+++ b/base/html/whatsnew/changelog.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
-<html lang="en" data-content_root="../">
+<html lang="en" dir="ltr" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -20,7 +20,7 @@
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
- <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=4365c8fe" />
+ <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=83ab0a67" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
<script src="../_static/documentation_options.js?v=d86cccaa"></script>
@@ -50462,7 +50462,7 @@ Kilburn.</p></li>
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br>
<br>
- Last updated on Aug 19, 2026 (20:32 UTC).
+ Last updated on Aug 19, 2026 (20:30 UTC).
<a href="/bugs.html">Found a bug</a>?diff --git a/html/library/sqlite3.html b/base/html/library/sqlite3.html
index 6decdde..fc9f358 100644
--- a/html/library/sqlite3.html
+++ b/base/html/library/sqlite3.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
-<html lang="en" data-content_root="../">
+<html lang="en" dir="ltr" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -20,7 +20,7 @@
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
- <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=4365c8fe" />
+ <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=83ab0a67" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
<script src="../_static/documentation_options.js?v=d86cccaa"></script>
@@ -2979,7 +2979,7 @@ statements. This is no longer the case.</p>
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br>
<br>
- Last updated on Aug 19, 2026 (20:32 UTC).
+ Last updated on Aug 19, 2026 (20:30 UTC).
<a href="/bugs.html">Found a bug</a>?diff --git a/html/library/datetime.html b/base/html/library/datetime.html
index b32b4a9..0381fa5 100644
--- a/html/library/datetime.html
+++ b/base/html/library/datetime.html
@@ -1,6 +1,6 @@
<!DOCTYPE html>
-<html lang="en" data-content_root="../">
+<html lang="en" dir="ltr" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -20,7 +20,7 @@
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
- <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=4365c8fe" />
+ <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=83ab0a67" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
<script src="../_static/documentation_options.js?v=d86cccaa"></script>
@@ -3649,7 +3649,7 @@ for a good explanation.</p>
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br>
<br>
- Last updated on Aug 19, 2026 (20:32 UTC).
+ Last updated on Aug 19, 2026 (20:30 UTC).
<a href="/bugs.html">Found a bug</a>? |
|
@cben, maybe you can help review this? From what I gather you're the expert in this area, I'd appreciate your thoughts here. |
StanFromIreland
left a comment
There was a problem hiding this comment.
I'm a little worried about regressing LTR, we should be very careful here.
Would something in layout.html like:
{% block body_tag %}<body{% if theme_is_rtl|tobool %} dir="rtl"{% endif %}>{% endblock %}not work instead of add_html_dir_to_context?
| context: dict[str, Any], | ||
| doctree: None, | ||
| ) -> None: | ||
| language = app.config.language or "en" |
There was a problem hiding this comment.
Why not context["language"]?
| MESSAGE_CATALOG_NAME = "python-docs-theme" | ||
|
|
||
|
|
||
| def _tobool(val: object) -> bool: |
There was a problem hiding this comment.
This seems quite overcomplicated for something used once.
|
|
||
| content_root = context.get("content_root", "") | ||
| lang_part = f' lang="{escape(language)}"' if language is not None else "" | ||
| context["html_tag"] = Markup( |
There was a problem hiding this comment.
I'm not a fan of this, what if Sphinx adds an attribute?
|
|
||
| div.body { | ||
| padding: 0 0 0 1.2em; | ||
| padding-inline-start: 1.2em; |
There was a problem hiding this comment.
This no longer zeros the other sides:
| padding: 0.3em 0.6em; | ||
| font-size: 90%; | ||
| color: #333; | ||
|
|
There was a problem hiding this comment.
These are unrelated changes.
|
|
||
| dl > dt span ~ em, | ||
| .sig { | ||
| font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; |
There was a problem hiding this comment.
Why are we dropping the font?
| div.footer { | ||
| line-height: 150%; | ||
| text-align: right; | ||
| text-align: end; /* was: text-align: right */ |
There was a problem hiding this comment.
| text-align: end; /* was: text-align: right */ | |
| text-align: end; |
These comments don't add any useful information.
|
|
||
| from pathlib import Path | ||
|
|
||
| from markupsafe import Markup, escape |
There was a problem hiding this comment.
This is now an undeclared direct dependency...






Added RTL support to python-docs-theme. Passing the
is_rtl=trueflag when building the documentation now generates RTL-friendly pages.I also added Vazirmatn as the font for RTL scripts (it really improves readability), but I’m not sure how acceptable this is, so I’m happy to change it if the maintainers disagree.
Please let me know if any changes or additions are needed. Thanks in advance!