From 9e753564818b8c38955e724ba3a46dbd0fe969c2 Mon Sep 17 00:00:00 2001 From: weerdy15 <77104725+ItsAleph@users.noreply.github.com> Date: Wed, 14 Sep 2022 18:15:29 +0300 Subject: [PATCH] fix: Only add external version warning nodes on documents (#114) Co-authored-by: Santos Gallegos --- readthedocs_ext/external_version_warning.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/readthedocs_ext/external_version_warning.py b/readthedocs_ext/external_version_warning.py index d13e4bc..1e808c4 100644 --- a/readthedocs_ext/external_version_warning.py +++ b/readthedocs_ext/external_version_warning.py @@ -16,6 +16,15 @@ def process_external_version_warning_banner(app, doctree, fromdocname): If the version type is external this will show a warning banner at the top of each page of the documentation. """ + # Sphinx itself always emits this with a document node, + # but extensions can also call `resolve_references` with other types + # of nodes, we don't want to inject the banner in those. + # Details: + # - https://github.com/readthedocs/readthedocs-sphinx-ext/issues/113 + # - https://github.com/readthedocs/readthedocs-sphinx-ext/pull/114 + if not isinstance(doctree, nodes.document): + return + is_gitlab = app.config.html_context.get('display_gitlab') name = 'merge request' if is_gitlab else 'pull request'