From 42993157e0862f02e775c13f5f4579786e0cc7fe Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Tue, 7 Apr 2020 00:47:56 +0200 Subject: [PATCH 1/6] Add tests for various sphinx versions --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index a1cbe42..277e51f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,11 @@ env: - SPHINX_VERSION=1.7.* - SPHINX_VERSION=1.8.* - SPHINX_VERSION=2.0.* + - SPHINX_VERSION=2.1.* + - SPHINX_VERSION=2.2.* + - SPHINX_VERSION=2.3.* + - SPHINX_VERSION=2.4.* + - SPHINX_VERSION=3.0.* - SPHINX_VERSION="" matrix: exclude: From 98ed16457abb296481084143355b38adba76d1cf Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Tue, 7 Apr 2020 11:21:09 +0200 Subject: [PATCH 2/6] Explicitly state jobs --- .travis.yml | 56 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 277e51f..fa3a442 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,51 @@ language: python python: - "2.7" - - "3.6" - "3.7" + - "3.8" # 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=2.1.* - - SPHINX_VERSION=2.2.* - - SPHINX_VERSION=2.3.* - - SPHINX_VERSION=2.4.* - - SPHINX_VERSION=3.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=1.9.* + - 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=1.9.* + - python: "2.7" + env: SPHINX_VERSION="" addons: apt: packages: From 5e823b5575d6a46c9194150dcae190bece4df51a Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Tue, 7 Apr 2020 11:22:06 +0200 Subject: [PATCH 3/6] remove python from global settings --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa3a442..e3ca912 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: python -python: - - "2.7" - - "3.7" - - "3.8" + # necessary for python 3.7, see https://github.com/travis-ci/travis-ci/issues/9815 dist: xenial From 2db79397b5576ba9cca96384ac7706f1fb074579 Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Tue, 7 Apr 2020 11:39:58 +0200 Subject: [PATCH 4/6] remove tests for sphinx 1.9 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3ca912..144a067 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,6 @@ jobs: env: SPHINX_VERSION=1.7.* - python: "3.7" env: SPHINX_VERSION=1.8.* - - python: "3.7" - env: SPHINX_VERSION=1.9.* - python: "3.7" env: SPHINX_VERSION=2.0.* - python: "3.7" @@ -39,8 +37,6 @@ jobs: env: SPHINX_VERSION=1.7.* - python: "2.7" env: SPHINX_VERSION=1.8.* - - python: "2.7" - env: SPHINX_VERSION=1.9.* - python: "2.7" env: SPHINX_VERSION="" addons: From ed5aa3a49c19a219bb9577cac054c7e7deb31b4a Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Wed, 8 Apr 2020 10:59:54 +0200 Subject: [PATCH 5/6] add test for triggered warning --- tests/test_sphinx_nbexamples.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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): From 87111fc6eb267b5567e03314fcdd93abdb3f1842 Mon Sep 17 00:00:00 2001 From: "Philipp S. Sommer" Date: Wed, 8 Apr 2020 11:01:50 +0200 Subject: [PATCH 6/6] use app.add_css_file for sphinx >= 3.0 see https://github.com/Chilipp/sphinx-nbexamples/issues/14 --- sphinx_nbexamples/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)