Skip to content

Commit 380647d

Browse files
authored
Merge pull request #1123 from readthedocs/Blendify/sphinx4
Add compatibility for sphinx4
2 parents 6417def + 0207996 commit 380647d

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ commands:
88
type: string
99
sphinx-version:
1010
type: string
11-
default: "16,17,18,20,21,22,23,24,30,31,32,33,34,latest"
11+
default: "16,17,18,20,21,22,23,24,30,31,32,33,34,35,40,41,latest"
1212
steps:
1313
- checkout
1414
- run: pip install --user tox

sphinx_rtd_theme/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def config_initiated(app, config):
3131
_('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
3232
)
3333

34-
3534
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
3635
def setup(app):
3736
if python_version[0] < 3:

sphinx_rtd_theme/layout.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
1010
{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%}
1111

12+
{# Build sphinx_version_info tuple from sphinx_version string in pure Jinja #}
13+
{%- set (_ver_major, _ver_minor, _ver_bugfix) = sphinx_version.split('.') | map('int') -%}
14+
{%- set sphinx_version_info = (_ver_major, _ver_minor, _ver_bugfix) -%}
15+
1216
<!DOCTYPE html>
1317
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
1418
<head>
@@ -20,8 +24,10 @@
2024
{%- endblock -%}
2125

2226
{#- CSS #}
23-
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
24-
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
27+
{%- if sphinx_version_info < (4, 0) -%}
28+
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
29+
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
30+
{%- endif %}
2531
{%- for css in css_files %}
2632
{%- if css|attr("rel") %}
2733
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
@@ -56,8 +62,10 @@
5662
<![endif]-->
5763
{%- if not embedded %}
5864
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
59-
{%- if sphinx_version >= "1.8.0" -%}
65+
{%- if sphinx_version_info >= (1, 8) -%}
66+
{%- if sphinx_version_info < (4, 0) -%}
6067
<script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
68+
{%- endif -%}
6169
{%- for scriptfile in script_files %}
6270
{{ js_tag(scriptfile) }}
6371
{%- endfor %}

sphinx_rtd_theme/static/css/theme.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sass/_theme_rst.sass

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@
9494
font-family: $code-font-family
9595
font-size: 12px
9696
line-height: 1.4
97-
98-
// Do not allow selection of code block prompts
99-
div.highlight .gp
100-
user-select: none
101-
pointer-events: none
97+
98+
// Do not allow selection of code block prompts and line numbers
99+
div.highlight
100+
span.linenos, .gp
101+
user-select: none
102+
pointer-events: none
103+
104+
span.linenos
105+
display: inline-block
106+
padding-left: 0px
107+
padding-right: ($base-line-height / 2)
108+
margin-right: ($base-line-height / 2)
109+
border-right: 1px solid lighten($table-border-color, 2%)
102110

103111
.code-block-caption
104112
font-style: italic
@@ -452,6 +460,12 @@
452460
.property
453461
display: inline-block
454462
padding-right: 8px
463+
// This is keywords such as "const"
464+
.k
465+
font-style: italic
466+
.sig-name, .descname, .descclassname
467+
font-family: $code-font-family
468+
color: $black
455469
// Doc links to sourcecode
456470
.viewcode-link, .viewcode-back
457471
display: inline-block

tests/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def build(root, builder='html', **kwargs):
3333
confoverrides = kwargs.pop('confoverrides', {})
3434
confoverrides['html_theme'] = 'sphinx_rtd_theme'
3535
extensions = confoverrides.get('extensions', [])
36+
extensions.append('sphinx_rtd_theme')
3637
extensions.append('readthedocs_ext.readthedocs')
3738
confoverrides['extensions'] = extensions
3839
kwargs['confoverrides'] = confoverrides

tox.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{27,36,37,38,39}-sphinx{16,17,18,20,21,22,23,24,30,31,32,33,34,latest}
2+
envlist = py{27,36,37,38,39}-sphinx{16,17,18,20,21,22,23,24,30,31,32,33,34,35,40,41,latest}
33

44
[testenv]
55
setev =
@@ -22,6 +22,9 @@ deps =
2222
sphinx32: Sphinx < 3.3
2323
sphinx33: Sphinx < 3.4
2424
sphinx34: Sphinx < 3.5
25+
sphinx35: Sphinx < 3.6
26+
sphinx40: Sphinx < 4.1
27+
sphinx41: Sphinx < 4.2
2528
sphinxlatest: Sphinx
2629
commands =
2730
pytest {posargs} tests/

0 commit comments

Comments
 (0)