ftnext / sphinx-new-tab-link

Open external links in new tabs of the browser in Sphinx HTML documents
https://ftnext.github.io/sphinx-new-tab-link/guide.html
MIT License
9 stars 2 forks source link

:bug: extension fails with latest sphinx #11

Closed enryH closed 4 months ago

enryH commented 4 months ago

Thanks for the extension! The possibility to change the default how links are opened is really nice.

Lately I noticed my builds failing with the latest sphinx version. Removing the extension, results in a successful build. Build error log from READTHEDOCS: link

The build process goes into a infinite recursion and fails:

Running Sphinx v7.2.6
making output directory... done
myst v2.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'dollarmath', 'amsmath'}, disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
myst-nb v1.0.0: NbParserConfig(custom_formats={}, metadata_key='mystnb', cell_metadata_key='mystnb', kernel_rgx_aliases={}, eval_name_regex='^[a-zA-Z_][a-zA-Z0-9_]*$', execution_mode='auto', execution_cache_path='', execution_excludepatterns=(), execution_timeout=30, execution_in_temp=False, execution_allow_errors=False, execution_raise_on_error=True, execution_show_tb=False, merge_streams=True, render_plugin='default', remove_code_source=False, remove_code_outputs=False, code_prompt_show='Show code cell {type}', code_prompt_hide='Hide code cell {type}', number_source_lines=False, output_stderr='show', render_text_lexer='myst-ansi', render_error_lexer='ipythontb', render_image_options={}, render_figure_options={}, render_markdown_format='commonmark', output_folder='build', append_css=True, metadata_to_fm=False)
Using jupyter-cache at: /home/docs/checkouts/readthedocs.org/user_builds/njab/checkouts/latest/_readthedocs/.jupyter_cache

...

writing output... [  5%] README
Traceback (most recent call last):
# repeated until error

File "/home/docs/checkouts/readthedocs.org/user_builds/njab/envs/latest/lib/python3.10/site-packages/pydata_sphinx_theme/translator.py", line 29, in starttag
  return super().starttag(*args, **kwargs)
File "/home/docs/checkouts/readthedocs.org/user_builds/njab/envs/latest/lib/python3.10/site-packages/sphinx_new_tab_link/__init__.py", line 23, in starttag
  return super(self.__class__, self).starttag(
  File "/home/docs/checkouts/readthedocs.org/user_builds/njab/envs/latest/lib/python3.10/site-packages/pydata_sphinx_theme/translator.py", line 27, in starttag
    if kwargs.get("ROLE") == "heading" and "ARIA-LEVEL" not in kwargs:
RecursionError: maximum recursion depth exceeded while calling a Python object

Recursion error:
maximum recursion depth exceeded while calling a Python object

This can happen with very large or deeply nested source files. You can carefully increase the default Python recursion limit of 1000 in conf.py with e.g.:
    import sys; sys.setrecursionlimit(1500)

Do you have an idea where this error might come from?

ftnext commented 4 months ago

@enryH Thank you very much for your comment and detailed error report.

Do you have an idea where this error might come from?

I think I implemented infinite recursion bug at v0.2.2 https://github.com/ftnext/sphinx-new-tab-link/commit/68531d4e966c1f14cbc3631c549fc605f4dfd4e1. Sorry for inconvenience. I think v0.2.1 will work, so please try.

ftnext commented 4 months ago

@enryH I've fixed this bug and released v0.2.3.

This bug caused by a combination of pydata-sphinx-theme and sphinx-new-tab-link (0.2.2). (sphinx-book-theme depends on pydata-sphinx-theme) pydata-sphinx-theme is implemented to inherit Translator dynamically, and I didn't expect that sphinx-new-tab-link (0.2.2) is used with dynamically inherited Translator so infinite recursion happened.

Thank you very much for your detailed bug report. It helped me to fix it.

enryH commented 3 months ago

Thanks for attending the issue:)