Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling import of theme configuration #8131

Merged
merged 7 commits into from May 6, 2020

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Apr 23, 2020

  • This is a 馃檵 feature or enhancement.
  • I've added tests.
  • I've adjusted the documentation.

Summary

So that related bugs are not activated out-of-the-box..

Context

Resolves #8114

@ashmaroli ashmaroli added this to the 4.1 milestone Apr 23, 2020
@ashmaroli ashmaroli requested a review from a team April 27, 2020 13:35
@DirtyF
Copy link
Member

DirtyF commented Apr 27, 2020

Can you explain how you see a theme config play with a site config?

I would expect the theme to have his own config, my site to have its config, and my site's config to override the theme's config if I want to override some theme's config.
A clear convention before adding options.

@ashmaroli
Copy link
Member Author

Yes, that was exactly the intended workflow.
Only that are some unforeseen stuff that comes into play.
For example, say a user's theme's config resolves to:

{"foo"=>{"alpha"=>"beta"}}

And their site config includes the following pair:

{"foo"=>{"lorem"=>"ipsum"}}

The user would expect "foo" to just have a single attribute ("lorem"). But, in reality, the resulting config has "foo" with two attributes ("alpha" and "lorem"). The user has to then try and workaround this by explicitly setting foo.alpha => nil.
For a feature meant to ease onboarding, this additional overhead does not bode well.

Another unforeseen issue is that the resulting config (after overriding theme-config with user-end config) is a Ruby Hash instance rather than a Jekyll::Configuration (subclass of Ruby Hash) instance. So effectively, the query site.config.is_a?(Jekyll::Configuration) is false which was an unintended breaking change and another v4.0 regression.

The easiest route out I saw was to remove the feature entirely since it is just one-version old. But I guess SemVer principles expects us to carry the baggage until a v5.0. So the next route would be to either provide an option to disable this non-essential feature or add more technical debt (to buoy a non-essential feature) by patching the bugs as they are reported.

@DirtyF
Copy link
Member

DirtyF commented Apr 28, 2020

When there's no overlap between the theme and the site's config, do we get a Jekyll::Configuration?

@ashmaroli
Copy link
Member Author

When there's no overlap between the theme and the site's config

We get a Jekyll::Configuration if nothing is done irrespective of overlap.
Consider the following lines on master:

jekyll/lib/jekyll/site.rb

Lines 434 to 436 in 18f04c6

def load_theme_configuration(config)
theme_config_file = in_theme_dir("_config.yml")
return config unless File.exist?(theme_config_file)

The argument config to the above private method is always an Jekyll::Configuration instance.


theme_config = SafeYAML.load_file(theme_config_file)

The result from SafeYAML.load_file is always a Hash


Utils.deep_merge_hashes(theme_config, config)

And finally Hash is returned by the utility method
def deep_merge_hashes(master_hash, other_hash)
deep_merge_hashes!(master_hash.dup, other_hash)
end

def deep_merge_hashes!(target, overwrite)
merge_values(target, overwrite)
merge_default_proc(target, overwrite)
duplicate_frozen_values(target)
target
end

Users can *opt-in* by setting `import_theme_config: true` in their config
file.
@ashmaroli ashmaroli changed the title Allow disabling import of theme configuration Make import of theme configuration *opt-in* Apr 30, 2020
@DirtyF DirtyF requested a review from mattr- April 30, 2020 13:08
@ashmaroli ashmaroli added the backport-candidate Consider for merge into an older stable branch label Apr 30, 2020
Copy link
Member

@mattr- mattr- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the docs as the authoritative version of what we want for this feature and made suggestions to the code based on that. That would also mean the title of the PR also doesn't match. 馃槃

lib/jekyll/site.rb Outdated Show resolved Hide resolved
features/theme_configuration.feature Outdated Show resolved Hide resolved
@ashmaroli
Copy link
Member Author

Thanks for the review @mattr-
I started this off with an opt-out stand and switched to an opt-in in a6f932e But I forgot to update the documentation.
Either ways, which stand would be the most apt for Jekyll 4.1 and Jekyll 4.0.1..? Opt-in or opt-out?

@mattr-
Copy link
Member

mattr- commented Apr 30, 2020

Opt out is the least surprising from my point of view, as the feature was already enabled. We don't have numbers but I imagine the number of people that run into this is low enough that we can just point them to the docs when they bring it up and that's good enough for now. we can always revisit the default in 5.0

@ashmaroli ashmaroli changed the title Make import of theme configuration *opt-in* Allow disabling import of theme configuration Apr 30, 2020
@ashmaroli ashmaroli removed the backport-candidate Consider for merge into an older stable branch label Apr 30, 2020
@ashmaroli ashmaroli requested a review from mattr- April 30, 2020 19:27
Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opt out 馃憣

@ashmaroli
Copy link
Member Author

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit ed11d21 into jekyll:master May 6, 2020
jekyllbot added a commit that referenced this pull request May 6, 2020
@ashmaroli ashmaroli deleted the ignore-theme-config branch May 6, 2020 19:57
@jekyll jekyll locked and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: variables used in theme configuration are showing up when not overridden
4 participants