<commit_before>require "octopress-debugger/version"
require "jekyll"

if RUBY_VERSION >= "2"
  require 'pry-byebug'
else
  require 'pry-debugger'
end

module Octopress
  module Debugger
    class Tag < Liquid::Tag
      def render(context)
        site = context.registers[:site]
        page_hash = context.registers[:page]
        page = site.pages.find{|p| p.url == page_hash['url'] }
        scopes = context.scopes

        binding.pry

        return ''
      end
    end
  end
end

Liquid::Template.register_tag('debug', Octopress::Debugger::Tag)

if defined? Octopress::Docs
  Octopress::Docs.add({
    name:        "Octopress Debugger",
    gem:         "octopress-debugger",
    version:     Octopress::Debugger::VERSION,
    description: "Debug Jekyll sites with a fancy console.",
    path:        File.expand_path(File.join(File.dirname(__FILE__), "../")),
    source_url:  "https://github.com/octopress/debugger"
  })
end<commit_msg>Better in-debugger  example docs<commit_after>require "octopress-debugger/version"
require "jekyll"

if RUBY_VERSION >= "2"
  require 'pry-byebug'
else
  require 'pry-debugger'
end

module Octopress
  module Debugger
    class Tag < Liquid::Tag
      def render(context)
        @context = context
        # Instances
        site      = context.registers[:site]
        page      = site.pages.find{|p| p.url == c('page')['url'] }

        # HELP:
        # Use `c` to read variables from Liquid's context 
        # - c 'site' => site hash
        # - c 'page' => page hash
        #
        # Dot notation works too:
        # - c 'page.content'
        # - c 'post.tags'

        binding.pry

        return '' # Debugger halts on this line
      end

      def c(var)
        @context[var]
      end
    end
  end
end

Liquid::Template.register_tag('debug', Octopress::Debugger::Tag)

if defined? Octopress::Docs
  Octopress::Docs.add({
    name:        "Octopress Debugger",
    gem:         "octopress-debugger",
    version:     Octopress::Debugger::VERSION,
    description: "Debug Jekyll sites with a fancy console.",
    path:        File.expand_path(File.join(File.dirname(__FILE__), "../")),
    source_url:  "https://github.com/octopress/debugger"
  })
end
{'fraction_non_alphanumeric': 0.1263537906137184, 'fraction_numerical': 0.0009025270758122744, 'mean_word_length': 2.5246422893481717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6507249', 'n_tokens_mistral': 742, 'n_tokens_neox': 725, 'n_words': 163}