Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 213df25

Browse files
committed
Merge pull request matplotlib#4233 from jenshnielsen/sphinx_plot_formats
FIX : Fix small option for docs build with sphinx 1.3
2 parents 51576d4 + a312fc9 commit 213df25

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ matrix:
2424
env: BUILD_DOCS=true
2525

2626
install:
27-
- pip install -q --use-mirrors nose python-dateutil $NUMPY pep8 pyparsing pillow sphinx==1.2.3
27+
- pip install -q --use-mirrors nose python-dateutil $NUMPY pep8 pyparsing pillow sphinx!=1.3.0
2828
- sudo apt-get update && sudo apt-get -qq install inkscape libav-tools gdb mencoder
2929
# We use --no-install-recommends to avoid pulling in additional large latex docs that we don't need
3030

doc/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def html(buildername='html'):
4040
check_build()
4141
copy_if_out_of_date('../lib/matplotlib/mpl-data/matplotlibrc', '_static/matplotlibrc')
4242
if small_docs:
43-
options = "-D plot_formats=\"[('png', 80)]\""
43+
options = "-D plot_formats=png:80"
4444
else:
4545
options = ''
4646
if warnings_as_errors:

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@
103103
[(suffix, dpi), suffix, ...]
104104
105105
that determine the file format and the DPI. For entries whose
106-
DPI was omitted, sensible defaults are chosen.
106+
DPI was omitted, sensible defaults are chosen. When passing from
107+
the command line through sphinx_build the list should be passed as
108+
suffix:dpi,suffix:dpi, ....
107109
108110
plot_html_show_formats
109111
Whether to show links to the files in HTML.
@@ -539,10 +541,17 @@ def render_figures(code, code_path, output_dir, output_base, context,
539541
formats = []
540542
plot_formats = config.plot_formats
541543
if isinstance(plot_formats, six.string_types):
542-
plot_formats = eval(plot_formats)
544+
# String Sphinx < 1.3, Split on , to mimic
545+
# Sphinx 1.3 and later. Sphinx 1.3 always
546+
# returns a list.
547+
plot_formats = plot_formats.split(',')
543548
for fmt in plot_formats:
544549
if isinstance(fmt, six.string_types):
545-
formats.append((fmt, default_dpi.get(fmt, 80)))
550+
if ':' in fmt:
551+
suffix,dpi = fmt.split(':')
552+
formats.append((str(suffix), int(dpi)))
553+
else:
554+
formats.append((fmt, default_dpi.get(fmt, 80)))
546555
elif type(fmt) in (tuple, list) and len(fmt)==2:
547556
formats.append((str(fmt[0]), int(fmt[1])))
548557
else:

0 commit comments

Comments
 (0)