mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Add compatibility for sphinx4
Sphinx 4.x moves javascript and css declarations to `script_files` and `css_files`. This patch fixes duplicatd link and script tags when using sphinx4 Sphinx 4.x changes the default setting of html_codeblock_linenos_style to 'inline' and deprecates `html_codeblock_linenos_style`. The css for `.hll` to make the hightling span the full line cause the line number and code to be split on seperate lines. I could not get the highlight to span the full line so it was removed completely. I also made line numbers not selectible by the user. This changes also adds the needed changes to the tox testing enviorment alhough, sphinx4 is not officially released to pypi yet. You will need to test these changes locally using: `pip install git+https://github.com/sphinx-doc/sphinx@master`
This commit is contained in:
parent
3db4e2fbfe
commit
836467e4b9
@ -8,7 +8,7 @@ commands:
|
|||||||
type: string
|
type: string
|
||||||
sphinx-version:
|
sphinx-version:
|
||||||
type: string
|
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,latest"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: pip install --user tox
|
- run: pip install --user tox
|
||||||
|
@ -20,8 +20,10 @@
|
|||||||
{%- endblock -%}
|
{%- endblock -%}
|
||||||
|
|
||||||
{#- CSS #}
|
{#- CSS #}
|
||||||
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
{%- if (sphinx_version <= "4.0.0") -%}
|
||||||
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
|
<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 %}
|
{%- for css in css_files %}
|
||||||
{%- if css|attr("rel") %}
|
{%- 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 %} />
|
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
|
||||||
@ -57,7 +59,9 @@
|
|||||||
{%- if not embedded %}
|
{%- 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 #}
|
{# 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 >= "1.8.0" -%}
|
||||||
|
{%- if sphinx_version <= "4.0.0" -%}
|
||||||
<script type="text/javascript" id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
|
<script type="text/javascript" id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
|
||||||
|
{%- endif -%}
|
||||||
{%- for scriptfile in script_files %}
|
{%- for scriptfile in script_files %}
|
||||||
{{ js_tag(scriptfile) }}
|
{{ js_tag(scriptfile) }}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -85,18 +85,13 @@
|
|||||||
padding: ($base-line-height / 2) ($base-line-height / 2)
|
padding: ($base-line-height / 2) ($base-line-height / 2)
|
||||||
display: block
|
display: block
|
||||||
overflow: auto
|
overflow: auto
|
||||||
& .hll
|
|
||||||
// Line emphasis spans full width
|
|
||||||
display: block
|
|
||||||
margin: 0 (-1 * $base-line-height / 2)
|
|
||||||
padding: 0 ($base-line-height / 2)
|
|
||||||
pre.literal-block, div[class^='highlight'] pre, .linenodiv pre
|
pre.literal-block, div[class^='highlight'] pre, .linenodiv pre
|
||||||
font-family: $code-font-family
|
font-family: $code-font-family
|
||||||
font-size: 12px
|
font-size: 12px
|
||||||
line-height: 1.4
|
line-height: 1.4
|
||||||
|
|
||||||
// Do not allow selection of code block prompts
|
// Do not allow selection of code block prompts and line numbers
|
||||||
div.highlight .gp
|
.lineno, .gp
|
||||||
user-select: none
|
user-select: none
|
||||||
pointer-events: none
|
pointer-events: none
|
||||||
|
|
||||||
|
4
tox.ini
4
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[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,latest}
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setev =
|
setev =
|
||||||
@ -22,6 +22,8 @@ deps =
|
|||||||
sphinx32: Sphinx < 3.3
|
sphinx32: Sphinx < 3.3
|
||||||
sphinx33: Sphinx < 3.4
|
sphinx33: Sphinx < 3.4
|
||||||
sphinx34: Sphinx < 3.5
|
sphinx34: Sphinx < 3.5
|
||||||
|
sphinx35: Sphinx < 4.0
|
||||||
|
sphinx40: Sphinx < 4.1
|
||||||
sphinxlatest: Sphinx
|
sphinxlatest: Sphinx
|
||||||
commands =
|
commands =
|
||||||
pytest {posargs} tests/
|
pytest {posargs} tests/
|
||||||
|
Loading…
Reference in New Issue
Block a user