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

Skip to content

Commit b47dde5

Browse files
authored
Merge pull request #13420 from tacaswell/doc_backports
Doc backports
2 parents 0e25859 + 5684b7d commit b47dde5

6 files changed

Lines changed: 362 additions & 360 deletions

File tree

doc-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Install the documentation requirements with:
77
# pip install -r doc-requirements.txt
88
#
9-
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3,<1.8
9+
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3
1010
colorspacious
1111
ipython
1212
ipywidgets

doc/conf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# is relative to the documentation root, use os.path.abspath to make it
2323
# absolute, like shown here.
2424
sys.path.append(os.path.abspath('.'))
25+
sys.path.append('.')
2526

2627
# General configuration
2728
# ---------------------
@@ -39,9 +40,9 @@
3940
'IPython.sphinxext.ipython_directive',
4041
'numpydoc', # Needs to be loaded *after* autodoc.
4142
'sphinx_gallery.gen_gallery',
42-
'matplotlib.sphinxext.mathmpl',
4343
'matplotlib.sphinxext.only_directives',
4444
'matplotlib.sphinxext.plot_directive',
45+
'matplotlib.sphinxext.mathmpl',
4546
'sphinxext.custom_roles',
4647
'sphinxext.github',
4748
'sphinxext.math_symbol_table',
@@ -93,7 +94,10 @@ def _check_deps():
9394
autosummary_generate = True
9495

9596
autodoc_docstring_signature = True
96-
autodoc_default_flags = ['members', 'undoc-members']
97+
if sphinx.version_info < (1, 8):
98+
autodoc_default_flags = ['members', 'undoc-members']
99+
else:
100+
autodoc_default_options = {'members': None, 'undoc-members': None}
97101

98102
intersphinx_mapping = {
99103
'python': ('https://docs.python.org/3', None),

doc/sphinxext/github.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
7575
prb = inliner.problematic(rawtext, rawtext, msg)
7676
return [prb], [msg]
7777
app = inliner.document.settings.env.app
78-
#app.info('issue %r' % text)
7978
if 'pull' in name.lower():
8079
category = 'pull'
8180
elif 'issue' in name.lower():
@@ -105,7 +104,6 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
105104
:param content: The directive content for customization.
106105
"""
107106
app = inliner.document.settings.env.app
108-
#app.info('user link %r' % text)
109107
ref = 'https://www.github.com/' + text
110108
node = nodes.reference(rawtext, text, refuri=ref, **options)
111109
return [node], []
@@ -126,7 +124,6 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
126124
:param content: The directive content for customization.
127125
"""
128126
app = inliner.document.settings.env.app
129-
#app.info('user link %r' % text)
130127
try:
131128
base = app.config.github_project_url
132129
if not base:
@@ -146,7 +143,6 @@ def setup(app):
146143
147144
:param app: Sphinx application context.
148145
"""
149-
app.info('Initializing GitHub plugin')
150146
app.add_role('ghissue', ghissue_role)
151147
app.add_role('ghpull', ghissue_role)
152148
app.add_role('ghuser', ghuser_role)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:orphan:
2+
3+
``:math:`` directive renamed to ``:mathmpl:``
4+
`````````````````````````````````````````````
5+
6+
The ``:math:`` rst role provided by `matplotlib.sphinxext.mathmpl` has been
7+
renamed to ``:mathmpl:`` to avoid conflicting with the ``:math:`` role that
8+
Sphinx 1.8 provides by default. (``:mathmpl:`` uses Matplotlib to render math
9+
expressions to images embedded in html, whereas Sphinx uses MathJax.)
10+
11+
When using Sphinx<1.8, both names (``:math:`` and ``:mathmpl:``) remain
12+
available for backcompatibility.

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
3-
43
import six
5-
4+
import hashlib
65
import os
76
import sys
8-
from hashlib import md5
7+
import warnings
98

109
from docutils import nodes
1110
from docutils.parsers.rst import directives
12-
import warnings
11+
import sphinx
1312

1413
from matplotlib import rcParams
1514
from matplotlib.mathtext import MathTextParser
@@ -66,7 +65,7 @@ def latex2png(latex, filename, fontset='cm'):
6665
def latex2html(node, source):
6766
inline = isinstance(node.parent, nodes.TextElement)
6867
latex = node['latex']
69-
name = 'math-%s' % md5(latex.encode()).hexdigest()[-10:]
68+
name = 'math-%s' % hashlib.md5(latex.encode()).hexdigest()[-10:]
7069

7170
destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
7271
if not os.path.exists(destdir):
@@ -115,9 +114,13 @@ def depart_latex_math_latex(self, node):
115114
app.add_node(latex_math,
116115
html=(visit_latex_math_html, depart_latex_math_html),
117116
latex=(visit_latex_math_latex, depart_latex_math_latex))
118-
app.add_role('math', math_role)
119-
app.add_directive('math', math_directive,
117+
app.add_role('mathmpl', math_role)
118+
app.add_directive('mathmpl', math_directive,
120119
True, (0, 0, 0), **options_spec)
120+
if sphinx.version_info < (1, 8):
121+
app.add_role('math', math_role)
122+
app.add_directive('math', math_directive,
123+
True, (0, 0, 0), **options_spec)
121124

122125
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
123126
return metadata

0 commit comments

Comments
 (0)