Skip to content

Commit

Permalink
Remove old sphinx compatibility code (#985)
Browse files Browse the repository at this point in the history
This code was for Sphinx < 1.6, and the minimum is now 1.8.3, so this
should have been dropped in #513.
  • Loading branch information
QuLogic authored Aug 6, 2022
1 parent 0bc8e00 commit 4072df4
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 177 deletions.
4 changes: 2 additions & 2 deletions sphinx_gallery/backreferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import warnings

from sphinx.errors import ExtensionError
import sphinx.util

from . import sphinx_compatibility
from .scrapers import _find_image_ext
from .utils import _replace_md5
from .directives import THUMBNAIL_PARENT_DIV, THUMBNAIL_PARENT_DIV_CLOSE
Expand Down Expand Up @@ -322,7 +322,7 @@ def _write_backreferences(backrefs, seen_backrefs, gallery_conf,

def _finalize_backreferences(seen_backrefs, gallery_conf):
"""Replace backref files only if necessary."""
logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')
if gallery_conf['backreferences_dir'] is None:
return

Expand Down
7 changes: 4 additions & 3 deletions sphinx_gallery/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
from urllib.parse import quote

from sphinx.errors import ConfigError
import sphinx.util

from .utils import replace_py_ipynb
from . import sphinx_compatibility, glr_path_static
from . import glr_path_static


logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')


def gen_binder_url(fpath, binder_conf, gallery_conf):
Expand Down Expand Up @@ -204,7 +205,7 @@ def _copy_binder_notebooks(app):
if not isinstance(gallery_dirs, (list, tuple)):
gallery_dirs = [gallery_dirs]

iterator = sphinx_compatibility.status_iterator(
iterator = sphinx.util.status_iterator(
gallery_dirs, 'copying binder notebooks...', length=len(gallery_dirs))

for i_folder in iterator:
Expand Down
7 changes: 3 additions & 4 deletions sphinx_gallery/docs_resolv.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@

from sphinx.errors import ExtensionError
from sphinx.search import js_index
import sphinx.util

from . import sphinx_compatibility


logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')


def _get_data(url):
Expand Down Expand Up @@ -345,7 +344,7 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
flat = [[dirpath, filename]
for dirpath, _, filenames in os.walk(html_gallery_dir)
for filename in filenames]
iterator = sphinx_compatibility.status_iterator(
iterator = sphinx.util.status_iterator(
flat, 'embedding documentation hyperlinks for %s... ' % gallery_dir,
color='fuchsia', length=len(flat),
stringify_func=lambda x: os.path.basename(x[1]))
Expand Down
7 changes: 3 additions & 4 deletions sphinx_gallery/gen_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
from xml.sax.saxutils import quoteattr, escape

from sphinx.errors import ConfigError, ExtensionError
import sphinx.util
from sphinx.util.console import red
from . import sphinx_compatibility, glr_path_static, __version__ as _sg_version
from . import glr_path_static, __version__ as _sg_version
from .utils import _replace_md5, _has_optipng, _has_pypandoc
from .backreferences import _finalize_backreferences
from .gen_rst import (generate_dir_rst, SPHX_GLR_SIG, _get_memory_base,
Expand Down Expand Up @@ -103,7 +104,7 @@ def __call__(self, gallery_conf, script_vars):
'prefer_full_module': [],
}

logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')


def _bool_eval(x):
Expand Down Expand Up @@ -903,8 +904,6 @@ def default_getter(conf):

def setup(app):
"""Setup Sphinx-Gallery sphinx extension"""
sphinx_compatibility._app = app

app.add_config_value('sphinx_gallery_conf', DEFAULT_GALLERY_CONF, 'html')
for key in ['plot_gallery', 'abort_on_example_error']:
app.add_config_value(key, get_default_config_value(key), 'html')
Expand Down
6 changes: 3 additions & 3 deletions sphinx_gallery/gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
import codeop

from sphinx.errors import ExtensionError
import sphinx.util

from .scrapers import (save_figures, ImagePathIterator, clean_modules,
_find_image_ext)
from .utils import (replace_py_ipynb, scale_image, get_md5sum, _replace_md5,
optipng)
from . import glr_path_static
from . import sphinx_compatibility
from .backreferences import (_write_backreferences, _thumbnail_div,
identify_names)
from .downloads import CODE_DOWNLOAD
Expand All @@ -51,7 +51,7 @@
from .notebook import jupyter_notebook, save_notebook
from .binder import check_binder_conf, gen_binder_rst

logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')


###############################################################################
Expand Down Expand Up @@ -437,7 +437,7 @@ def generate_dir_rst(
costs = []
subsection_toctree_filenames = []
build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])
iterator = sphinx_compatibility.status_iterator(
iterator = sphinx.util.status_iterator(
sorted_listdir,
'generating gallery for %s... ' % build_target_dir,
length=len(sorted_listdir))
Expand Down
4 changes: 2 additions & 2 deletions sphinx_gallery/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import textwrap

from sphinx.errors import ExtensionError
import sphinx.util

from . import sphinx_compatibility
from .py_source_parser import split_code_and_text_blocks
from .utils import replace_py_ipynb

logger = sphinx_compatibility.getLogger('sphinx-gallery')
logger = sphinx.util.logging.getLogger('sphinx-gallery')


def jupyter_notebook_skeleton():
Expand Down
2 changes: 1 addition & 1 deletion sphinx_gallery/py_source_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from textwrap import dedent

from sphinx.errors import ExtensionError
from .sphinx_compatibility import getLogger
from sphinx.util.logging import getLogger

logger = getLogger('sphinx-gallery')

Expand Down
71 changes: 0 additions & 71 deletions sphinx_gallery/sphinx_compatibility.py

This file was deleted.

10 changes: 2 additions & 8 deletions sphinx_gallery/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sphinx.errors import ExtensionError
from sphinx.util.docutils import docutils_namespace
from sphinx_gallery import (docs_resolv, gen_gallery, gen_rst, utils,
sphinx_compatibility, py_source_parser)
py_source_parser)
from sphinx_gallery.scrapers import _import_matplotlib
from sphinx_gallery.utils import _get_image

Expand Down Expand Up @@ -69,12 +69,7 @@ def gallery_conf(tmpdir):

@pytest.fixture
def fakesphinxapp():
orig_app = sphinx_compatibility._app
sphinx_compatibility._app = app = FakeSphinxApp()
try:
yield app
finally:
sphinx_compatibility._app = orig_app
yield FakeSphinxApp()


@pytest.fixture
Expand Down Expand Up @@ -198,7 +193,6 @@ def create_sphinx_app_context(self):
with docutils_namespace():
app = Sphinx(self.srcdir, self.confdir, self.outdir,
self.doctreedir, self.buildername, **self.kwargs)
sphinx_compatibility._app = app
yield app

def build_sphinx_app(self, *args, **kwargs):
Expand Down
77 changes: 0 additions & 77 deletions sphinx_gallery/tests/test_sphinx_compatibility.py

This file was deleted.

5 changes: 3 additions & 2 deletions sphinx_gallery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
from shutil import move, copyfile
import subprocess

from . import sphinx_compatibility
from sphinx.errors import ExtensionError
import sphinx.util

logger = sphinx_compatibility.getLogger('sphinx-gallery')

logger = sphinx.util.logging.getLogger('sphinx-gallery')


def _get_image():
Expand Down

0 comments on commit 4072df4

Please sign in to comment.