From 23d578da81b85e202f2671de1659065d4c17c192 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 16 Oct 2008 19:29:35 +0000 Subject: [PATCH] Create pygments.css before copying user-supplied static files. --- sphinx/builder.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sphinx/builder.py b/sphinx/builder.py index f610c2889..e464a546a 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -644,6 +644,18 @@ class StandaloneHTMLBuilder(Builder): # copy static files self.info(bold('copying static files... '), nonl=True) ensuredir(path.join(self.outdir, '_static')) + # first, create pygments style file + f = open(path.join(self.outdir, '_static', 'pygments.css'), 'w') + f.write(PygmentsBridge('html', self.config.pygments_style).get_stylesheet()) + f.close() + # then, copy translations JavaScript file + if self.config.language is not None: + jsfile = path.join(path.dirname(__file__), 'locale', self.config.language, + 'LC_MESSAGES', 'sphinx.js') + if path.isfile(jsfile): + shutil.copyfile(jsfile, path.join(self.outdir, '_static', + 'translations.js')) + # then, copy over all user-supplied static files staticdirnames = [path.join(path.dirname(__file__), 'static')] + \ [path.join(self.confdir, spath) for spath in self.config.html_static_path] @@ -661,22 +673,11 @@ class StandaloneHTMLBuilder(Builder): if path.exists(targetname): shutil.rmtree(targetname) shutil.copytree(fullname, targetname) - # add translations JavaScript file - if self.config.language is not None: - jsfile = path.join(path.dirname(__file__), 'locale', self.config.language, - 'LC_MESSAGES', 'sphinx.js') - if path.isfile(jsfile): - shutil.copyfile(jsfile, path.join(self.outdir, '_static', - 'translations.js')) - # copy logo file (handled differently) + # last, copy logo file (handled differently) if self.config.html_logo: logobase = path.basename(self.config.html_logo) shutil.copyfile(path.join(self.confdir, self.config.html_logo), path.join(self.outdir, '_static', logobase)) - # add pygments style file - f = open(path.join(self.outdir, '_static', 'pygments.css'), 'w') - f.write(PygmentsBridge('html', self.config.pygments_style).get_stylesheet()) - f.close() self.info('done') # dump the search index