From f3860b1af9ab91872b7d83cbb2834b8af4b976e2 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 10 Jun 2009 08:45:22 +0200 Subject: [PATCH 1/4] Update URL for html2rest. --- doc/intro.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/intro.rst b/doc/intro.rst index 7b8f86511..abf34a9a0 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -23,8 +23,8 @@ This section is intended to collect helpful hints for those wanting to migrate to reStructuredText/Sphinx from other documentation systems. * Gerard Flanagan has written a script to convert pure HTML to reST; it can be - found at `Launchpad - `_. + found at `BitBucket + `_. * For converting the old Python docs to Sphinx, a converter was written which can be found at `the Python SVN repository From 0f0dd77ccf0e473455db7d0ae0805ee29230f607 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 15 Jun 2009 17:25:30 +0200 Subject: [PATCH 2/4] Warn about uncopyable image and download files, dont error out. --- sphinx/builders/html.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index b7c63fc09..4894f8e78 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -494,8 +494,12 @@ class StandaloneHTMLBuilder(Builder): ensuredir(path.join(self.outdir, '_images')) for src, dest in self.images.iteritems(): self.info(' '+src, nonl=1) - copyfile(path.join(self.srcdir, src), - path.join(self.outdir, '_images', dest)) + try: + copyfile(path.join(self.srcdir, src), + path.join(self.outdir, '_images', dest)) + except Exception, err: + self.warn('cannot copy image file %s: %s' % + (path.join(self.srcdir, src), err)) self.info() # copy downloadable files @@ -504,8 +508,12 @@ class StandaloneHTMLBuilder(Builder): ensuredir(path.join(self.outdir, '_downloads')) for src, (_, dest) in self.env.dlfiles.iteritems(): self.info(' '+src, nonl=1) - copyfile(path.join(self.srcdir, src), - path.join(self.outdir, '_downloads', dest)) + try: + copyfile(path.join(self.srcdir, src), + path.join(self.outdir, '_downloads', dest)) + except Exception, err: + self.warn('cannot copy downloadable file %s: %s' % + (path.join(self.srcdir, src), err)) self.info() # copy static files From f45aeb4b052c0cb1403d6e9e653f992e38d7b34d Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 15 Jun 2009 17:30:48 +0200 Subject: [PATCH 3/4] Improve warning message. --- sphinx/builders/html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 4894f8e78..c64f4ee51 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -498,7 +498,7 @@ class StandaloneHTMLBuilder(Builder): copyfile(path.join(self.srcdir, src), path.join(self.outdir, '_images', dest)) except Exception, err: - self.warn('cannot copy image file %s: %s' % + self.warn('cannot copy image file %r: %s' % (path.join(self.srcdir, src), err)) self.info() @@ -512,7 +512,7 @@ class StandaloneHTMLBuilder(Builder): copyfile(path.join(self.srcdir, src), path.join(self.outdir, '_downloads', dest)) except Exception, err: - self.warn('cannot copy downloadable file %s: %s' % + self.warn('cannot copy downloadable file %r: %s' % (path.join(self.srcdir, src), err)) self.info() From 5e439cbbb5f791d39ad27f55ea594ad0ef935966 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 15 Jun 2009 17:31:29 +0200 Subject: [PATCH 4/4] #196: Add a warning if an extension module doesn't have a ``setup()`` function. --- CHANGES | 3 +++ sphinx/application.py | 5 ++++- tests/test_application.py | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 72bef47bf..069b3ce53 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.2 (in development) ============================== +* #196: Add a warning if an extension module doesn't have a + ``setup()`` function. + * #158: Allow '..' in template names, and absolute template paths; Jinja 2 by default disables both. diff --git a/sphinx/application.py b/sphinx/application.py index 62b0c53d6..7e926e572 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -167,7 +167,10 @@ class Sphinx(object): except ImportError, err: raise ExtensionError('Could not import extension %s' % extension, err) - if hasattr(mod, 'setup'): + if not hasattr(mod, 'setup'): + self.warn('extension %r has no setup() function; is it really ' + 'a Sphinx extension module?' % extension) + else: mod.setup(self) self._extensions[extension] = mod diff --git a/tests/test_application.py b/tests/test_application.py index 6425e2753..a113c2359 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -57,3 +57,13 @@ def test_output(): assert app._warncount == old_count + 1 finally: app.cleanup() + + +def test_extensions(): + status, warnings = StringIO(), StringIO() + app = TestApp(status=status, warning=warnings) + try: + app.setup_extension('shutil') + assert warnings.getvalue().startswith("WARNING: extension 'shutil'") + finally: + app.cleanup()