Skip to content
Permalink
Browse files

Remove warnings and fixes for deprecated config (#7440)

Merge pull request 7440
  • Loading branch information...
ashmaroli authored and jekyllbot committed Aug 4, 2019
1 parent 9a10ff9 commit 0f5e15811fe8f9a33a6cd1e3c05859b627f12e93
@@ -156,3 +156,13 @@ Notes:
```
* Vendors that provide a versioned Jekyll Environment Image (e.g. Docker Image, GitHub Pages, etc)
will have to manually whitelist kramdown's extension gems in their distributions for Jekyll 4.0.

## Deprecated Configuration Options

Jekyll 4.0 has dropped support for all legacy configuration options that were deprecated over multiple
releases in the previous series.

To that end, we shall no longer output a deprecation warning when we encounter a legacy config key nor
shall we gracefully assign their values to the newer counterparts. Depending on the key, it shall either
be ignored or raise an `InvalidConfigurationError` error if the key is still valid but the associated
value is not of the valid type.
@@ -21,7 +21,7 @@ Feature: Markdown
Given I have a configuration file with:
| key | value |
| paginate | 5 |
| gems | [jekyll-paginate] |
| plugins | [jekyll-paginate] |
And I have an "index.html" page that contains "Index - {% for post in paginator.posts %} {{ post.content }} {% endfor %}"
And I have a _posts directory
And I have the following post:
@@ -7,7 +7,7 @@ Feature: Site pagination
Given I have a configuration file with:
| key | value |
| paginate | <num> |
| gems | [jekyll-paginate] |
| plugins | [jekyll-paginate] |
And I have a _layouts directory
And I have an "index.html" page that contains "{{ paginator.posts.size }}"
And I have a _posts directory
@@ -35,7 +35,7 @@ Feature: Site pagination
| paginate | 1 |
| paginate_path | /blog/page-:num |
| permalink | /blog/:year/:month/:day/:title |
| gems | [jekyll-paginate] |
| plugins | [jekyll-paginate] |
And I have a blog directory
And I have an "blog/index.html" page that contains "{{ paginator.posts.size }}"
And I have a _posts directory
@@ -63,7 +63,7 @@ Feature: Site pagination
| paginate | 1 |
| paginate_path | /blog/page/:num |
| permalink | /blog/:year/:month/:day/:title |
| gems | [jekyll-paginate] |
| plugins | [jekyll-paginate] |
And I have a blog directory
And I have an "blog/index.html" page that contains "{{ paginator.posts.size }}"
And I have an "index.html" page that contains "Don't pick me!"
@@ -4,7 +4,7 @@ Feature: Configuring and using plugins

Scenario: Add a gem-based plugin
Given I have an "index.html" file that contains "Whatever"
And I have a configuration file with "gems" set to "[jekyll_test_plugin]"
And I have a configuration file with "plugins" set to "[jekyll_test_plugin]"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
@@ -15,7 +15,7 @@ Feature: Configuring and using plugins
Given I have an "index.html" file that contains "Whatever"
And I have a configuration file with:
| key | value |
| gems | [jekyll_test_plugin] |
| plugins | [jekyll_test_plugin] |
| whitelist | [] |
When I run jekyll build --safe
Then I should get a zero exit status
@@ -27,7 +27,7 @@ Feature: Configuring and using plugins
Given I have an "index.html" file that contains "Whatever"
And I have a configuration file with:
| key | value |
| gems | [jekyll_test_plugin, jekyll_test_plugin_malicious] |
| plugins | [jekyll_test_plugin, jekyll_test_plugin_malicious] |
| whitelist | [jekyll_test_plugin] |
When I run jekyll build --safe
Then I should get a zero exit status
@@ -98,7 +98,7 @@ Feature: Rendering
Scenario: Don't place asset files in layout
Given I have an "index.scss" page with layout "simple" that contains ".foo-bar { color:black; }"
And I have an "index.coffee" page with layout "simple" that contains "whatever()"
And I have a configuration file with "gems" set to "[jekyll-coffeescript]"
And I have a configuration file with "plugins" set to "[jekyll-coffeescript]"
And I have a simple layout that contains "{{ content }}Ahoy, indeed!"
When I run jekyll build
Then I should get a zero exit status
@@ -165,7 +165,7 @@ Feature: Rendering

Scenario: Render liquid in CoffeeScript with jekyll-coffeescript enabled
Given I have an "index.coffee" page with animal "cicada" that contains "hey='for {{page.animal}}'"
And I have a configuration file with "gems" set to "[jekyll-coffeescript]"
And I have a configuration file with "plugins" set to "[jekyll-coffeescript]"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("safe_yaml", "~> 1.0")

s.post_install_message = <<~MSG
----------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
This version of Jekyll comes with some major changes.
Most notably:
@@ -59,6 +59,10 @@ Gem::Specification.new do |s|
* Our `post_url` tag now comes with the `relative_url` filter incorporated into it.
You shouldn't prepend `{{ site.baseurl }}` to `{% post_url 2019-03-27-hello %}`
For further details: https://github.com/jekyll/jekyll/pull/7589
----------------------------------------------------------------------------------
* Support for deprecated configuration options has been removed. We will no longer
output a warning and gracefully assign their values to the newer counterparts
internally.
-------------------------------------------------------------------------------------
MSG
end
@@ -79,15 +79,11 @@ class Configuration < Hash

class << self
# Static: Produce a Configuration ready for use in a Site.
# It takes the input, fills in the defaults where values do not
# exist, and patches common issues including migrating options for
# backwards compatiblity. Except where a key or value is being fixed,
# the user configuration will override the defaults.
# It takes the input, fills in the defaults where values do not exist.
#
# user_config - a Hash or Configuration of overrides.
#
# Returns a Configuration filled with defaults and fixed for common
# problems and backwards-compatibility.
# Returns a Configuration filled with defaults.
def from(user_config)
Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys)
.add_default_collections.add_default_excludes
@@ -132,8 +128,8 @@ def safe_load_file(filename)
when %r!\.ya?ml!i
SafeYAML.load_file(filename) || {}
else
raise ArgumentError, "No parser for '#{filename}' is available.
Use a .y(a)ml or .toml file instead."
raise ArgumentError,
"No parser for '#{filename}' is available. Use a .y(a)ml or .toml file instead."
end
end

@@ -169,16 +165,19 @@ def config_files(override)
def read_config_file(file)
file = File.expand_path(file)
next_config = safe_load_file(file)
check_config_is_hash!(next_config, file)

unless next_config.is_a?(Hash)
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
end

Jekyll.logger.info "Configuration file:", file
next_config
rescue SystemCallError
if @default_config_file ||= nil
Jekyll.logger.warn "Configuration file:", "none"
{}
else
Jekyll.logger.error "Fatal:", "The configuration file '#{file}'
could not be found."
Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
raise LoadError, "The Configuration file '#{file}' could not be found."
end
end
@@ -200,12 +199,11 @@ def read_config_files(files)
configuration = Utils.deep_merge_hashes(configuration, new_config)
end
rescue ArgumentError => e
Jekyll.logger.warn "WARNING:", "Error reading configuration. " \
"Using defaults (and options)."
Jekyll.logger.warn "WARNING:", "Error reading configuration. Using defaults (and options)."
warn e
end

configuration.backwards_compatibilize.add_default_collections
configuration.validate.add_default_collections
end

# Public: Split a CSV string into an array containing its values
@@ -217,35 +215,18 @@ def csv_to_array(csv)
csv.split(",").map(&:strip)
end

# Public: Ensure the proper options are set in the configuration to allow for
# backwards-compatibility with Jekyll pre-1.0
# Public: Ensure the proper options are set in the configuration
#
# Returns the backwards-compatible configuration
def backwards_compatibilize
# Returns the configuration Hash
def validate
config = clone
# Provide backwards-compatibility
check_auto(config)
check_server(config)
check_plugins(config)

renamed_key "server_port", "port", config
renamed_key "gems", "plugins", config
renamed_key "layouts", "layouts_dir", config
renamed_key "data_source", "data_dir", config

check_pygments(config)
check_plugins(config)
check_include_exclude(config)
check_coderay(config)
check_maruku(config)

config
end

# DEPRECATED.
def fix_common_issues
self
end

def add_default_collections
config = clone

@@ -284,15 +265,6 @@ def add_default_excludes
config
end

def renamed_key(old, new, config)
if config.key?(old)
Jekyll::Deprecator.deprecation_message "The '#{old}' configuration" \
" option has been renamed to '#{new}'. Please update your config" \
" file accordingly."
config[new] = config.delete(old)
end
end

private

def style_to_permalink(permalink_style)
@@ -312,77 +284,13 @@ def style_to_permalink(permalink_style)
end
end

# Private: Checks if a given config is a hash
#
# extracted_config - the value to check
# file - the file from which the config was extracted
#
# Raises an ArgumentError if given config is not a hash
def check_config_is_hash!(extracted_config, file)
unless extracted_config.is_a?(Hash)
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
end
end

def check_auto(config)
if config.key?("auto") || config.key?("watch")
Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \
" be set from your configuration file(s). Use the" \
" --[no-]watch/-w command-line option instead."
config.delete("auto")
config.delete("watch")
end
end

def check_server(config)
if config.key?("server")
Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \
" is no longer accepted. Use the 'jekyll serve'" \
" subcommand to serve your site with WEBrick."
config.delete("server")
end
end

def check_pygments(config)
if config.key?("pygments")
Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \
" has been renamed to 'highlighter'. Please update your" \
" config file accordingly. The allowed values are 'rouge', " \
"'pygments' or null."

config["highlighter"] = "pygments" if config["pygments"]
config.delete("pygments")
end
end

def check_include_exclude(config)
%w(include exclude).each do |option|
if config[option].is_a?(String)
Jekyll::Deprecator.deprecation_message "The '#{option}' configuration option" \
" must now be specified as an array, but you specified" \
" a string. For now, we've treated the string you provided" \
" as a list of comma-separated values."
config[option] = csv_to_array(config[option])
end
config[option]&.map!(&:to_s)
end
end
next unless config.key?(option)
next if config[option].is_a?(Array)

def check_coderay(config)
if (config["kramdown"] || {}).key?("use_coderay")
Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \
" to 'enable_coderay' in your configuration file."
config["kramdown"]["use_coderay"] = config["kramdown"].delete("enable_coderay")
end
end

def check_maruku(config)
if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero?
Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \
"Markdown processor, which has been removed as of 3.0.0. " \
"We recommend you switch to Kramdown. To do this, replace " \
"`markdown: maruku` with `markdown: kramdown` in your " \
"`_config.yml` file."
raise Jekyll::Errors::InvalidConfigurationError,
"'#{option}' should be set as an array, but was: #{config[option].inspect}."
end
end

@@ -391,17 +299,16 @@ def check_maruku(config)
# config - the config hash
#
# Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins`
# is a string
# is not an Array.
def check_plugins(config)
if config.key?("plugins") && config["plugins"].is_a?(String)
Jekyll.logger.error "Configuration Error:", "You specified the" \
" `plugins` config in your configuration file as a string, please" \
" use an array instead. If you wanted to set the directory of your" \
" plugins, use the config key `plugins_dir` instead."
raise Jekyll::Errors::InvalidConfigurationError,
"'plugins' should not be a string, but was: " \
"#{config["plugins"].inspect}. Use 'plugins_dir' instead."
end
return unless config.key?("plugins")
return if config["plugins"].is_a?(Array)

Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \
"#{config["plugins"].inspect}. Use 'plugins_dir' instead to set the directory " \
"for your non-gemified Ruby plugins."
raise Jekyll::Errors::InvalidConfigurationError,
"'plugins' should be set as an array, but was: #{config["plugins"].inspect}."
end
end
end

0 comments on commit 0f5e158

Please sign in to comment.
You can’t perform that action at this time.