Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only add external version warning nodes on documents #114

Merged
merged 5 commits into from
Sep 14, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions readthedocs_ext/external_version_warning.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from docutils import nodes
from sphinx import addnodes
elenakrittik marked this conversation as resolved.
Show resolved Hide resolved

try:
# Available from Sphinx 1.6
Expand All @@ -16,6 +17,16 @@ 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.
"""
# For unknown reason Sphinx emits this not only for
# actual documents, but also, e.g., docutils.nodes.bullet_list
# We don't want this warning to appear in random places,
# thus we return here if the doctree doesnt represent a document
elenakrittik marked this conversation as resolved.
Show resolved Hide resolved
# Details:
# - https://github.com/readthedocs/readthedocs-sphinx-ext/issues/113
# - https://github.com/readthedocs/readthedocs-sphinx-ext/pull/114
if not isinstance(doctree, addnodes.document):
elenakrittik marked this conversation as resolved.
Show resolved Hide resolved
return
elenakrittik marked this conversation as resolved.
Show resolved Hide resolved

is_gitlab = app.config.html_context.get('display_gitlab')
name = 'merge request' if is_gitlab else 'pull request'

Expand Down