From 68531d4e966c1f14cbc3631c549fc605f4dfd4e1 Mon Sep 17 00:00:00 2001 From: ftnext Date: Mon, 5 Feb 2024 22:19:53 +0900 Subject: [PATCH] [feat] Experimental support of method assignment --- sphinx_new_tab_link/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx_new_tab_link/__init__.py b/sphinx_new_tab_link/__init__.py index a7ab826..e96cec6 100644 --- a/sphinx_new_tab_link/__init__.py +++ b/sphinx_new_tab_link/__init__.py @@ -18,7 +18,11 @@ def starttag(self, node, tagname, *args, **atts): ): atts["target"] = "_blank" atts["rel"] = "noopener noreferrer" - return super().starttag(node, tagname, *args, **atts) + # Support method assignment like the following (But hack) + # SomeTranslator.starttag = NewTabLinkHTMLTranslator.starttag + return super(self.__class__, self).starttag( + node, tagname, *args, **atts + ) def setup(app):