summaryrefslogtreecommitdiff
path: root/sphinx/util/docfields.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-03-22 00:03:53 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-03-23 17:27:22 +0900
commita990f9ff724bc04e434167a0f98b60583f973ce8 (patch)
tree11e82fc9dc69899a614f2d1572cb12f438e6dda6 /sphinx/util/docfields.py
parent86f0336693df45acdc2e968322bd794171e45eef (diff)
downloadsphinx-git-a990f9ff724bc04e434167a0f98b60583f973ce8.tar.gz
Add ObjectDescription.get_field_type_map()
Conceal caching mechanism of Field classes to ObjectDescription class. This deprecates DocFieldTransformer.preprocess_field_types().
Diffstat (limited to 'sphinx/util/docfields.py')
-rw-r--r--sphinx/util/docfields.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py
index 591ca0786..9b19d229d 100644
--- a/sphinx/util/docfields.py
+++ b/sphinx/util/docfields.py
@@ -9,15 +9,18 @@
:license: BSD, see LICENSE for details.
"""
+import warnings
from typing import List, Tuple, cast
from docutils import nodes
from sphinx import addnodes
+from sphinx.deprecation import RemovedInSphinx40Warning
if False:
# For type annotation
from typing import Any, Dict, Type, Union # NOQA
+ from sphinx.directive import ObjectDescription # NOQA
from sphinx.environment import BuildEnvironment # NOQA
from sphinx.util.typing import TextlikeNode # NOQA
@@ -244,15 +247,14 @@ class DocFieldTransformer:
typemap = None # type: Dict[str, Tuple[Field, bool]]
def __init__(self, directive):
- # type: (Any) -> None
+ # type: (ObjectDescription) -> None
self.directive = directive
- if '_doc_field_type_map' not in directive.__class__.__dict__:
- directive.__class__._doc_field_type_map = \
- self.preprocess_fieldtypes(directive.__class__.doc_field_types)
- self.typemap = directive._doc_field_type_map
+ self.typemap = directive.get_field_type_map()
def preprocess_fieldtypes(self, types):
# type: (List[Field]) -> Dict[str, Tuple[Field, bool]]
+ warnings.warn('DocFieldTransformer.preprocess_fieldtypes() is deprecated.',
+ RemovedInSphinx40Warning)
typemap = {}
for fieldtype in types:
for name in fieldtype.names: