Fix #6474: `DocFieldTransformer` raises AttributeError

This commit is contained in:
Takeshi KOMIYA 2019-08-02 02:07:40 +09:00
parent 4732ec5edf
commit ec71c4d14a
2 changed files with 10 additions and 1 deletions

View File

@ -64,6 +64,8 @@ Bugs fixed
* #6561: glossary: Wrong hyperlinks are generated for non alphanumeric terms
* #6620: i18n: classifiers of definition list are not translated with
docutils-0.15
* #6474: ``DocFieldTransformer`` raises AttributeError when given directive is
not a subclass of ObjectDescription
Testing
--------

View File

@ -218,7 +218,14 @@ class DocFieldTransformer:
def __init__(self, directive: "ObjectDescription") -> None:
self.directive = directive
try:
self.typemap = directive.get_field_type_map()
except Exception:
# for 3rd party extensions directly calls this transformer.
warnings.warn('DocFieldTransformer expects given directive object is a subclass '
'of ObjectDescription.', RemovedInSphinx40Warning)
self.typemap = self.preprocess_fieldtypes(directive.__class__.doc_field_types)
def preprocess_fieldtypes(self, types: List[Field]) -> Dict[str, Tuple[Field, bool]]:
warnings.warn('DocFieldTransformer.preprocess_fieldtypes() is deprecated.',