From: Vladimír Vondruš Date: Sat, 24 Aug 2019 20:25:07 +0000 (+0200) Subject: documentation/python: add implicit kwargs to all plugin hooks. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=158f4363c5a599b003f5fd254a3cab3198e48514;p=blog.git documentation/python: add implicit kwargs to all plugin hooks. So they are future-proofed when new arguments are added. Need also *args because pelican passes things unnamed. --- diff --git a/documentation/test_python/page_plugins/plugins/fancyline.py b/documentation/test_python/page_plugins/plugins/fancyline.py index e0861007..507c316b 100644 --- a/documentation/test_python/page_plugins/plugins/fancyline.py +++ b/documentation/test_python/page_plugins/plugins/fancyline.py @@ -47,11 +47,11 @@ def _post_crawl(**kwargs): global post_crawl_call_count post_crawl_call_count = post_crawl_call_count + 1 -def _pre_page(): +def _pre_page(**kwargs): global pre_page_call_count pre_page_call_count = pre_page_call_count + 1 -def _post_run(): +def _post_run(**kwargs): global post_run_call_count post_run_call_count = post_run_call_count + 1 diff --git a/plugins/m/math.py b/plugins/m/math.py index f11ac57b..9082e401 100644 --- a/plugins/m/math.py +++ b/plugins/m/math.py @@ -100,7 +100,7 @@ class Math(rst.Directive): container.append(node) return [container] -def new_page(*args): +def new_page(*args, **kwargs): latex2svgextra.counter = 0 def math(role, rawtext, text, lineno, inliner, options={}, content=[]): @@ -133,7 +133,7 @@ def math(role, rawtext, text, lineno, inliner, options={}, content=[]): node = nodes.raw(rawtext, latex2svgextra.patch(text, svg, depth, attribs), format='html', **options) return [node], [] -def save_cache(*args): +def save_cache(*args, **kwargs): if settings['M_MATH_CACHE_FILE']: latex2svgextra.pickle_cache(settings['M_MATH_CACHE_FILE']) diff --git a/plugins/m/plots.py b/plugins/m/plots.py index 41505b90..e410aac6 100644 --- a/plugins/m/plots.py +++ b/plugins/m/plots.py @@ -260,7 +260,7 @@ class Plot(rst.Directive): container.append(node) return [container] -def new_page(*args): +def new_page(*args, **kwargs): mpl.rcParams['svg.hashsalt'] = 0 def register_mcss(mcss_settings, hooks_pre_page, **kwargs):