File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change 4545import pandocfilters
4646import pypandoc
4747import plotly .io as pio
48+ from pathlib import Path
4849pio .renderers .default = 'sphinx_gallery'
4950
5051
@@ -140,22 +141,17 @@ def reset_seeds(gallery_conf, fname):
140141 sphinx_gallery_conf ['ignore_pattern' ] = r'/(?!' + re .escape (os .getenv ('GALLERY_PATTERN' )) + r')[^/]+$'
141142
142143for i in range (len (sphinx_gallery_conf ['examples_dirs' ])):
143- gallery_dir = sphinx_gallery_conf ['gallery_dirs' ][i ]
144- source_dir = sphinx_gallery_conf ['examples_dirs' ][i ]
145- # Create gallery dirs if it doesn't exist
146- try :
147- os .mkdir (gallery_dir )
148- except OSError :
149- pass
144+ gallery_dir = Path (sphinx_gallery_conf ["gallery_dirs" ][i ])
145+ source_dir = Path (sphinx_gallery_conf ["examples_dirs" ][i ])
150146
151147 # Copy rst files from source dir to gallery dir
152- for f in glob .glob (os .path .join (source_dir , '*.rst' )):
153- distutils .file_util .copy_file (f , gallery_dir , update = True )
154-
148+ for f in source_dir .rglob ("*.rst" ):
149+ f_dir = Path (f ).parent
150+ gallery_subdir_path = gallery_dir / f_dir .relative_to (source_dir )
151+ gallery_subdir_path .mkdir (parents = True , exist_ok = True )
152+ distutils .file_util .copy_file (f , gallery_subdir_path , update = True )
155153
156154# Add any paths that contain templates here, relative to this directory.
157-
158-
159155templates_path = ['_templates' ]
160156
161157# The suffix(es) of source filenames.
You can’t perform that action at this time.
0 commit comments