diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-10-04 16:41:44 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-10-04 16:41:44 +0300 |
commit | 598b85da75bc533004d68b95a5056016dc16df1c (patch) | |
tree | e08eae0ea5f098257f01081e4c792bcfeb92eba6 /sphinx/transforms | |
parent | 11633f2e53bf01f6844256558444991836815690 (diff) | |
parent | 38bb3774643d779b708970f941f2b16d1ab81b89 (diff) |
Merge branch '3.x' into master
Diffstat (limited to 'sphinx/transforms')
-rw-r--r-- | sphinx/transforms/post_transforms/images.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sphinx/transforms/post_transforms/images.py b/sphinx/transforms/post_transforms/images.py index f2cacac3c..949c09dde 100644 --- a/sphinx/transforms/post_transforms/images.py +++ b/sphinx/transforms/post_transforms/images.py @@ -11,7 +11,7 @@ import os import re from math import ceil -from typing import Any, Dict, List, Tuple +from typing import Any, Dict, List, Optional, Tuple from docutils import nodes @@ -175,6 +175,13 @@ class ImageConverter(BaseImageConverter): """ default_priority = 200 + #: The converter is available or not. Will be filled at the first call of + #: the build. The result is shared in the same process. + #: + #: .. todo:: This should be refactored not to store the state without class + #: variable. + available = None # type: Optional[bool] + #: A conversion rules the image converter supports. #: It is represented as a list of pair of source image format (mimetype) and #: destination one:: @@ -187,16 +194,14 @@ class ImageConverter(BaseImageConverter): conversion_rules = [] # type: List[Tuple[str, str]] def __init__(self, *args: Any, **kwargs: Any) -> None: - self.available = None # type: bool - # the converter is available or not. - # Will be checked at first conversion super().__init__(*args, **kwargs) def match(self, node: nodes.image) -> bool: if not self.app.builder.supported_image_types: return False elif self.available is None: - self.available = self.is_available() + # store the value to the class variable to share it during the build + self.__class__.available = self.is_available() if not self.available: return False |