diff --git a/.travis.yml b/.travis.yml index a1cbe42..144a067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,44 @@ language: python -python: - - "2.7" - - "3.6" - - "3.7" + # necessary for python 3.7, see https://github.com/travis-ci/travis-ci/issues/9815 dist: xenial -sudo: yes -env: - - SPHINX_VERSION=1.5.* - - SPHINX_VERSION=1.6.* - - SPHINX_VERSION=1.7.* - - SPHINX_VERSION=1.8.* - - SPHINX_VERSION=2.0.* - - SPHINX_VERSION="" -matrix: - exclude: - - python: "2.7" + +jobs: + include: + - python: "3.8" + env: SPHINX_VERSION=2.4.* + - python: "3.8" + env: SPHINX_VERSION=3.0.* + - python: "3.8" + env: SPHINX_VERSION="" + - python: "3.7" + env: SPHINX_VERSION=1.7.* + - python: "3.7" + env: SPHINX_VERSION=1.8.* + - python: "3.7" env: SPHINX_VERSION=2.0.* - python: "3.7" - env: SPHINX_VERSION=1.5.* + env: SPHINX_VERSION=2.1.* + - python: "3.7" + env: SPHINX_VERSION=2.2.* + - python: "3.7" + env: SPHINX_VERSION=2.3.* - python: "3.7" + env: SPHINX_VERSION=2.4.* + - python: "3.7" + env: SPHINX_VERSION=3.0.* + - python: "3.7" + env: SPHINX_VERSION="" + - python: "2.7" + env: SPHINX_VERSION=1.5.* + - python: "2.7" env: SPHINX_VERSION=1.6.* + - python: "2.7" + env: SPHINX_VERSION=1.7.* + - python: "2.7" + env: SPHINX_VERSION=1.8.* + - python: "2.7" + env: SPHINX_VERSION="" addons: apt: packages: diff --git a/sphinx_nbexamples/__init__.py b/sphinx_nbexamples/__init__.py index d65a870..0140afe 100644 --- a/sphinx_nbexamples/__init__.py +++ b/sphinx_nbexamples/__init__.py @@ -1162,7 +1162,10 @@ def setup(app): app.add_config_value('example_gallery_config', gallery_config, 'html') - app.add_stylesheet('example_gallery_styles.css') + if int(sphinx.__version__.split('.')[0]) >= 3: + app.add_css_file('example_gallery_styles.css') + else: + app.add_stylesheet('example_gallery_styles.css') app.add_directive('linkgalleries', LinkGalleriesDirective) diff --git a/tests/test_sphinx_nbexamples.py b/tests/test_sphinx_nbexamples.py index 57f257b..b888378 100644 --- a/tests/test_sphinx_nbexamples.py +++ b/tests/test_sphinx_nbexamples.py @@ -48,6 +48,7 @@ def setUp(self): os.rmdir(self.src_dir) self.out_dir = osp.join(self.src_dir, 'build', 'html') shutil.copytree(sphinx_supp, self.src_dir) + self.app = Sphinx( srcdir=self.src_dir, confdir=self.src_dir, outdir=self.out_dir, doctreedir=osp.join(self.src_dir, 'build', 'doctrees'), @@ -219,6 +220,27 @@ def test_bash(self): self.assertIn('hello, world', rst) +class TestWarnings(BaseTest): + + def setUp(self): + pass + + def _setUp(self): + super().setUp() + + @unittest.skipIf(int(sphinx.__version__.split('.')[0]) != 3, + "Test implemented for sphinx 3.0") + @unittest.expectedFailure + def test_stylesheet_warning(self): + """Test whether the app.add_stylesheet() warning is triggered + + See https://github.com/Chilipp/sphinx-nbexamples/issues/14""" + from sphinx.application import RemovedInSphinx40Warning + self.assertWarnsRegex( + RemovedInSphinx40Warning, '.*Please use app.add_css_file', + self._setUp) + + @unittest.skipIf(pathlib is None, 'The pathlib package is required!') class TestLinkGalleries(BaseTest):