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

Commit 9fec847

Browse files
authored
[maintenance] Add plugins for debugging (#7998)
1 parent 9c53a80 commit 9fec847

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

_plugins/debug/site_post_render.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright © Magento, Inc. All rights reserved.
4+
# See COPYING.txt for license details.
5+
6+
# To enable this plugin, add to your '_config.local.yml' the following:
7+
#
8+
# debug: site_post_render
9+
#
10+
# 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.
11+
# See the ":site, :post_render" hook: https://jekyllrb.com/docs/plugins/hooks/
12+
# Available objects to explore are 'site' and 'payload'.
13+
#
14+
# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'):
15+
# - '.methods.sort'
16+
# - '.instance_variables.sort'
17+
# - '.keys.sort'
18+
#
19+
# Examples:
20+
#
21+
# To view available configuration data of the site
22+
# > payload.site.keys
23+
#
24+
# To view the number of pages:
25+
# > payload.site.pages.count
26+
#
27+
# To find a page by path and view its data:
28+
# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0]
29+
# > page.data
30+
#
31+
# To exit from the IRB session:
32+
# > exit!
33+
#
34+
Jekyll::Hooks.register :site, :post_render do |site, payload|
35+
next unless site.config['serving']
36+
37+
# rubocop:disable Lint/Debugger
38+
binding.irb if site.config['debug'] == 'site_post_render'
39+
# rubocop:enable Lint/Debugger
40+
end

_plugins/debug/site_pre_render.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright © Magento, Inc. All rights reserved.
4+
# See COPYING.txt for license details.
5+
6+
# To enable this plugin, add to your '_config.local.yml' the following:
7+
#
8+
# debug: site_pre_render
9+
#
10+
# 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.
11+
# See the ":site, :pre_render" hook: https://jekyllrb.com/docs/plugins/hooks/
12+
# Available objects to explore are 'site' and 'payload'.
13+
#
14+
# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'):
15+
# - '.methods.sort'
16+
# - '.instance_variables.sort'
17+
# - '.keys.sort'
18+
#
19+
# Examples:
20+
#
21+
# To view available configuration data of the site
22+
# > payload.site.keys
23+
#
24+
# To view the number of pages:
25+
# > payload.site.pages.count
26+
#
27+
# To find a page by path and view its data:
28+
# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0]
29+
# > page.data
30+
#
31+
# To exit from the IRB session:
32+
# > exit!
33+
#
34+
Jekyll::Hooks.register :site, :pre_render do |site, payload|
35+
next unless site.config['serving']
36+
37+
# rubocop:disable Lint/Debugger
38+
binding.irb if site.config['debug'] == 'site_pre_render'
39+
# rubocop:enable Lint/Debugger
40+
end

0 commit comments

Comments
 (0)