Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 077b26f

Browse filesBrowse files
committed
Merge pull request #1897 from mdboom/doc/encoding_gen_rst
Fix documentation build failure (unicode error in generate_example_rst)
2 parents b9d3422 + 1ed2b1a commit 077b26f
Copy full SHA for 077b26f

File tree

Expand file treeCollapse file tree

3 files changed

+14
-20
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-20
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
# If your extensions are in another directory, add it here. If the directory
1717
# is relative to the documentation root, use os.path.abspath to make it
1818
# absolute, like shown here.
19-
sys.path.append(os.path.abspath('sphinxext'))
19+
sys.path.append(os.path.abspath('.'))
2020

2121
# General configuration
2222
# ---------------------
2323

2424
# Add any Sphinx extension module names here, as strings. They can be extensions
2525
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
26-
extensions = ['matplotlib.sphinxext.mathmpl', 'math_symbol_table',
26+
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table',
2727
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives',
2828
'sphinx.ext.doctest',
2929
'matplotlib.sphinxext.plot_directive', 'sphinx.ext.inheritance_diagram',
30-
'gen_gallery', 'gen_rst',
31-
'matplotlib.sphinxext.ipython_console_highlighting', 'github']
30+
'sphinxext.gen_gallery', 'sphinxext.gen_rst',
31+
'matplotlib.sphinxext.ipython_console_highlighting', 'sphinxext.github']
3232

3333
# Add any paths that contain templates here, relative to this directory.
3434
templates_path = ['_templates']

‎doc/sphinxext/__init__.py

Copy file name to clipboardExpand all lines: doc/sphinxext/__init__.py
Whitespace-only changes.

‎doc/sphinxext/gen_rst.py

Copy file name to clipboardExpand all lines: doc/sphinxext/gen_rst.py
+10-16Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ def generate_example_rst(app):
3838
continue
3939

4040
fullpath = os.path.join(root,fname)
41-
if sys.version_info[0] >= 3:
42-
contents = io.open(fullpath, encoding='utf8').read()
43-
else:
44-
contents = io.open(fullpath).read()
41+
contents = io.open(fullpath, encoding='utf8').read()
4542
# indent
4643
relpath = os.path.split(root)[-1]
4744
datad.setdefault(relpath, []).append((fullpath, fname, contents))
@@ -126,34 +123,31 @@ def generate_example_rst(app):
126123
) and
127124
not noplot_regex.search(contents))
128125
if not do_plot:
129-
fhstatic = open(outputfile, 'w')
126+
fhstatic = io.open(outputfile, 'w', encoding='utf-8')
130127
fhstatic.write(contents)
131128
fhstatic.close()
132129

133130
if not out_of_date(fullpath, outrstfile):
134131
continue
135132

136-
if sys.version_info[0] >= 3:
137-
fh = io.open(outrstfile, 'w', encoding='utf8')
138-
else:
139-
fh = io.open(outrstfile, 'w')
140-
fh.write('.. _%s-%s:\n\n'%(subdir, basename))
133+
fh = io.open(outrstfile, 'w', encoding='utf-8')
134+
fh.write(u'.. _%s-%s:\n\n' % (subdir, basename))
141135
title = '%s example code: %s'%(subdir, fname)
142136
#title = '<img src=%s> %s example code: %s'%(thumbfile, subdir, fname)
143137

144-
fh.write(title + '\n')
145-
fh.write('='*len(title) + '\n\n')
138+
fh.write(title + u'\n')
139+
fh.write(u'=' * len(title) + u'\n\n')
146140

147141
if do_plot:
148-
fh.write("\n\n.. plot:: %s\n\n::\n\n" % fullpath)
142+
fh.write(u"\n\n.. plot:: %s\n\n::\n\n" % fullpath)
149143
else:
150-
fh.write("[`source code <%s>`_]\n\n::\n\n" % fname)
144+
fh.write(u"[`source code <%s>`_]\n\n::\n\n" % fname)
151145

152146
# indent the contents
153-
contents = '\n'.join([' %s'%row.rstrip() for row in contents.split('\n')])
147+
contents = u'\n'.join([u' %s'%row.rstrip() for row in contents.split(u'\n')])
154148
fh.write(contents)
155149

156-
fh.write('\n\nKeywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)')
150+
fh.write(u'\n\nKeywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)')
157151
fh.close()
158152

159153
fhsubdirIndex.close()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.