33"""
44import os , glob
55
6- import matplotlib .cbook as cbook
7-
86import os
97import re
108import sys
@@ -75,8 +73,10 @@ def out_of_date(original, derived):
7573
7674 subdirIndexFile = os .path .join (subdir , 'index.rst' )
7775 fhsubdirIndex = file (subdirIndexFile , 'w' )
78- fhindex .write (' %s\n ' % subdirIndexFile )
79-
76+ fhindex .write (' %s\n \n ' % subdirIndexFile )
77+ #thumbdir = '../_static/plot_directive/mpl_examples/%s/thumbnails/'%subdir
78+ #for thumbname in glob.glob(os.path.join(thumbdir,'*.png')):
79+ # fhindex.write(' %s\n'%thumbname)
8080
8181 fhsubdirIndex .write ("""\
8282 .. _%s-examples-index:
@@ -101,15 +101,23 @@ def out_of_date(original, derived):
101101
102102 data = datad [subdir ]
103103 data .sort ()
104- for fullname , fname , contents in data :
105- static_file = os .path .join (static_dir , fname )
104+
105+ #parts = os.path.split(static_dir)
106+ #thumb_dir = ('../'*(len(parts)-1)) + os.path.join(static_dir, 'thumbnails')
107+
108+ for fullpath , fname , contents in data :
106109 basename , ext = os .path .splitext (fname )
110+ static_file = os .path .join (static_dir , fname )
111+ #thumbfile = os.path.join(thumb_dir, '%s.png'%basename)
112+ #print ' static_dir=%s, basename=%s, fullpath=%s, fname=%s, thumb_dir=%s, thumbfile=%s'%(static_dir, basename, fullpath, fname, thumb_dir, thumbfile)
113+
107114 rstfile = '%s.rst' % basename
108115 outfile = os .path .join (subdir , rstfile )
116+
109117 fhsubdirIndex .write (' %s\n ' % rstfile )
110118
111- if (not out_of_date (fullname , static_file ) and
112- not out_of_date (fullname , outfile )):
119+ if (not out_of_date (fullpath , static_file ) and
120+ not out_of_date (fullpath , outfile )):
113121 continue
114122
115123 print ' %s' % fname
@@ -121,6 +129,8 @@ def out_of_date(original, derived):
121129 fh = file (outfile , 'w' )
122130 fh .write ('.. _%s-%s:\n \n ' % (subdir , basename ))
123131 title = '%s example code: %s' % (subdir , fname )
132+ #title = '<img src=%s> %s example code: %s'%(thumbfile, subdir, fname)
133+
124134
125135 fh .write (title + '\n ' )
126136 fh .write ('=' * len (title ) + '\n \n ' )
@@ -131,7 +141,7 @@ def out_of_date(original, derived):
131141 not noplot_regex .search (contents ))
132142
133143 if do_plot :
134- fh .write ("\n \n .. plot:: %s\n \n ::\n \n " % fullname [3 :])
144+ fh .write ("\n \n .. plot:: %s\n \n ::\n \n " % fullpath [3 :])
135145 else :
136146 linkname = os .path .join ('..' , '..' , '_static' , 'examples' , subdir , fname )
137147 fh .write ("[`source code <%s>`_]\n \n ::\n \n " % linkname )
0 commit comments