From e9dcc705eae42a696a4ccde61562dba1943d01be Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 5 Oct 2020 13:04:03 -0500 Subject: [PATCH 1/5] Add plugins for debugging --- _plugins/debug/site_post_render.rb | 38 ++++++++++++++++++++++++++++++ _plugins/debug/site_pre_render.rb | 38 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 _plugins/debug/site_post_render.rb create mode 100644 _plugins/debug/site_pre_render.rb diff --git a/_plugins/debug/site_post_render.rb b/_plugins/debug/site_post_render.rb new file mode 100644 index 00000000000..dff5fbfc673 --- /dev/null +++ b/_plugins/debug/site_post_render.rb @@ -0,0 +1,38 @@ +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +# To enable this plugin, add to your 'config.local.yml' the following: +# +# debug: site_post_render +# +# This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state after rendering the whole site, but before writing any files. +# See the ":site, :post_render" hook: https://jekyllrb.com/docs/plugins/hooks/ +# Available objects to explore are 'site' and 'config'. +# +# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'config.keys'): +# - '.methods.sort' +# - '.instance_variables.sort' +# - '.keys.sort' +# +# Examples: +# +# To view available configuration data of the site +# > config.site.keys +# +# To view the number of pages: +# > config.site.pages.count +# +# To find a page by path and view its data: +# > page = config.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page.data +# +# To exit from the IRB session: +# > exit! +# +Jekyll::Hooks.register :site, :post_render do |site, config| + next unless page.site.config['serving'] + + if site.config['debug'] == 'site_post_render' + binding.irb + end +end diff --git a/_plugins/debug/site_pre_render.rb b/_plugins/debug/site_pre_render.rb new file mode 100644 index 00000000000..05e36505d2f --- /dev/null +++ b/_plugins/debug/site_pre_render.rb @@ -0,0 +1,38 @@ +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +# To enable this plugin, add to your 'config.local.yml' the following: +# +# debug: site_pre_render +# +# This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state just before rendering the whole site. +# See the ":site, :pre_render" hook: https://jekyllrb.com/docs/plugins/hooks/ +# Available objects to explore are 'site' and 'config'. +# +# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'config.keys'): +# - '.methods.sort' +# - '.instance_variables.sort' +# - '.keys.sort' +# +# Examples: +# +# To view available configuration data of the site +# > config.site.keys +# +# To view the number of pages: +# > config.site.pages.count +# +# To find a page by path and view its data: +# > page = config.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page.data +# +# To exit from the IRB session: +# > exit! +# +Jekyll::Hooks.register :site, :pre_render do |site, config| + next unless page.site.config['serving'] + + if site.config['debug'] == 'site_pre_render' + binding.irb + end +end From 53e23770288f7e41177b5e2140204712a6ba4c0c Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 5 Oct 2020 13:10:20 -0500 Subject: [PATCH 2/5] Rename config to payload in plugins for debugging --- _plugins/debug/site_post_render.rb | 12 ++++++------ _plugins/debug/site_pre_render.rb | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/_plugins/debug/site_post_render.rb b/_plugins/debug/site_post_render.rb index dff5fbfc673..e8c5d66e925 100644 --- a/_plugins/debug/site_post_render.rb +++ b/_plugins/debug/site_post_render.rb @@ -1,15 +1,15 @@ # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. -# To enable this plugin, add to your 'config.local.yml' the following: +# To enable this plugin, add to your '_config.local.yml' the following: # # debug: site_post_render # # This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state after rendering the whole site, but before writing any files. # See the ":site, :post_render" hook: https://jekyllrb.com/docs/plugins/hooks/ -# Available objects to explore are 'site' and 'config'. +# Available objects to explore are 'site' and 'payload'. # -# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'config.keys'): +# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'): # - '.methods.sort' # - '.instance_variables.sort' # - '.keys.sort' @@ -17,13 +17,13 @@ # Examples: # # To view available configuration data of the site -# > config.site.keys +# > payload.site.keys # # To view the number of pages: -# > config.site.pages.count +# > payload.site.pages.count # # To find a page by path and view its data: -# > page = config.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] # > page.data # # To exit from the IRB session: diff --git a/_plugins/debug/site_pre_render.rb b/_plugins/debug/site_pre_render.rb index 05e36505d2f..da373da86c8 100644 --- a/_plugins/debug/site_pre_render.rb +++ b/_plugins/debug/site_pre_render.rb @@ -1,15 +1,15 @@ # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. -# To enable this plugin, add to your 'config.local.yml' the following: +# To enable this plugin, add to your '_config.local.yml' the following: # # debug: site_pre_render # # This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state just before rendering the whole site. # See the ":site, :pre_render" hook: https://jekyllrb.com/docs/plugins/hooks/ -# Available objects to explore are 'site' and 'config'. +# Available objects to explore are 'site' and 'payload'. # -# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'config.keys'): +# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'): # - '.methods.sort' # - '.instance_variables.sort' # - '.keys.sort' @@ -17,19 +17,19 @@ # Examples: # # To view available configuration data of the site -# > config.site.keys +# > payload.site.keys # # To view the number of pages: -# > config.site.pages.count +# > payload.site.pages.count # # To find a page by path and view its data: -# > page = config.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] # > page.data # # To exit from the IRB session: # > exit! # -Jekyll::Hooks.register :site, :pre_render do |site, config| +Jekyll::Hooks.register :site, :pre_render do |site, payload| next unless page.site.config['serving'] if site.config['debug'] == 'site_pre_render' From 402ad35311f295fa197d4ecbaefe07c6a3374278 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 5 Oct 2020 13:20:56 -0500 Subject: [PATCH 3/5] Autofixes by rubocop --- _plugins/debug/site_post_render.rb | 20 ++++++++++---------- _plugins/debug/site_pre_render.rb | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/_plugins/debug/site_post_render.rb b/_plugins/debug/site_post_render.rb index e8c5d66e925..5b784f608a8 100644 --- a/_plugins/debug/site_post_render.rb +++ b/_plugins/debug/site_post_render.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. # To enable this plugin, add to your '_config.local.yml' the following: -# +# # debug: site_post_render -# +# # This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state after rendering the whole site, but before writing any files. # See the ":site, :post_render" hook: https://jekyllrb.com/docs/plugins/hooks/ # Available objects to explore are 'site' and 'payload'. @@ -15,24 +17,22 @@ # - '.keys.sort' # # Examples: -# +# # To view available configuration data of the site # > payload.site.keys -# +# # To view the number of pages: # > payload.site.pages.count -# +# # To find a page by path and view its data: -# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] # > page.data # # To exit from the IRB session: # > exit! -# +# Jekyll::Hooks.register :site, :post_render do |site, config| next unless page.site.config['serving'] - if site.config['debug'] == 'site_post_render' - binding.irb - end + binding.irb if site.config['debug'] == 'site_post_render' end diff --git a/_plugins/debug/site_pre_render.rb b/_plugins/debug/site_pre_render.rb index da373da86c8..3384dc0ec08 100644 --- a/_plugins/debug/site_pre_render.rb +++ b/_plugins/debug/site_pre_render.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + # Copyright © Magento, Inc. All rights reserved. # See COPYING.txt for license details. # To enable this plugin, add to your '_config.local.yml' the following: -# +# # debug: site_pre_render -# +# # This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state just before rendering the whole site. # See the ":site, :pre_render" hook: https://jekyllrb.com/docs/plugins/hooks/ # Available objects to explore are 'site' and 'payload'. @@ -15,24 +17,22 @@ # - '.keys.sort' # # Examples: -# +# # To view available configuration data of the site # > payload.site.keys -# +# # To view the number of pages: # > payload.site.pages.count -# +# # To find a page by path and view its data: -# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] +# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] # > page.data -# +# # To exit from the IRB session: # > exit! -# +# Jekyll::Hooks.register :site, :pre_render do |site, payload| next unless page.site.config['serving'] - if site.config['debug'] == 'site_pre_render' - binding.irb - end + binding.irb if site.config['debug'] == 'site_pre_render' end From 8265fa8bc58907900b7beb65dca59a99865e01c3 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 5 Oct 2020 13:29:49 -0500 Subject: [PATCH 4/5] Rubocop linting --- _plugins/debug/site_post_render.rb | 2 ++ _plugins/debug/site_pre_render.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/_plugins/debug/site_post_render.rb b/_plugins/debug/site_post_render.rb index 5b784f608a8..f478c02647b 100644 --- a/_plugins/debug/site_post_render.rb +++ b/_plugins/debug/site_post_render.rb @@ -34,5 +34,7 @@ Jekyll::Hooks.register :site, :post_render do |site, config| next unless page.site.config['serving'] + # rubocop:disable Lint/Debugger binding.irb if site.config['debug'] == 'site_post_render' + # rubocop:enable Lint/Debugger end diff --git a/_plugins/debug/site_pre_render.rb b/_plugins/debug/site_pre_render.rb index 3384dc0ec08..6f7c93ce8a9 100644 --- a/_plugins/debug/site_pre_render.rb +++ b/_plugins/debug/site_pre_render.rb @@ -34,5 +34,7 @@ Jekyll::Hooks.register :site, :pre_render do |site, payload| next unless page.site.config['serving'] + # rubocop:disable Lint/Debugger binding.irb if site.config['debug'] == 'site_pre_render' + # rubocop:enable Lint/Debugger end From e55e612f47d4f681f9b9675abe8a965dc909a407 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Mon, 5 Oct 2020 13:34:33 -0500 Subject: [PATCH 5/5] Fix a bug --- _plugins/debug/site_post_render.rb | 4 ++-- _plugins/debug/site_pre_render.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_plugins/debug/site_post_render.rb b/_plugins/debug/site_post_render.rb index f478c02647b..8e72a2bae95 100644 --- a/_plugins/debug/site_post_render.rb +++ b/_plugins/debug/site_post_render.rb @@ -31,8 +31,8 @@ # To exit from the IRB session: # > exit! # -Jekyll::Hooks.register :site, :post_render do |site, config| - next unless page.site.config['serving'] +Jekyll::Hooks.register :site, :post_render do |site, payload| + next unless site.config['serving'] # rubocop:disable Lint/Debugger binding.irb if site.config['debug'] == 'site_post_render' diff --git a/_plugins/debug/site_pre_render.rb b/_plugins/debug/site_pre_render.rb index 6f7c93ce8a9..bae552f6b0c 100644 --- a/_plugins/debug/site_pre_render.rb +++ b/_plugins/debug/site_pre_render.rb @@ -32,7 +32,7 @@ # > exit! # Jekyll::Hooks.register :site, :pre_render do |site, payload| - next unless page.site.config['serving'] + next unless site.config['serving'] # rubocop:disable Lint/Debugger binding.irb if site.config['debug'] == 'site_pre_render'