diff options
Diffstat (limited to 'sphinx/directives')
-rw-r--r-- | sphinx/directives/__init__.py | 42 | ||||
-rw-r--r-- | sphinx/directives/code.py | 17 | ||||
-rw-r--r-- | sphinx/directives/other.py | 16 | ||||
-rw-r--r-- | sphinx/directives/patches.py | 25 |
4 files changed, 26 insertions, 74 deletions
diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 574962d81..7684931c7 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -10,7 +10,7 @@ import re from typing import Any, Dict, List, Tuple -from typing import cast +from typing import TYPE_CHECKING, cast from docutils import nodes from docutils.nodes import Node @@ -18,16 +18,13 @@ from docutils.parsers.rst import directives, roles from sphinx import addnodes from sphinx.addnodes import desc_signature -from sphinx.deprecation import ( - RemovedInSphinx40Warning, RemovedInSphinx50Warning, deprecated_alias -) +from sphinx.deprecation import RemovedInSphinx50Warning, deprecated_alias from sphinx.util import docutils from sphinx.util.docfields import DocFieldTransformer, Field, TypedField from sphinx.util.docutils import SphinxDirective from sphinx.util.typing import DirectiveOption -if False: - # For type annotation +if TYPE_CHECKING: from sphinx.application import Sphinx @@ -266,39 +263,6 @@ class DefaultDomain(SphinxDirective): self.env.temp_data['default_domain'] = self.env.domains.get(domain_name) return [] -from sphinx.directives.code import ( # noqa - Highlight, CodeBlock, LiteralInclude -) -from sphinx.directives.other import ( # noqa - TocTree, Author, VersionChange, SeeAlso, - TabularColumns, Centered, Acks, HList, Only, Include, Class -) -from sphinx.directives.patches import ( # noqa - Figure, Meta -) -from sphinx.domains.index import IndexDirective # noqa - -deprecated_alias('sphinx.directives', - { - 'Highlight': Highlight, - 'CodeBlock': CodeBlock, - 'LiteralInclude': LiteralInclude, - 'TocTree': TocTree, - 'Author': Author, - 'Index': IndexDirective, - 'VersionChange': VersionChange, - 'SeeAlso': SeeAlso, - 'TabularColumns': TabularColumns, - 'Centered': Centered, - 'Acks': Acks, - 'HList': HList, - 'Only': Only, - 'Include': Include, - 'Class': Class, - 'Figure': Figure, - 'Meta': Meta, - }, - RemovedInSphinx40Warning) deprecated_alias('sphinx.directives', { diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 8c19dd0c5..fabf259e8 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -7,9 +7,9 @@ """ import sys -import warnings from difflib import unified_diff from typing import Any, Dict, List, Tuple +from typing import TYPE_CHECKING from docutils import nodes from docutils.nodes import Element, Node @@ -18,14 +18,12 @@ from docutils.statemachine import StringList from sphinx import addnodes from sphinx.config import Config -from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.locale import __ from sphinx.util import logging from sphinx.util import parselinenos from sphinx.util.docutils import SphinxDirective -if False: - # For type annotation +if TYPE_CHECKING: from sphinx.application import Sphinx logger = logging.getLogger(__name__) @@ -57,16 +55,6 @@ class Highlight(SphinxDirective): linenothreshold=linenothreshold)] -class HighlightLang(Highlight): - """highlightlang directive (deprecated)""" - - def run(self) -> List[Node]: - warnings.warn('highlightlang directive is deprecated. ' - 'Please use highlight directive instead.', - RemovedInSphinx40Warning, stacklevel=2) - return super().run() - - def dedent_lines(lines: List[str], dedent: int, location: Tuple[str, int] = None) -> List[str]: if not dedent: return lines @@ -468,7 +456,6 @@ class LiteralInclude(SphinxDirective): def setup(app: "Sphinx") -> Dict[str, Any]: directives.register_directive('highlight', Highlight) - directives.register_directive('highlightlang', HighlightLang) directives.register_directive('code-block', CodeBlock) directives.register_directive('sourcecode', CodeBlock) directives.register_directive('literalinclude', LiteralInclude) diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index e4fcc0f5c..fc1631edc 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -8,7 +8,7 @@ import re from typing import Any, Dict, List -from typing import cast +from typing import TYPE_CHECKING, cast from docutils import nodes from docutils.nodes import Element, Node @@ -18,7 +18,6 @@ from docutils.parsers.rst.directives.misc import Class from docutils.parsers.rst.directives.misc import Include as BaseInclude from sphinx import addnodes -from sphinx.deprecation import RemovedInSphinx40Warning, deprecated_alias from sphinx.domains.changeset import VersionChange # NOQA # for compatibility from sphinx.locale import _ from sphinx.util import url_re, docname_join @@ -26,8 +25,7 @@ from sphinx.util.docutils import SphinxDirective from sphinx.util.matching import Matcher, patfilter from sphinx.util.nodes import explicit_title_re -if False: - # For type annotation +if TYPE_CHECKING: from sphinx.application import Sphinx @@ -361,16 +359,6 @@ class Include(BaseInclude, SphinxDirective): return super().run() -# Import old modules here for compatibility -from sphinx.domains.index import IndexDirective # NOQA - -deprecated_alias('sphinx.directives.other', - { - 'Index': IndexDirective, - }, - RemovedInSphinx40Warning) - - def setup(app: "Sphinx") -> Dict[str, Any]: directives.register_directive('toctree', TocTree) directives.register_directive('sectionauthor', Author) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 4b73a7955..c4535e119 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -6,8 +6,9 @@ :license: BSD, see LICENSE for details. """ +import warnings from typing import Any, Dict, List, Tuple -from typing import cast +from typing import TYPE_CHECKING, cast from docutils import nodes from docutils.nodes import Node, make_id, system_message @@ -15,13 +16,13 @@ from docutils.parsers.rst import directives from docutils.parsers.rst.directives import images, html, tables from sphinx import addnodes +from sphinx.deprecation import RemovedInSphinx60Warning from sphinx.directives import optional_int from sphinx.domains.math import MathDomain from sphinx.util.docutils import SphinxDirective from sphinx.util.nodes import set_source_info -if False: - # For type annotation +if TYPE_CHECKING: from sphinx.application import Sphinx @@ -73,6 +74,11 @@ class RSTTable(tables.RSTTable): Only for docutils-0.13 or older version.""" + def run(self) -> List[Node]: + warnings.warn('RSTTable is deprecated.', + RemovedInSphinx60Warning) + return super().run() + def make_title(self) -> Tuple[nodes.title, List[system_message]]: title, message = super().make_title() if title: @@ -86,6 +92,11 @@ class CSVTable(tables.CSVTable): Only for docutils-0.13 or older version.""" + def run(self) -> List[Node]: + warnings.warn('RSTTable is deprecated.', + RemovedInSphinx60Warning) + return super().run() + def make_title(self) -> Tuple[nodes.title, List[system_message]]: title, message = super().make_title() if title: @@ -99,6 +110,11 @@ class ListTable(tables.ListTable): Only for docutils-0.13 or older version.""" + def run(self) -> List[Node]: + warnings.warn('RSTTable is deprecated.', + RemovedInSphinx60Warning) + return super().run() + def make_title(self) -> Tuple[nodes.title, List[system_message]]: title, message = super().make_title() if title: @@ -209,9 +225,6 @@ class MathDirective(SphinxDirective): def setup(app: "Sphinx") -> Dict[str, Any]: directives.register_directive('figure', Figure) directives.register_directive('meta', Meta) - directives.register_directive('table', RSTTable) - directives.register_directive('csv-table', CSVTable) - directives.register_directive('list-table', ListTable) directives.register_directive('code', Code) directives.register_directive('math', MathDirective) |