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 #3212: HTML Builders crashes with docutils-0.13 #3217

Merged
merged 1 commit into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ env:
- PYTHONFAULTHANDLER=x
- PYTHONWARNINGS=all
matrix:
- DOCUTILS=0.11
- DOCUTILS=0.12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this PR, I removed docutils-0.11 from test matrix to prevent to increase test time.
@shimizukawa what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to me.
IMO, it is sufficient to keep only the last two versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

- DOCUTILS=0.13.1
addons:
apt:
packages:
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bugs fixed
* #3198: AttributeError is raised when toctree has 'self'
* #3211: Remove untranslated sphinx locale catalogs (it was covered by
untranslated it_IT)
* #3212: HTML Builders crashes with docutils-0.13


Release 1.5 (released Dec 5, 2016)
Expand Down
13 changes: 12 additions & 1 deletion sphinx/writers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import warnings

from six import string_types
import docutils
from docutils import nodes
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator

Expand Down Expand Up @@ -500,7 +501,7 @@ def visit_image(self, node):
self.builder.images[olduri])

uri = node['uri']
if uri.lower().endswith('svg') or uri.lower().endswith('svgz'):
if uri.lower().endswith(('svg', 'svgz')):
atts = {'src': uri}
if 'width' in node:
atts['width'] = node['width']
Expand Down Expand Up @@ -532,6 +533,16 @@ def visit_image(self, node):
node['height'] = str(size[1])
BaseTranslator.visit_image(self, node)

# overwritten
def depart_image(self, node):
if docutils.__version__ >= "0.13":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison doesn't always work:

>>> '0.9' >= '0.13'
True

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I post a new PR for this: #3225.

# since docutils-0.13, HTMLWriter does not push context data on visit_image()
if node['uri'].lower().endswith(('svg', 'svgz')):
self.body.append(self.context.pop())
else:
# docutils-0.12 or below, HTML Writer always push context data on visit_image()
self.body.append(self.context.pop())

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
Expand Down