Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5221429

Browse files
committed
Improve documentation re-build speed.
svn path=/trunk/matplotlib/; revision=7516
1 parent 65ebe49 commit 5221429

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

doc/sphinxext/gen_gallery.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
multiimage = re.compile('(.*)_\d\d')
2020

21+
def out_of_date(original, derived):
22+
return (not os.path.exists(derived) or
23+
os.stat(derived).st_mtime < os.stat(original).st_mtime)
24+
2125
def gen_gallery(app, doctree):
2226
if app.builder.name != 'html':
2327
return
@@ -58,10 +62,10 @@ def gen_gallery(app, doctree):
5862

5963
# Create thumbnails based on images in tmpdir, and place
6064
# them within the build tree
61-
image.thumbnail(
62-
str(os.path.join(origdir, filename)),
63-
str(os.path.join(thumbdir, filename)),
64-
scale=0.3)
65+
orig_path = str(os.path.join(origdir, filename))
66+
thumb_path = str(os.path.join(thumbdir, filename))
67+
if out_of_date(orig_path, thumb_path):
68+
image.thumbnail(orig_path, thumb_path, scale=0.3)
6569

6670
m = multiimage.match(basename)
6771
if m is None:

doc/sphinxext/gen_rst.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ def generate_example_rst(app):
113113

114114
fhsubdirIndex.write(' %s\n'%rstfile)
115115

116-
if (not out_of_date(fullpath, outputfile) and
117-
not out_of_date(fullpath, outrstfile)):
116+
if not out_of_date(fullpath, outrstfile):
118117
continue
119118

120119
fh = file(outrstfile, 'w')

0 commit comments

Comments
 (0)