Add DirectiveOption type to an entry of Directive.option_spec

This commit is contained in:
Takeshi KOMIYA 2018-12-07 22:59:09 +09:00
parent 1d2929c806
commit 02f8d26fd3
2 changed files with 5 additions and 3 deletions

View File

@ -39,7 +39,7 @@ if False:
from sphinx.config import Config # NOQA from sphinx.config import Config # NOQA
from sphinx.environment import BuildEnvironment # NOQA from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.docfields import Field # NOQA from sphinx.util.docfields import Field # NOQA
from sphinx.util.typing import unicode # NOQA from sphinx.util.typing import DirectiveOption, unicode # NOQA
# RE to strip backslash escapes # RE to strip backslash escapes
@ -60,7 +60,7 @@ class ObjectDescription(SphinxDirective):
final_argument_whitespace = True final_argument_whitespace = True
option_spec = { option_spec = {
'noindex': directives.flag, 'noindex': directives.flag,
} } # type: Dict[str, DirectiveOption]
# types of doc fields that this directive handles, see sphinx.util.docfields # types of doc fields that this directive handles, see sphinx.util.docfields
doc_field_types = [] # type: List[Field] doc_field_types = [] # type: List[Field]

View File

@ -9,7 +9,7 @@
:license: BSD, see LICENSE for details. :license: BSD, see LICENSE for details.
""" """
from typing import Callable, Dict, List, Tuple, TypeVar from typing import Any, Callable, Dict, List, Tuple, TypeVar
from docutils import nodes from docutils import nodes
from docutils.parsers.rst.states import Inliner from docutils.parsers.rst.states import Inliner
@ -26,6 +26,8 @@ else:
N_co = TypeVar('N_co', bound=nodes.Node, covariant=True) N_co = TypeVar('N_co', bound=nodes.Node, covariant=True)
# An entry of Directive.option_spec
DirectiveOption = Callable[[str], Any]
# common role functions # common role functions
RoleFunction = Callable[[text_type, text_type, text_type, int, Inliner, Dict, List[text_type]], RoleFunction = Callable[[text_type, text_type, text_type, int, Inliner, Dict, List[text_type]],