Skip to content

Commit

Permalink
Increase minimum Docutils to 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 27, 2022
1 parent f41e184 commit 58e894c
Show file tree
Hide file tree
Showing 23 changed files with 28 additions and 209 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Expand Up @@ -14,11 +14,11 @@ jobs:
matrix:
include:
- python: "3.8"
docutils: du17
- python: "3.9"
docutils: du18
- python: "3.9"
docutils: du19
- python: "3.10"
docutils: du18
docutils: du19
- python: "3.10"
docutils: du19
- python: "3.11-dev"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -63,7 +63,7 @@ dependencies = [
"sphinxcontrib-qthelp",
"Jinja2>=3.0",
"Pygments>=2.12",
"docutils>=0.17,<0.20",
"docutils>=0.18,<0.20",
"snowballstemmer>=2.0",
"babel>=2.9",
"alabaster>=0.7,<0.8",
Expand Down
29 changes: 12 additions & 17 deletions sphinx/addnodes.py
Expand Up @@ -2,19 +2,24 @@

from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence

import docutils
from docutils import nodes
from docutils.nodes import Element

from sphinx.deprecation import RemovedInSphinx70Warning, deprecated_alias

if TYPE_CHECKING:
from sphinx.application import Sphinx

try:
from docutils.nodes import meta as docutils_meta # type: ignore
except ImportError:
# docutils-0.17
from docutils.parsers.rst.directives.html import MetaBody
docutils_meta = MetaBody.meta
deprecated_alias('sphinx.addnodes',
{
'meta': nodes.meta, # type: ignore
'docutils_meta': nodes.meta, # type: ignore
},
RemovedInSphinx70Warning,
{
'meta': 'docutils.nodes.meta',
'docutils_meta': 'docutils.nodes.meta',
})


class document(nodes.document):
Expand Down Expand Up @@ -424,13 +429,6 @@ class tabular_col_spec(nodes.Element):
"""Node for specifying tabular columns, used for LaTeX output."""


class meta(nodes.Special, nodes.PreBibliographic, nodes.Element):
"""Node for meta directive -- same as docutils' standard meta node,
but pickleable.
"""
rawcontent = None


# inline nodes

class pending_xref(nodes.Inline, nodes.Element):
Expand Down Expand Up @@ -557,9 +555,6 @@ def setup(app: "Sphinx") -> Dict[str, Any]:
app.add_node(literal_strong)
app.add_node(manpage)

if docutils.__version_info__ < (0, 18):
app.add_node(meta)

return {
'version': 'builtin',
'parallel_read_safe': True,
Expand Down
28 changes: 2 additions & 26 deletions sphinx/directives/patches.py
@@ -1,14 +1,14 @@
import os
from os import path
from typing import TYPE_CHECKING, Any, Dict, List, Sequence, cast
from typing import TYPE_CHECKING, Any, Dict, List, cast

from docutils import nodes
from docutils.nodes import Node, make_id
from docutils.parsers.rst import directives
from docutils.parsers.rst.directives import images, tables
from docutils.parsers.rst.directives.misc import Meta # type: ignore[attr-defined]
from docutils.parsers.rst.roles import set_classes

from sphinx import addnodes
from sphinx.directives import optional_int
from sphinx.domains.math import MathDomain
from sphinx.locale import __
Expand All @@ -18,30 +18,6 @@
from sphinx.util.osutil import SEP, os_path, relpath
from sphinx.util.typing import OptionSpec

try:
from docutils.parsers.rst.directives.misc import Meta as Meta # type: ignore
except ImportError:
# docutils-0.17
from docutils.parsers.rst.directives.html import Meta as MetaBase

class Meta(MetaBase, SphinxDirective): # type: ignore
def run(self) -> Sequence[Node]: # type: ignore
result = super().run()
for node in result:
# for docutils-0.17. Since docutils-0.18, patching is no longer needed
# because it uses picklable node; ``docutils.nodes.meta``.
if (isinstance(node, nodes.pending) and
isinstance(node.details['nodes'][0], addnodes.docutils_meta)):
meta = node.details['nodes'][0]
meta.source = self.env.doc2path(self.env.docname)
meta.line = self.lineno
meta.rawcontent = meta['content']

# docutils' meta nodes aren't picklable because the class is nested
meta.__class__ = addnodes.meta

return result

if TYPE_CHECKING:
from sphinx.application import Sphinx

Expand Down
3 changes: 0 additions & 3 deletions sphinx/environment/__init__.py
Expand Up @@ -9,7 +9,6 @@
from typing import (TYPE_CHECKING, Any, Callable, Dict, Generator, Iterator, List, Optional,
Set, Tuple, Union)

import docutils
from docutils import nodes
from docutils.nodes import Node

Expand Down Expand Up @@ -52,8 +51,6 @@
'file_insertion_enabled': True,
'smartquotes_locales': [],
}
if docutils.__version_info__[:2] <= (0, 17):
default_settings['embed_images'] = False

# This is increased every time an environment attribute is added
# or changed to properly invalidate pickle files.
Expand Down
4 changes: 2 additions & 2 deletions sphinx/search/__init__.py
Expand Up @@ -189,8 +189,8 @@ def __init__(self, document: nodes.document, lang: SearchLanguage) -> None:
self.lang = lang

def is_meta_keywords(self, node: Element) -> bool:
if (isinstance(node, (addnodes.meta, addnodes.docutils_meta)) and
node.get('name') == 'keywords'):
if (isinstance(node, nodes.meta) # type: ignore
and node.get('name') == 'keywords'):
meta_lang = node.get('lang')
if meta_lang is None: # lang not specified
return True
Expand Down
45 changes: 0 additions & 45 deletions sphinx/themes/basic/static/basic.css_t
Expand Up @@ -237,18 +237,6 @@ a.headerlink {
visibility: hidden;
}

{%- if docutils_version_info[:2] < (0, 18) %}
a.brackets:before,
span.brackets > a:before{
content: "[";
}

a.brackets:after,
span.brackets > a:after {
content: "]";
}
{% endif %}

h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
Expand Down Expand Up @@ -337,20 +325,16 @@ p.sidebar-title {
font-weight: bold;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{%- endif %}
div.admonition, div.topic, blockquote {
clear: left;
}

/* -- topics ---------------------------------------------------------------- */

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{%- endif %}
div.topic {
border: 1px solid #ccc;
padding: 7px;
Expand Down Expand Up @@ -389,21 +373,17 @@ div.body p.centered {

div.sidebar > :last-child,
aside.sidebar > :last-child,
{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents > :last-child,
aside.topic > :last-child,
{%- endif %}
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}

div.sidebar::after,
aside.sidebar::after,
{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents::after,
aside.topic::after,
{%- endif %}
div.topic::after,
div.admonition::after,
blockquote::after {
Expand Down Expand Up @@ -629,24 +609,6 @@ ul.simple p {
margin-bottom: 0;
}

{%- if docutils_version_info[:2] < (0, 18) %}
dl.footnote > dt,
dl.citation > dt {
float: left;
margin-right: 0.5em;
}

dl.footnote > dd,
dl.citation > dd {
margin-bottom: 0em;
}

dl.footnote > dd:after,
dl.citation > dd:after {
content: "";
clear: both;
}
{%- elif docutils_version_info[:2] >= (0, 18) %}
aside.footnote > span,
div.citation > span {
float: left;
Expand All @@ -670,7 +632,6 @@ div.citation > p:last-of-type:after {
content: "";
clear: both;
}
{%- endif %}

dl.field-list {
display: grid;
Expand All @@ -684,12 +645,6 @@ dl.field-list > dt {
padding-right: 5px;
}

{%- if docutils_version_info[:2] < (0, 18) %}
dl.field-list > dt:after {
content: ":";
}
{% endif %}

dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/bizstyle/static/bizstyle.css_t
Expand Up @@ -306,10 +306,8 @@ div.quotebar {
border: 1px solid #ccc;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #f8f8f8;
}
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/classic/static/classic.css_t
Expand Up @@ -290,10 +290,8 @@ div.seealso {
border: 1px solid #ff6;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #eee;
}
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/epub/static/epub.css_t
Expand Up @@ -245,10 +245,8 @@ p.sidebar-title {

/* -- topics ---------------------------------------------------------------- */

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/nature/static/nature.css_t
Expand Up @@ -194,10 +194,8 @@ div.seealso {
border: 1px solid #ff6;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #eee;
}
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/nonav/static/nonav.css_t
Expand Up @@ -234,10 +234,8 @@ p.sidebar-title {

/* -- topics ---------------------------------------------------------------- */

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/pyramid/static/epub.css_t
Expand Up @@ -254,10 +254,8 @@ div.seealso {
border: 1px solid #ff6;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #eee;
}
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/pyramid/static/pyramid.css_t
Expand Up @@ -245,10 +245,8 @@ div.seealso {
padding: 10px 20px 10px 60px;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background: #eeeeee;
border: 2px solid #C6C9CB;
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/sphinxdoc/static/sphinxdoc.css_t
Expand Up @@ -266,10 +266,8 @@ div.quotebar {
border: 1px solid #ccc;
}

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #f8f8f8;
}
Expand Down
2 changes: 0 additions & 2 deletions sphinx/themes/traditional/static/traditional.css_t
Expand Up @@ -506,10 +506,8 @@ p.rubric {

/* "Topics" */

{%- if docutils_version_info[:2] >= (0, 18) %}
nav.contents,
aside.topic,
{% endif %}
div.topic {
background-color: #eee;
border: 1px solid #ccc;
Expand Down
9 changes: 2 additions & 7 deletions sphinx/transforms/i18n.py
Expand Up @@ -19,7 +19,7 @@
from sphinx.util import get_filetype, logging, split_index_msg
from sphinx.util.i18n import docname_to_domain
from sphinx.util.nodes import (IMAGE_TYPE_NODES, LITERAL_TYPE_NODES, NodeMatcher,
extract_messages, is_pending_meta, traverse_translatable_index)
extract_messages, traverse_translatable_index)

if TYPE_CHECKING:
from sphinx.application import Sphinx
Expand Down Expand Up @@ -254,12 +254,7 @@ def apply(self, **kwargs: Any) -> None:
continue

# update meta nodes
if isinstance(node, nodes.pending) and is_pending_meta(node):
# docutils-0.17
node.details['nodes'][0]['content'] = msgstr
continue
elif isinstance(node, addnodes.docutils_meta):
# docutils-0.18+
if isinstance(node, nodes.meta): # type: ignore
node['content'] = msgstr
continue

Expand Down

0 comments on commit 58e894c

Please sign in to comment.