Sha256: 2906b4750cd4d74f843e27590c3110f83fadf8b653bbc68f5787156d679efb79

Contents?: true

Size: 1001 Bytes

Versions: 193

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Helpers for builtin documentation
    module Documentation
      module_function

      # @api private
      def department_to_basename(department)
        "cops_#{department.to_s.downcase.tr('/', '_')}"
      end

      # @api private
      def url_for(cop_class, config = nil)
        base = department_to_basename(cop_class.department)
        fragment = cop_class.cop_name.downcase.gsub(/[^a-z]/, '')
        base_url = base_url_for(cop_class, config)

        "#{base_url}/#{base}.html##{fragment}"
      end

      # @api private
      def base_url_for(cop_class, config)
        return default_base_url unless config

        department_name = cop_class.department.to_s

        config.for_department(department_name)['DocumentationBaseURL'] ||
          config.for_all_cops['DocumentationBaseURL']
      end

      # @api private
      def default_base_url
        'https://docs.rubocop.org/rubocop'
      end
    end
  end
end

Version data entries

193 entries across 184 versions & 17 rubygems

Version Path
rubocop-1.56.1 lib/rubocop/cop/documentation.rb
tursodb-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.0/lib/rubocop/cop/documentation.rb
synctera_ruby_sdk-1.0.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.0/lib/rubocop/cop/documentation.rb
rubocop-1.56.0 lib/rubocop/cop/documentation.rb
rubocop-1.55.1 lib/rubocop/cop/documentation.rb
rubocop-1.55.0 lib/rubocop/cop/documentation.rb
rubocop-1.54.2 lib/rubocop/cop/documentation.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.54.1/lib/rubocop/cop/documentation.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.54.1/lib/rubocop/cop/documentation.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.52.1/lib/rubocop/cop/documentation.rb
rubocop-1.54.1 lib/rubocop/cop/documentation.rb
rubocop-1.54.0 lib/rubocop/cop/documentation.rb
rubocop-1.53.1 lib/rubocop/cop/documentation.rb
rubocop-1.53.0 lib/rubocop/cop/documentation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/cop/documentation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.26.0/lib/rubocop/cop/documentation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.52.1/lib/rubocop/cop/documentation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/cop/documentation.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/cop/documentation.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.52.1/lib/rubocop/cop/documentation.rb