aboutsummaryrefslogtreecommitdiffstats
path: root/docs/_plugins
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-09-27 14:56:52 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-09-27 14:56:52 +0100
commitb3fea58c6f9a29ec5fb428d82c25e3a82ac962af (patch)
treef7b79502c8bcbc158451c205944ee8d337750f8e /docs/_plugins
parent371927debffc6bb42d8d86a90afc715d1d837e74 (diff)
Move docs from gh-pages branch.
Diffstat (limited to 'docs/_plugins')
-rw-r--r--docs/_plugins/incremental_regeneration_fixer.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/docs/_plugins/incremental_regeneration_fixer.rb b/docs/_plugins/incremental_regeneration_fixer.rb
new file mode 100644
index 000000000..f138c37bc
--- /dev/null
+++ b/docs/_plugins/incremental_regeneration_fixer.rb
@@ -0,0 +1,51 @@
+module IncrementalRegenerationFixer
+ def IncrementalRegenerationFixer.init(site)
+ if site.regenerator.disabled?
+ return
+ end
+
+ # This is a fix for the following bug:
+ #
+ # https://github.com/jekyll/jekyll/issues/4112
+ #
+ # To work around it, we'll remember groups of interdependent files;
+ # if any of the files in a group changes, we'll make sure to
+ # regenerate *all* the files in that group.
+ interdependent_files = []
+
+ config = site.config['incremental_regeneration_fixer']
+ if not config
+ raise ("You probably want to specify incremental_regeneration_fixer " +
+ "config if you want to use this plugin")
+ end
+
+ globs = config['interdependent_files']
+ if not globs
+ return
+ end
+
+ for glob in globs
+ group = Dir["#{site.source}/#{glob}"]
+ if group.length == 0
+ raise ("The path '#{glob}' contains no files! Please fix " +
+ "interdependent_files in your site's _config.yml.")
+ end
+ interdependent_files << group
+ end
+
+ for group in interdependent_files
+ for srcfile in group
+ if site.regenerator.modified? srcfile
+ for dependent_file in group
+ site.regenerator.force dependent_file
+ end
+ break
+ end
+ end
+ end
+ end
+end
+
+Jekyll::Hooks.register :site, :post_read do |site|
+ IncrementalRegenerationFixer.init(site)
+end