Rename incremental regeneration flag

Rename from `full_rebuild` to disable, to `incremental` to enable
This commit is contained in:
Alfred Xing 2015-10-26 14:20:44 -07:00
parent d9b12bc090
commit 2a040fd527
13 changed files with 30 additions and 31 deletions

View File

@ -209,8 +209,7 @@ namespace :site do
Jekyll::Commands::Build.process({ Jekyll::Commands::Build.process({
"source" => File.expand_path("site"), "source" => File.expand_path("site"),
"destination" => File.expand_path("gh-pages"), "destination" => File.expand_path("gh-pages"),
"sass" => { "style" => "compressed" }, "sass" => { "style" => "compressed" }
"full_rebuild" => true
}) })
File.open('gh-pages/.nojekyll', 'wb') { |f| f.puts(":dog: food.") } File.open('gh-pages/.nojekyll', 'wb') { |f| f.puts(":dog: food.") }

View File

@ -10,26 +10,26 @@ Feature: Incremental rebuild
| title | date | layout | content | | title | date | layout | content |
| Wargames | 2009-03-27 | default | The only winning move is not to play. | | Wargames | 2009-03-27 | default | The only winning move is not to play. |
And I have a default layout that contains "Post Layout: {{ content }}" And I have a default layout that contains "Post Layout: {{ content }}"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html" And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html" And I should see "Post Layout: <p>The only winning move is not to play.</p>" in "_site/2009/03/27/wargames.html"
Scenario: Generate a metadata file Scenario: Generate a metadata file
Given I have an "index.html" file that contains "Basic Site" Given I have an "index.html" file that contains "Basic Site"
When I run jekyll build When I run jekyll build -I
Then the ".jekyll-metadata" file should exist Then the ".jekyll-metadata" file should exist
Scenario: Rebuild when content is changed Scenario: Rebuild when content is changed
Given I have an "index.html" file that contains "Basic Site" Given I have an "index.html" file that contains "Basic Site"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Basic Site" in "_site/index.html" And I should see "Basic Site" in "_site/index.html"
When I wait 1 second When I wait 1 second
Then I have an "index.html" file that contains "Bacon Site" Then I have an "index.html" file that contains "Bacon Site"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Bacon Site" in "_site/index.html" And I should see "Bacon Site" in "_site/index.html"
@ -37,12 +37,12 @@ Feature: Incremental rebuild
Given I have a _layouts directory Given I have a _layouts directory
And I have an "index.html" page with layout "default" that contains "Basic Site with Layout" And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
And I have a default layout that contains "Page Layout: {{ content }}" And I have a default layout that contains "Page Layout: {{ content }}"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Page Layout: Basic Site with Layout" in "_site/index.html" And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
When I wait 1 second When I wait 1 second
Then I have a default layout that contains "Page Layout Changed: {{ content }}" Then I have a default layout that contains "Page Layout Changed: {{ content }}"
When I run jekyll build --full-rebuild When I run jekyll build
Then the _site directory should exist Then the _site directory should exist
And I should see "Page Layout Changed: Basic Site with Layout" in "_site/index.html" And I should see "Page Layout Changed: Basic Site with Layout" in "_site/index.html"
@ -50,11 +50,11 @@ Feature: Incremental rebuild
Given I have a _includes directory Given I have a _includes directory
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}" And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
And I have an "_includes/about.textile" file that contains "Generated by Jekyll" And I have an "_includes/about.textile" file that contains "Generated by Jekyll"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html" And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
When I wait 1 second When I wait 1 second
Then I have an "_includes/about.textile" file that contains "Regenerated by Jekyll" Then I have an "_includes/about.textile" file that contains "Regenerated by Jekyll"
When I run jekyll build When I run jekyll build -I
Then the _site directory should exist Then the _site directory should exist
And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html" And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html"

View File

@ -13,7 +13,7 @@ module Jekyll
# Cleans up the site's destination directory # Cleans up the site's destination directory
def cleanup! def cleanup!
FileUtils.rm_rf(obsolete_files) FileUtils.rm_rf(obsolete_files)
FileUtils.rm_rf(metadata_file) if @site.full_rebuild? FileUtils.rm_rf(metadata_file) if !@site.incremental?
end end
private private

View File

@ -60,7 +60,7 @@ module Jekyll
c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished' c.option 'unpublished', '--unpublished', 'Render posts that were marked as unpublished'
c.option 'quiet', '-q', '--quiet', 'Silence output.' c.option 'quiet', '-q', '--quiet', 'Silence output.'
c.option 'verbose', '-V', '--verbose', 'Print verbose output.' c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
c.option 'full_rebuild', '-f', '--full-rebuild', 'Disable incremental rebuild.' c.option 'incremental', '-I', '--incremental', 'Enable incremental rebuild.'
end end
end end

View File

@ -52,10 +52,10 @@ module Jekyll
t = Time.now t = Time.now
source = options['source'] source = options['source']
destination = options['destination'] destination = options['destination']
full_build = options['full_rebuild'] incremental = options['incremental']
Jekyll.logger.info "Source:", source Jekyll.logger.info "Source:", source
Jekyll.logger.info "Destination:", destination Jekyll.logger.info "Destination:", destination
Jekyll.logger.info "Incremental build:", (full_build ? "disabled" : "enabled") Jekyll.logger.info "Incremental build:", (incremental ? "enabled" : "disabled. Enable with --incremental")
Jekyll.logger.info "Generating..." Jekyll.logger.info "Generating..."
process_site(site) process_site(site)
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds." Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."

View File

@ -22,7 +22,6 @@ module Jekyll
'keep_files' => ['.git','.svn'], 'keep_files' => ['.git','.svn'],
'encoding' => 'utf-8', 'encoding' => 'utf-8',
'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md', 'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md',
'full_rebuild' => true,
# Filtering Content # Filtering Content
'show_drafts' => nil, 'show_drafts' => nil,
@ -39,6 +38,7 @@ module Jekyll
'highlighter' => 'rouge', 'highlighter' => 'rouge',
'lsi' => false, 'lsi' => false,
'excerpt_separator' => "\n\n", 'excerpt_separator' => "\n\n",
'incremental' => false,
# Serving # Serving
'detach' => false, # default to not detaching the server 'detach' => false, # default to not detaching the server

View File

@ -144,7 +144,7 @@ module Jekyll
# #
# Returns a Boolean (true for disabled, false for enabled). # Returns a Boolean (true for disabled, false for enabled).
def disabled? def disabled?
@disabled = site.full_rebuild? if @disabled.nil? @disabled = !site.incremental? if @disabled.nil?
@disabled @disabled
end end

View File

@ -351,8 +351,8 @@ module Jekyll
# Whether to perform a full rebuild without incremental regeneration # Whether to perform a full rebuild without incremental regeneration
# #
# Returns a Boolean: true for a full rebuild, false for normal build # Returns a Boolean: true for a full rebuild, false for normal build
def full_rebuild?(override = {}) def incremental?(override = {})
override['full_rebuild'] || config['full_rebuild'] override['incremental'] || config['incremental']
end end
# Returns the publisher or creates a new publisher if it doesn't # Returns the publisher or creates a new publisher if it doesn't

View File

@ -2,7 +2,7 @@
export BENCHMARK=1 export BENCHMARK=1
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site', 'full_rebuild' => true})" TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site'})"
RUBY=$(cat <<RUBY RUBY=$(cat <<RUBY
require 'ruby-prof' require 'ruby-prof'

View File

@ -5,7 +5,7 @@ set -e
export BENCHMARK=true export BENCHMARK=true
command -v stackprof > /dev/null || script/bootstrap command -v stackprof > /dev/null || script/bootstrap
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site', 'full_rebuild' => true})" TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site'})"
PROF_OUTPUT_FILE=tmp/stackprof-$(date +%Y%m%d%H%M).dump PROF_OUTPUT_FILE=tmp/stackprof-$(date +%Y%m%d%H%M).dump
test -f "$PROF_OUTPUT_FILE" || { test -f "$PROF_OUTPUT_FILE" || {

View File

@ -74,7 +74,7 @@ class JekyllUnitTest < Minitest::Test
def site_configuration(overrides = {}) def site_configuration(overrides = {})
full_overrides = build_configs(overrides, build_configs({ full_overrides = build_configs(overrides, build_configs({
"destination" => dest_dir, "destination" => dest_dir,
"full_rebuild" => true "incremental" => false
})) }))
build_configs({ build_configs({
"source" => source_dir "source" => source_dir

View File

@ -11,7 +11,7 @@ class TestRegenerator < JekyllUnitTest
"output" => true "output" => true
} }
}, },
"full_rebuild" => false "incremental" => true
}) })
@site.read @site.read
@ -94,7 +94,7 @@ class TestRegenerator < JekyllUnitTest
FileUtils.rm_rf(source_dir(".jekyll-metadata")) FileUtils.rm_rf(source_dir(".jekyll-metadata"))
@site = fixture_site({ @site = fixture_site({
"full_rebuild" => false "incremental" => true
}) })
@site.read @site.read
@ -131,7 +131,7 @@ class TestRegenerator < JekyllUnitTest
@site = Site.new(Jekyll.configuration({ @site = Site.new(Jekyll.configuration({
"source" => source_dir, "source" => source_dir,
"destination" => dest_dir, "destination" => dest_dir,
"full_rebuild" => false "incremental" => true
})) }))
@site.process @site.process
@ -297,7 +297,7 @@ class TestRegenerator < JekyllUnitTest
end end
should "regenerate everything if metadata is disabled" do should "regenerate everything if metadata is disabled" do
@site.config["full_rebuild"] = true @site.config["incremental"] = false
@regenerator.clear @regenerator.clear
@regenerator.add(@path) @regenerator.add(@path)
@regenerator.write_metadata @regenerator.write_metadata

View File

@ -330,7 +330,7 @@ class TestSite < JekyllUnitTest
end end
bad_processor = "Custom::Markdown" bad_processor = "Custom::Markdown"
s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true)) s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
assert_raises Jekyll::Errors::FatalException do assert_raises Jekyll::Errors::FatalException do
s.process s.process
end end
@ -348,7 +348,7 @@ class TestSite < JekyllUnitTest
should 'throw FatalException at process time' do should 'throw FatalException at process time' do
bad_processor = 'not a processor name' bad_processor = 'not a processor name'
s = Site.new(site_configuration('markdown' => bad_processor, 'full_rebuild' => true)) s = Site.new(site_configuration('markdown' => bad_processor, 'incremental' => false))
assert_raises Jekyll::Errors::FatalException do assert_raises Jekyll::Errors::FatalException do
s.process s.process
end end
@ -429,7 +429,7 @@ class TestSite < JekyllUnitTest
context "manipulating the Jekyll environment" do context "manipulating the Jekyll environment" do
setup do setup do
@site = Site.new(site_configuration({ @site = Site.new(site_configuration({
'full_rebuild' => true 'incremental' => false
})) }))
@site.process @site.process
@page = @site.pages.find { |p| p.name == "environment.html" } @page = @site.pages.find { |p| p.name == "environment.html" }
@ -443,7 +443,7 @@ class TestSite < JekyllUnitTest
setup do setup do
ENV["JEKYLL_ENV"] = "production" ENV["JEKYLL_ENV"] = "production"
@site = Site.new(site_configuration({ @site = Site.new(site_configuration({
'full_rebuild' => true 'incremental' => false
})) }))
@site.process @site.process
@page = @site.pages.find { |p| p.name == "environment.html" } @page = @site.pages.find { |p| p.name == "environment.html" }
@ -473,7 +473,7 @@ class TestSite < JekyllUnitTest
context "incremental build" do context "incremental build" do
setup do setup do
@site = Site.new(site_configuration({ @site = Site.new(site_configuration({
'full_rebuild' => false 'incremental' => true
})) }))
@site.read @site.read
end end