Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

[maintenance] Add plugins for debugging #7998

Merged
merged 6 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions _plugins/debug/site_post_render.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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'.
#
# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'):
# - '.methods.sort'
# - '.instance_variables.sort'
# - '.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.data
#
# To exit from the IRB session:
# > exit!
#
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'
# rubocop:enable Lint/Debugger
end
40 changes: 40 additions & 0 deletions _plugins/debug/site_pre_render.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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'.
#
# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'):
# - '.methods.sort'
# - '.instance_variables.sort'
# - '.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.data
#
# To exit from the IRB session:
# > exit!
#
Jekyll::Hooks.register :site, :pre_render do |site, payload|
next unless site.config['serving']

# rubocop:disable Lint/Debugger
binding.irb if site.config['debug'] == 'site_pre_render'
# rubocop:enable Lint/Debugger
end