Skip to content

Commit 88044a2

Browse files
authored
Fix deprecation message for missing doc method (#8960)
Merge pull request 8960
1 parent d46bef7 commit 88044a2

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

features/post_data.feature

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,35 @@ Scenario: Use page.render_with_liquid variable
382382
And the _site directory should exist
383383
And I should see "next post: Some like it hot" in "_site/2009/03/27/star-wars.html"
384384
And I should see "Previous post: Some like it hot" in "_site/2009/05/27/terminator.html"
385+
386+
Scenario: Deprecate calling data keys directly via Ruby
387+
Given I have a _posts directory
388+
And I have a _plugins directory
389+
And I have the following post:
390+
| title | date | content |
391+
| My post | 2016-01-21 | Luke, I am your father. |
392+
And I have a "_plugins/foo.rb" file with content:
393+
"""
394+
Jekyll::Hooks.register :documents, :pre_render do |doc|
395+
doc.title
396+
end
397+
"""
398+
And I have a "_plugins/bar.rb" file with content:
399+
"""
400+
module FooBar
401+
def self.dummy?(doc)
402+
doc.title == "Dummy Document"
403+
end
404+
end
405+
406+
Jekyll::Hooks.register :documents, :post_render do |doc|
407+
FooBar.dummy?(doc)
408+
end
409+
"""
410+
When I run jekyll build
411+
Then I should get a zero exit status
412+
And the _site directory should exist
413+
And I should see "Deprecation: Document#title" in the build output
414+
And I should see "_plugins/foo.rb:2" in the build output
415+
And I should see "_plugins/bar.rb:3" in the build output
416+
But I should not see "lib/jekyll/document.rb" in the build output

lib/jekyll/document.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,8 @@ def related_posts
406406
# Override of method_missing to check in @data for the key.
407407
def method_missing(method, *args, &blck)
408408
if data.key?(method.to_s)
409-
Jekyll::Deprecator.deprecation_message "Document##{method} is now a key "\
410-
"in the #data hash."
411-
Jekyll::Deprecator.deprecation_message "Called by #{caller(0..0)}."
409+
Jekyll::Deprecator.deprecation_message "Document##{method} is now a key in the #data hash."
410+
Jekyll.logger.warn "", "Called by #{caller(1..1)[0]}."
412411
data[method.to_s]
413412
else
414413
super

0 commit comments

Comments
 (0)