-
Notifications
You must be signed in to change notification settings - Fork 26
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
dev-python/sphinx: Backport fixes for compatibility with docutils 0.13 #452
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# git diff 3adc236114^..7dabcdee91 -- sphinx/writers/html.py | ||
# and parts of edfdd3ec78 as well in order to make these apply | ||
|
||
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py | ||
index 7b666aa5..d6bdd833 100644 | ||
--- a/sphinx/writers/html.py | ||
+++ b/sphinx/writers/html.py | ||
@@ -458,9 +458,9 @@ class HTMLTranslator(BaseTranslator): | ||
node['uri'] = posixpath.join(self.builder.imgpath, | ||
self.builder.images[olduri]) | ||
|
||
- if node['uri'].lower().endswith('svg') or \ | ||
- node['uri'].lower().endswith('svgz'): | ||
- atts = {'src': node['uri']} | ||
+ uri = node['uri'] | ||
+ if uri.lower().endswith(('svg', 'svgz')): | ||
+ atts = {'src': uri} | ||
if 'width' in node: | ||
atts['width'] = node['width'] | ||
if 'height' in node: | ||
@@ -492,6 +492,13 @@ class HTMLTranslator(BaseTranslator): | ||
node['height'] = str(size[1]) | ||
BaseTranslator.visit_image(self, node) | ||
|
||
+ # overwritten | ||
+ def depart_image(self, node): | ||
+ if node['uri'].lower().endswith(('svg', 'svgz')): | ||
+ self.body.append(self.context.pop()) | ||
+ else: | ||
+ BaseTranslator.depart_image(self, node) | ||
+ | ||
def visit_toctree(self, node): | ||
# this only happens when formatting a toc from env.tocs -- in this | ||
# case we don't want to include the subtree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You depart from upstream fix by not checking for the docutils version. Is this safe to use with docutils-0.12 which is in stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream reverted that version check in sphinx-doc/sphinx@b98e2e3. The important aspect is to keep things balanced: if
visit_image
does call the base version without modifying the stack itself, then so doesdepart_image
. Ifvisit_image
returns without calling the base version, and does push something on the stack, thendepart_image
doesn't call the base version either, and makes use of the item on the stack. The common check for file extension achieves that these code paths will always match one another.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I hadn't inspected that commit. So long as it doesn't lock use in docutils-0.13 over 0.12 I see no reason not to merge.