Skip to content

Commit d1b7186

Browse files
authored
Merge pull request #1368 from Earlopain/documentation-rails-version
[Fix #1203] Insert the target rails version into docs
2 parents 490e9e8 + 34ca703 commit d1b7186

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/rubocop/cop/mixin/target_rails_version.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module TargetRailsVersion
77
# Informs the base RuboCop gem that it the Rails version is checked via `requires_gem` API,
88
# without needing to call this `#support_target_rails_version` method.
99
USES_REQUIRES_GEM_API = true
10+
# Look for `railties` instead of `rails`, to support apps that only use a subset of `rails`
11+
# See https://github.com/rubocop/rubocop/pull/11289
12+
TARGET_GEM_NAME = 'railties' # :nodoc:
1013

1114
def minimum_target_rails_version(version)
1215
if respond_to?(:requires_gem)
@@ -33,11 +36,6 @@ def support_target_rails_version?(version)
3336
@minimum_target_rails_version <= version
3437
end
3538
end
36-
37-
# Look for `railties` instead of `rails`, to support apps that only use a subset of `rails`
38-
# See https://github.com/rubocop/rubocop/pull/11289
39-
TARGET_GEM_NAME = 'railties'
40-
private_constant :TARGET_GEM_NAME
4139
end
4240
end
4341
end

tasks/cops_documentation.rake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ end
1212

1313
task update_cops_documentation: :yard_for_generate_documentation do
1414
deps = ['Rails']
15+
# NOTE: Insert minimum_target_rails_version after ruby version
16+
required_rails_version = lambda do |data|
17+
return '' unless (version = data.cop.gem_requirements[RuboCop::Cop::TargetRailsVersion::TARGET_GEM_NAME])
18+
19+
"NOTE: Required Rails version: #{version.requirements[0][1]}\n\n"
20+
end
21+
extra_info = { required_ruby_version: required_rails_version }
1522

1623
# NOTE: Update `<<next>>` version for docs/modules/ROOT/pages/cops_rails.adoc
1724
# when running release tasks.
1825
RuboCop::Rails::Inject.defaults!
1926

20-
CopsDocumentationGenerator.new(departments: deps).call
27+
CopsDocumentationGenerator.new(departments: deps, extra_info: extra_info).call
2128
end
2229

2330
desc 'Syntax check for the documentation comments'

0 commit comments

Comments
 (0)