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

Skip to content

Commit b0b5ec7

Browse files
committed
Merge remote-tracking branch 'upstream/v1.2.x'
Conflicts: doc/conf.py
2 parents 02ffdec + e5d9960 commit b0b5ec7

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

doc/conf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
# If your extensions are in another directory, add it here. If the directory
1919
# is relative to the documentation root, use os.path.abspath to make it
2020
# absolute, like shown here.
21-
sys.path.insert(0, os.path.abspath('sphinxext'))
21+
sys.path.append(os.path.abspath('.'))
2222

2323
# General configuration
2424
# ---------------------
2525

2626
# Add any Sphinx extension module names here, as strings. They can be extensions
2727
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
28-
extensions = ['matplotlib.sphinxext.mathmpl', 'math_symbol_table',
28+
extensions = ['matplotlib.sphinxext.mathmpl', 'sphinxext.math_symbol_table',
2929
'sphinx.ext.autodoc', 'matplotlib.sphinxext.only_directives',
3030
'sphinx.ext.doctest', 'sphinx.ext.autosummary',
3131
'matplotlib.sphinxext.plot_directive', 'sphinx.ext.inheritance_diagram',
32-
'gen_gallery', 'gen_rst',
33-
'matplotlib.sphinxext.ipython_console_highlighting', 'github',
32+
'sphinxext.gen_gallery', 'sphinxext.gen_rst',
33+
'matplotlib.sphinxext.ipython_console_highlighting',
34+
'sphinxext.github',
3435
'numpydoc']
3536

3637

doc/sphinxext/__init__.py

Whitespace-only changes.

doc/sphinxext/gen_rst.py

Lines 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)