From 07adee0aa76c8d734155467541d99fd0b890ac0c Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:29:16 +0200 Subject: [PATCH] Set `DocumentationBaseURL` and `DocumentationExtension` This allows `ruby-lsp` to link to cop documentation for this extension. Documentation here is in markdown and rubocop didn't support that until recently, so only set this when it supports both options. Otherwise it would link to non-existant html docs. --- lib/rubocop/sorbet/inject.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/rubocop/sorbet/inject.rb b/lib/rubocop/sorbet/inject.rb index b3a31508..0283a75c 100644 --- a/lib/rubocop/sorbet/inject.rb +++ b/lib/rubocop/sorbet/inject.rb @@ -11,6 +11,14 @@ class << self def defaults! path = CONFIG_DEFAULT.to_s hash = ConfigLoader.send(:load_yaml_configuration, path) + if Gem::Version.new(RuboCop::Version::STRING) >= Gem::Version.new("1.66") + # We use markdown for cop documentation. Unconditionally setting + # the base url will produce incorrect urls on older RuboCop versions, + # so we do that for fully supported version only here. + hash["Sorbet"] ||= {} + hash["Sorbet"]["DocumentationBaseURL"] = "https://github.com/Shopify/rubocop-sorbet/blob/main/manual" + hash["Sorbet"]["DocumentationExtension"] = ".md" + end config = Config.new(hash, path).tap(&:make_excludes_absolute) puts "configuration from #{path}" if ConfigLoader.debug? config = ConfigLoader.merge_with_default(config, path)