Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Contributors
* Alastair Houghton -- Apple Help builder
* Alex Gaynor -- linkcheck retry on errors
* Alexander Todorov -- inheritance_diagram tests and improvements
* Alireza Shabani -- RTL support
* Andi Albrecht -- agogo theme
* Antonio Valentino -- qthelp builder, docstring inheritance
* Antti Kaihola -- doctest extension (skipif option)
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ Features added
* #13326: Remove hardcoding from handling :class:`~sphinx.addnodes.productionlist`
nodes in all writers, to improve flexibility.
Patch by Adam Turner.
* #10385: Add RTL (right-to-left) support for all Sphinx themes via ``is_rtl``

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* #10385: Add RTL (right-to-left) support for all Sphinx themes via ``is_rtl``
* #10385: Add RTL (right-to-left) support for all Sphinx themes via the ``is_rtl``

theme option. Includes automatic layout mirroring, and bidirectional text
support.
Patch by Revisto.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Patch by Revisto.
Patch by Alireza Shabani.

Usually we use names (see above entries) rather than github @s but its up to you.


Bugs fixed
----------
Expand Down
10 changes: 10 additions & 0 deletions doc/usage/theming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ These themes are:

.. versionadded:: 3.2

- **is_rtl** (true or false): Enable right-to-left (RTL) text direction.
Use this for languages that are read right-to-left (like Farsi, Arabic,
Hebrew, etc). When enabled, the theme will:

- Change text direction to RTL
- Mirror layout components
- Keep code blocks in LTR direction

Defaults to ``False``.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A version added block would be a nice addition

**alabaster**
`Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz
(especially as used in his Requests project), which was itself originally
Expand Down
2 changes: 2 additions & 0 deletions sphinx/themes/agogo/static/agogo.css.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Sphinx stylesheet -- agogo theme.
*/

@import url("rtl.css");

* {
margin: 0px;
padding: 0px;
Expand Down
152 changes: 152 additions & 0 deletions sphinx/themes/agogo/static/rtl.css.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{% if theme_is_rtl|tobool %}

/* Core RTL overrides for Agogo theme */
body {
direction: rtl !important;
text-align: right !important;
}

/* Header adjustments */
div.header .headertitle {
text-align: right !important;
letter-spacing: 0 !important;
}

div.header div.rel {
direction: rtl !important;
}

p.logo {
float: left !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really shouldn’t be needed. Just change the agogo.css.jinja’s definition to use flow-relative values:

p.logo {
    float: inline-start;
}

}

/* Content layout */
div.document {
float: right !important;
}

div.body {
{%- if theme_rightsidebar|tobool %}
padding-left: 2em !important;
padding-right: 0 !important;
{%- else %}
padding-right: 2em !important;
padding-left: 0 !important;
{% endif %}
}

/* Sidebar positioning */
div.sidebar,
aside.sidebar {
{%- if theme_rightsidebar|tobool %}
float: left !important;
{%- else %}
float: right !important;
{% endif %}
}

/* Lists and margins */
div.document ul {
margin-right: 1.5em !important;
margin-left: 0 !important;
}

div.document dd {
margin-right: 1.2em !important;
margin-left: 0 !important;
}

/* Admonitions */
div.admonition {
border-right: 0.2em solid black !important;
border-left: none !important;
padding: 2px 7px 1px 7px !important;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
padding: 2px 7px 1px 7px !important;

This is redundant? It is already defined, you are overriding the exact same thing

padding: 2px 7px 1px 7px;

I presume there are more cases of this

}

/* Search elements */
ul.search {
margin: 10px 20px 0 0 !important;
}

ul.search li {
padding: 5px 20px 5px 0 !important;
background-position: right 7px !important;
}

/* Table alignments */
table.indextable td {
text-align: right !important;
}

/* Footer adjustments */
div.footer .right {
text-align: left !important;
}

div.footer .left {
text-align: right !important;
}

/* Code blocks - keep LTR */
div.highlight pre {
direction: ltr !important;
text-align: left !important;
}

/* Header links */
a.headerlink {
padding-right: .3em !important;
padding-left: 0 !important;
}

/* Sidebar list adjustments */
div.sidebar li.toctree-l1 a,
aside.sidebar li.toctree-l1 a {
padding-right: 3px !important;
padding-left: 0 !important;
}

div.sidebar li.toctree-l2 a,
aside.sidebar li.toctree-l2 a {
margin-right: 1em !important;
margin-left: 0 !important;
}

div.sidebar li.toctree-l3 a,
aside.sidebar li.toctree-l3 a {
margin-right: 2em !important;
margin-left: 0 !important;
}

/* Float adjustments */
.left {
float: right !important;
}

.right {
float: left !important;
}

/* Image alignments */
img.align-left, .figure.align-left, object.align-left {
float: right !important;
margin-left: 1em !important;
margin-right: 0 !important;
}

img.align-right, .figure.align-right, object.align-right {
float: left !important;
margin-right: 1em !important;
margin-left: 0 !important;
}

/* Viewcode extension */
.viewcode-link, .viewcode-back {
float: left !important;
}

/* Equation numbers */
span.eqno {
float: left !important;
}
{% endif %}
2 changes: 2 additions & 0 deletions sphinx/themes/basic/static/basic.css.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/* -- main layout ----------------------------------------------------------- */

@import url("rtl.css");

div.clearer {
clear: both;
}
Expand Down
1 change: 1 addition & 0 deletions sphinx/themes/basic/static/documentation_options.js.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ const DOCUMENTATION_OPTIONS = {
NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}},
SHOW_SEARCH_SUMMARY: {{ 'true' if show_search_summary else 'false' }},
ENABLE_SEARCH_SHORTCUTS: {{ 'true' if theme_enable_search_shortcuts|tobool else 'false'}},
IS_RTL: {{ 'true' if is_rtl else 'false' }},
};
Loading