<commit_before>namespace :doc do
  def gem_path(gem_name)
    @specs ||= Bundler.load.specs
    @specs.find{|s| s.name == gem_name}.full_gem_path
  end

  desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
  Rake::RDocTask.new("app") { |rdoc|
    rdoc.rdoc_dir = 'doc/app'
    rdoc.template = ENV['template'] if ENV['template']
    rdoc.title    = ENV['title'] || "Rails Application Documentation"
    rdoc.options << '--line-numbers' << '--inline-source'
    rdoc.options << '--charset' << 'utf-8'
    rdoc.rdoc_files.include('doc/README_FOR_APP')
    rdoc.rdoc_files.include('app/**/*.rb')
    rdoc.rdoc_files.include('lib/**/*.rb')
  }

  desc 'Generate documentation for the Rails framework.'
  Rake::RDocTask.new("rails") { |rdoc|
    rdoc.rdoc_dir = 'doc/api'
    rdoc.template = "#{ENV['template']}.rb" if ENV['template']
    rdoc.title    = "Rails Framework Documentation"
    rdoc.options << '--line-numbers' << '--inline-source'
    rdoc.rdoc_files.include('README')

    %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
      rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}")
    end

    %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
      rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}")
    end

    %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
      rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}")
    end

    %w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
      rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}")
    end

    %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
      rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}")
    end

    %w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
      rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}")
    end

    %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
      rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}")
    end
  }

  plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }

  desc "Generate documentation for all installed plugins"
  task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }

  desc "Remove plugin documentation"
  task :clobber_plugins do
    rm_rf 'doc/plugins' rescue nil
  end

  desc "Generate Rails guides"
  task :guides do
    # FIXME: Reaching outside lib directory is a bad idea
    require File.expand_path('../../../../guides/rails_guides', __FILE__)
    RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate
  end

  namespace :plugins do
    # Define doc tasks for each plugin
    plugins.each do |plugin|
      desc "Generate documentation for the #{plugin} plugin"
      task(plugin => :environment) do
        plugin_base   = "vendor/plugins/#{plugin}"
        options       = []
        files         = Rake::FileList.new
        options << "-o doc/plugins/#{plugin}"
        options << "--title '#{plugin.titlecase} Plugin Documentation'"
        options << '--line-numbers' << '--inline-source'
        options << '--charset' << 'utf-8'
        options << '-T html'<commit_msg>Work without bundler<commit_after>namespace :doc do
  def gem_path(gem_name)
    if defined? Bundler
      @specs ||= Bundler.load.specs
      @specs.find{|s| s.name == gem_name}.full_gem_path
    else
      "#{ENV['RAILS_PATH']}/#{gem_name}"
    end
  end

  desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
  Rake::RDocTask.new("app") { |rdoc|
    rdoc.rdoc_dir = 'doc/app'
    rdoc.template = ENV['template'] if ENV['template']
    rdoc.title    = ENV['title'] || "Rails Application Documentation"
    rdoc.options << '--line-numbers' << '--inline-source'
    rdoc.options << '--charset' << 'utf-8'
    rdoc.rdoc_files.include('doc/README_FOR_APP')
    rdoc.rdoc_files.include('app/**/*.rb')
    rdoc.rdoc_files.include('lib/**/*.rb')
  }

  desc 'Generate documentation for the Rails framework. Uses gem paths or the RAILS_PATH environment variable.'
  path = ENV['RAILS_PATH']
  unless defined?(Bundler) || (path && File.directory?(path))
    task :rails do
    if path
      $stderr.puts "Skipping doc:rails, missing Rails directory at #{path}"
    else
      $stderr.puts "Skipping doc:rails, RAILS_PATH environment variable is not set"
    end
  else
    desc 'Generate documentation for the Rails framework.'
    Rake::RDocTask.new("rails") { |rdoc|
      rdoc.rdoc_dir = 'doc/api'
      rdoc.template = "#{ENV['template']}.rb" if ENV['template']
      rdoc.title    = "Rails Framework Documentation"
      rdoc.options << '--line-numbers' << '--inline-source'
      rdoc.rdoc_files.include('README')

      %w(README CHANGELOG MIT-LICENSE lib/action_mailer/base.rb).each do |file|
        rdoc.rdoc_files.include("#{gem_path('actionmailer')}/#{file}")
      end

      %w(README CHANGELOG MIT-LICENSE lib/action_controller/**/*.rb lib/action_view/**/*.rb).each do |file|
        rdoc.rdoc_files.include("#{gem_path('actionpack')}/#{file}")
      end

      %w(README CHANGELOG MIT-LICENSE lib/active_model/**/*.rb).each do |file|
        rdoc.rdoc_files.include("#{gem_path('activemodel')}/#{file}")
      end

      %w(README CHANGELOG lib/active_record/**/*.rb).each do |file|
        rdoc.rdoc_files.include("#{gem_path('activerecord')}/#{file}")
      end

      %w(README CHANGELOG lib/active_resource.rb lib/active_resource/*).each do |file|
        rdoc.rdoc_files.include("#{gem_path('activeresource')}/#{file}")
      end

      %w(README CHANGELOG lib/active_support/**/*.rb).each do |file|
        rdoc.rdoc_files.include("#{gem_path('activesupport')}/#{file}")
      end

      %w(README CHANGELOG lib/{*.rb,commands/*.rb,generators/*.rb}).each do |file|
        rdoc.rdoc_files.include("#{gem_path('railties')}/#{file}")
      end
    }
  end

  plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }

  desc "Generate documentation for all installed plugins"
  task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }

  desc "Remove plugin documentation"
  task :clobber_plugins do
    rm_rf 'doc/plugins' rescue nil
  end

  desc "Generate Rails guides"
  task :guides do
    # FIXME: Reaching outside lib directory is a bad idea
    require File.expand_path('../../../../guides/rails_guides', __FILE__)
    RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate
  end

  namespace :plugins do
    # Define doc tasks for each plugin
    plugins.each do |plugin|
      desc "Generate documentation for the #{plugin} plugin"
      task(plugin => :environment) do
        plugin_base   = "vendor/plugins/#{plugin}"
        options       = []
        files         = Rake::FileList.new
        options << "-o doc/plugins/#{plugin}"
        options << "--title '#{plugin.titlecase} Plugin Documentation'"
        options << '--line-numbers' << '--inline-source'
        options << '--charset' << 'utf-8'
        options << '-T html'
{'fraction_non_alphanumeric': 0.16443277601215975, 'fraction_numerical': 0.0005527152134862512, 'mean_word_length': 3.280307510348906, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '4881817', 'n_tokens_mistral': 2453, 'n_tokens_neox': 2419, 'n_words': 492}