Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-03-13 11:10:50 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-03-13 11:15:12 +0300
commita523a896635b5fc5e48cd12a7c034ebcbc71a43b (patch)
tree3b8a6d41d3de3cdd2392ed2efa02b5e2f8ed7dec /sphinx/util
parentc817c206265f545529b5fabe43fdf162bbc9bea2 (diff)
refactor: Add a type alias for the option_spec of directives; OptionSpec
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/typing.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index afd2f805a..128fbd542 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -16,6 +16,8 @@ from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, TypeVa
from docutils import nodes
from docutils.parsers.rst.states import Inliner
+from sphinx.deprecation import RemovedInSphinx60Warning, deprecated_alias
+
if sys.version_info > (3, 7):
from typing import ForwardRef
else:
@@ -40,9 +42,6 @@ if False:
from typing import Type # NOQA # for python3.5.1
-# An entry of Directive.option_spec
-DirectiveOption = Callable[[str], Any]
-
# Text like nodes which are initialized with text and rawsource
TextlikeNode = Union[nodes.Text, nodes.TextElement]
@@ -56,6 +55,9 @@ PathMatcher = Callable[[str], bool]
RoleFunction = Callable[[str, str, str, int, Inliner, Dict[str, Any], List[str]],
Tuple[List[nodes.Node], List[nodes.system_message]]]
+# A option spec for directive
+OptionSpec = Dict[str, Callable[[Optional[str]], Any]]
+
# title getter functions for enumerable nodes (see sphinx.domains.std)
TitleGetter = Callable[[nodes.Node], str]
@@ -405,3 +407,10 @@ def _stringify_py36(annotation: Any) -> str:
return 'Union[%s]' % param_str
return qualname
+
+
+deprecated_alias('sphinx.util.typing',
+ {
+ 'DirectiveOption': Callable[[str], Any],
+ },
+ RemovedInSphinx60Warning)