Skip to content

Commit

Permalink
fix: let deprecated DownloadImages option move to HttpMethod: 'POST' …
Browse files Browse the repository at this point in the history
…for compatibility
  • Loading branch information
oniboni committed Oct 13, 2023
1 parent f848974 commit 5d077ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kroki/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
for diagram_type, diagram_file_type in file_type_overrides.items():
self.diagram_types_supporting_file[diagram_type] = diagram_file_type

log.info(
log.debug(
f"File and Diagram types configured: {self.diagram_types_supporting_file}"
)

Expand Down
15 changes: 14 additions & 1 deletion kroki/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
log = get_plugin_logger(__name__)


class DeprecatedDownloadImagesCompat(MKDocsConfigDeprecated):
def pre_validation(self, config: "KrokiPluginConfig", key_name: str) -> None:
"""Set `HttpMethod: 'POST'`, if enabled"""
if config.get(key_name) is None:
return

self.warnings.append(self.message.format(key_name))

DownloadImages: bool = config.pop(key_name)
if DownloadImages:
config.HttpMethod = "POST"


class KrokiPluginConfig(MkDocsBaseConfig):
ServerURL = MKDocsConfigURL(
default=os.getenv("KROKI_SERVER_URL", "https://kroki.io")
Expand All @@ -35,7 +48,7 @@ class KrokiPluginConfig(MkDocsBaseConfig):
FileTypes = MkDocsConfigType(list, default=["svg"])
FileTypeOverrides = MkDocsConfigType(dict, default={})

DownloadImages = MKDocsConfigDeprecated(moved_to="HttpMethod: 'POST'")
DownloadImages = DeprecatedDownloadImagesCompat(moved_to="HttpMethod: 'POST'")
DownloadDir = MKDocsConfigDeprecated(removed=True)


Expand Down

0 comments on commit 5d077ac

Please sign in to comment.