Skip to content

Reduce amount of unnecessary recompilation done by sphinx #1043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ docs:
touch docs/.nojekyll

html-noplot:
make clean
$(SPHINXBUILD) -D plot_gallery=0 -b html $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html"
# bash .jenkins/remove_invisible_code_block_batch.sh "$(BUILDDIR)/html"
@echo
Expand Down
15 changes: 13 additions & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import glob
import shutil
from custom_directives import IncludeDirective, GalleryItemDirective, CustomGalleryItemDirective, CustomCalloutItemDirective, CustomCardItemDirective
import distutils.file_util
import re


try:
Expand Down Expand Up @@ -63,10 +65,19 @@
'examples_dirs': ['beginner_source', 'intermediate_source',
'advanced_source', 'recipes_source'],
'gallery_dirs': ['beginner', 'intermediate', 'advanced', 'recipes'],
'filename_pattern': os.environ.get('GALLERY_PATTERN', r'tutorial.py'),
'backreferences_dir': False
}

if os.getenv('GALLERY_PATTERN'):
# GALLERY_PATTERN is to be used when you want to work on a single
# tutorial. Previously this was fed into filename_pattern, but
# if you do that, you still end up parsing all of the other Python
# files which takes a few seconds. This strategy is better, as
# ignore_pattern also skips parsing.
# See https://github.com/sphinx-gallery/sphinx-gallery/issues/721
# for a more detailed description of the issue.
sphinx_gallery_conf['ignore_pattern'] = r'/(?!' + re.escape(os.getenv('GALLERY_PATTERN')) + r')[^/]+$'

for i in range(len(sphinx_gallery_conf['examples_dirs'])):
gallery_dir = sphinx_gallery_conf['gallery_dirs'][i]
source_dir = sphinx_gallery_conf['examples_dirs'][i]
Expand All @@ -78,7 +89,7 @@

# Copy rst files from source dir to gallery dir
for f in glob.glob(os.path.join(source_dir, '*.rst')):
shutil.copy(f, gallery_dir)
distutils.file_util.copy_file(f, gallery_dir, update=True)


# Add any paths that contain templates here, relative to this directory.
Expand Down