Module: RuboCop::Cop::Documentation
- Included in:
- CopsDocumentationGenerator
- Defined in:
- lib/rubocop/cop/documentation.rb
Overview
Helpers for builtin documentation
Class Method Summary collapse
- .base_url_for(cop_class, config) ⇒ Object private
- .default_base_url ⇒ Object private
- .department_to_basename(department) ⇒ Object private
- .url_for(cop_class, config = nil) ⇒ Object private
Class Method Details
.base_url_for(cop_class, config) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/cop/documentation.rb', line 24 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 |
.default_base_url ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/rubocop/cop/documentation.rb', line 34 def default_base_url 'https://docs.rubocop.org/rubocop' end |
.department_to_basename(department) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/rubocop/cop/documentation.rb', line 10 def department_to_basename(department) "cops_#{department.to_s.downcase.tr('/', '_')}" end |
.url_for(cop_class, config = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 |
# File 'lib/rubocop/cop/documentation.rb', line 15 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 |