Merge pull request #1123 from readthedocs/Blendify/sphinx4

Add compatibility for sphinx4
This commit is contained in:
Anthony 2021-07-19 17:56:43 -06:00 committed by GitHub
commit 380647d159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 12 deletions

View File

@ -8,7 +8,7 @@ commands:
type: string
sphinx-version:
type: string
default: "16,17,18,20,21,22,23,24,30,31,32,33,34,latest"
default: "16,17,18,20,21,22,23,24,30,31,32,33,34,35,40,41,latest"
steps:
- checkout
- run: pip install --user tox

View File

@ -31,7 +31,6 @@ def config_initiated(app, config):
_('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
)
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
def setup(app):
if python_version[0] < 3:

View File

@ -9,6 +9,10 @@
{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%}
{# Build sphinx_version_info tuple from sphinx_version string in pure Jinja #}
{%- set (_ver_major, _ver_minor, _ver_bugfix) = sphinx_version.split('.') | map('int') -%}
{%- set sphinx_version_info = (_ver_major, _ver_minor, _ver_bugfix) -%}
<!DOCTYPE html>
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
<head>
@ -20,8 +24,10 @@
{%- endblock -%}
{#- CSS #}
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- if sphinx_version_info < (4, 0) -%}
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- endif %}
{%- for css in css_files %}
{%- if css|attr("rel") %}
<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 @@
<![endif]-->
{%- if not embedded %}
{# 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 #}
{%- if sphinx_version >= "1.8.0" -%}
{%- if sphinx_version_info >= (1, 8) -%}
{%- if sphinx_version_info < (4, 0) -%}
<script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
{%- endif -%}
{%- for scriptfile in script_files %}
{{ js_tag(scriptfile) }}
{%- endfor %}

File diff suppressed because one or more lines are too long

View File

@ -94,11 +94,19 @@
font-family: $code-font-family
font-size: 12px
line-height: 1.4
// Do not allow selection of code block prompts
div.highlight .gp
user-select: none
pointer-events: none
// Do not allow selection of code block prompts and line numbers
div.highlight
span.linenos, .gp
user-select: none
pointer-events: none
span.linenos
display: inline-block
padding-left: 0px
padding-right: ($base-line-height / 2)
margin-right: ($base-line-height / 2)
border-right: 1px solid lighten($table-border-color, 2%)
.code-block-caption
font-style: italic
@ -452,6 +460,12 @@
.property
display: inline-block
padding-right: 8px
// This is keywords such as "const"
.k
font-style: italic
.sig-name, .descname, .descclassname
font-family: $code-font-family
color: $black
// Doc links to sourcecode
.viewcode-link, .viewcode-back
display: inline-block

View File

@ -33,6 +33,7 @@ def build(root, builder='html', **kwargs):
confoverrides = kwargs.pop('confoverrides', {})
confoverrides['html_theme'] = 'sphinx_rtd_theme'
extensions = confoverrides.get('extensions', [])
extensions.append('sphinx_rtd_theme')
extensions.append('readthedocs_ext.readthedocs')
confoverrides['extensions'] = extensions
kwargs['confoverrides'] = confoverrides

View File

@ -1,5 +1,5 @@
[tox]
envlist = py{27,36,37,38,39}-sphinx{16,17,18,20,21,22,23,24,30,31,32,33,34,latest}
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}
[testenv]
setev =
@ -22,6 +22,9 @@ deps =
sphinx32: Sphinx < 3.3
sphinx33: Sphinx < 3.4
sphinx34: Sphinx < 3.5
sphinx35: Sphinx < 3.6
sphinx40: Sphinx < 4.1
sphinx41: Sphinx < 4.2
sphinxlatest: Sphinx
commands =
pytest {posargs} tests/