diff options
author | Georg Brandl <georg@python.org> | 2008-11-19 18:08:51 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-11-19 18:08:51 +0100 |
commit | 390e6487ea3e2dbb38b2be6f8e6f9795e2e311cb (patch) | |
tree | 1e61eac022d97920883cd256ab76c9d27d113b56 /sphinx/ext/pngmath.py | |
parent | 7376a916ce8e3b4b6a89f388c6c2587b809841d5 (diff) | |
download | sphinx-git-390e6487ea3e2dbb38b2be6f8e6f9795e2e311cb.tar.gz |
In pngmath, don't call latex again if an image with the given SHA sum already
exists.
Diffstat (limited to 'sphinx/ext/pngmath.py')
-rw-r--r-- | sphinx/ext/pngmath.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index 08fb93892..77d08eef1 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -78,6 +78,8 @@ def render_math(self, math): shasum = "%s.png" % sha(math).hexdigest() relfn = posixpath.join(self.builder.imgpath, 'math', shasum) outfn = path.join(self.builder.outdir, '_images', 'math', shasum) + if path.isfile(outfn): + return relfn, self.builder.env._pngmath_depth.get(shasum, None) latex = DOC_HEAD + self.builder.config.pngmath_latex_preamble latex += (use_preview and DOC_BODY_PREVIEW or DOC_BODY) % math @@ -156,10 +158,15 @@ def render_math(self, math): m = depth_re.match(line) if m: depth = int(m.group(1)) + self.builder.env._pngmath_depth[shasum] = depth break return relfn, depth +def ensure_depthcache(app, env): + if not hasattr(env, '_pngmath_depth'): + env._pngmath_depth = {} + def cleanup_tempdir(app, exc): if exc: return @@ -200,4 +207,5 @@ def setup(app): app.add_config_value('pngmath_use_preview', False, False) app.add_config_value('pngmath_dvipng_args', ['-gamma 1.5', '-D 110'], False) app.add_config_value('pngmath_latex_preamble', '', False) + app.connect('env-updated', ensure_depthcache) app.connect('build-finished', cleanup_tempdir) |