diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8260ba8..9d3292a 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -64,7 +64,14 @@ jobs: - name: Set up yardocs if: steps.cache-yardocs.outputs.cache-hit != 'true' - run: cd solargraph-rspec && bundle exec yard gems + run: cd solargraph-rspec && bundle exec yard gems --verbose + + - name: List all Yardoc constants and methods + run: | + cd solargraph-rspec + bundle config path vendor/bundle + bundle exec yard list + bundle exec gem list - name: Run tests run: cd solargraph-rspec && bundle exec rspec --format progress diff --git a/lib/solargraph/rspec/correctors/dsl_methods_corrector.rb b/lib/solargraph/rspec/correctors/dsl_methods_corrector.rb index 9e0bcf6..36566e3 100644 --- a/lib/solargraph/rspec/correctors/dsl_methods_corrector.rb +++ b/lib/solargraph/rspec/correctors/dsl_methods_corrector.rb @@ -9,11 +9,15 @@ module Correctors # Includes DSL method helpers in the example group block for completion (ie. it, before, let, subject, etc.) class DslMethodsCorrector < Base # @return [Array] - def self.rspec_yardoc_registry - @rspec_yardoc_registry ||= begin + def self.rspec_yardoc_tags + @rspec_yardoc_tags ||= begin spec = Gem::Specification.find_by_name('rspec-core') require_paths = spec.require_paths.map { |path| File.join(spec.full_gem_path, path) } - YARD::Registry.load(require_paths, true) + Solargraph.logger.debug "[RSpec] Loading YARD registry for rspec-core from #{require_paths}" + puts "[RSpec] Loading YARD registry for rspec-core from #{require_paths}" + loaded = YARD::Registry.load(require_paths, true) + puts YARD::Registry.all + YARD::Registry.all end end @@ -64,7 +68,20 @@ def context_dsl_methods(namespace_pin) def example_group_documentation(method) return unless Rspec::EXAMPLE_METHODS.include?(method) - self.class.rspec_yardoc_registry.at("RSpec::Core::ExampleGroup.#{method}").docstring.all + yardoc = rspec_yardoc_tags_at("RSpec::Core::ExampleGroup.#{method}") + + unless yardoc + Solargraph.logger.warn "[RSpec] YARD documentation not found for RSpec::Core::ExampleGroup.#{method}" + return + end + + yardoc.docstring.all + end + + # @param method [String] + # @return [YARD::CodeObjects::MethodObject, nil] + def rspec_yardoc_tags_at(method_path) + self.class.rspec_yardoc_tags.find { |tag| tag.path == method_path } end # @return [Array] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 857ec14..b3b9a87 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,6 +4,9 @@ require 'solargraph-rspec' require 'debug' unless ENV['NO_DEBUG'] # Useful for: `fswatch lib spec | NO_DEBUG=1 xargs -n1 -I{} rspec` +Solargraph.logger.level = Logger::WARN +YARD::Logger.instance.level = Logger::DEBUG + ENV['SOLARGRAPH_DEBUG'] ||= 'true' # Load support files