Skip to content

Doc backports #13420

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

Merged
merged 5 commits into from
Feb 12, 2019
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 doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Install the documentation requirements with:
# pip install -r doc-requirements.txt
#
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3,<1.8
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3
colorspacious
ipython
ipywidgets
Expand Down
8 changes: 6 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
sys.path.append(os.path.abspath('.'))
sys.path.append('.')

# General configuration
# ---------------------
Expand All @@ -39,9 +40,9 @@
'IPython.sphinxext.ipython_directive',
'numpydoc', # Needs to be loaded *after* autodoc.
'sphinx_gallery.gen_gallery',
'matplotlib.sphinxext.mathmpl',
'matplotlib.sphinxext.only_directives',
'matplotlib.sphinxext.plot_directive',
'matplotlib.sphinxext.mathmpl',
'sphinxext.custom_roles',
'sphinxext.github',
'sphinxext.math_symbol_table',
Expand Down Expand Up @@ -93,7 +94,10 @@ def _check_deps():
autosummary_generate = True

autodoc_docstring_signature = True
autodoc_default_flags = ['members', 'undoc-members']
if sphinx.version_info < (1, 8):
autodoc_default_flags = ['members', 'undoc-members']
else:
autodoc_default_options = {'members': None, 'undoc-members': None}

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
Expand Down
4 changes: 0 additions & 4 deletions doc/sphinxext/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
app = inliner.document.settings.env.app
#app.info('issue %r' % text)
if 'pull' in name.lower():
category = 'pull'
elif 'issue' in name.lower():
Expand Down Expand Up @@ -105,7 +104,6 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#app.info('user link %r' % text)
ref = 'https://www.github.com/' + text
node = nodes.reference(rawtext, text, refuri=ref, **options)
return [node], []
Expand All @@ -126,7 +124,6 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#app.info('user link %r' % text)
try:
base = app.config.github_project_url
if not base:
Expand All @@ -146,7 +143,6 @@ def setup(app):

:param app: Sphinx application context.
"""
app.info('Initializing GitHub plugin')
app.add_role('ghissue', ghissue_role)
app.add_role('ghpull', ghissue_role)
app.add_role('ghuser', ghuser_role)
Expand Down
12 changes: 12 additions & 0 deletions doc/users/next_whats_new/2018-09-15-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:orphan:

``:math:`` directive renamed to ``:mathmpl:``
`````````````````````````````````````````````

The ``:math:`` rst role provided by `matplotlib.sphinxext.mathmpl` has been
renamed to ``:mathmpl:`` to avoid conflicting with the ``:math:`` role that
Sphinx 1.8 provides by default. (``:mathmpl:`` uses Matplotlib to render math
expressions to images embedded in html, whereas Sphinx uses MathJax.)

When using Sphinx<1.8, both names (``:math:`` and ``:mathmpl:``) remain
available for backcompatibility.
17 changes: 10 additions & 7 deletions lib/matplotlib/sphinxext/mathmpl.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import hashlib
import os
import sys
from hashlib import md5
import warnings

from docutils import nodes
from docutils.parsers.rst import directives
import warnings
import sphinx

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

destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
if not os.path.exists(destdir):
Expand Down Expand Up @@ -115,9 +114,13 @@ def depart_latex_math_latex(self, node):
app.add_node(latex_math,
html=(visit_latex_math_html, depart_latex_math_html),
latex=(visit_latex_math_latex, depart_latex_math_latex))
app.add_role('math', math_role)
app.add_directive('math', math_directive,
app.add_role('mathmpl', math_role)
app.add_directive('mathmpl', math_directive,
True, (0, 0, 0), **options_spec)
if sphinx.version_info < (1, 8):
app.add_role('math', math_role)
app.add_directive('math', math_directive,
True, (0, 0, 0), **options_spec)

metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata
Loading