Skip to content

Commit

Permalink
List Yardoc methods in GH Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lekemula committed Jun 9, 2024
1 parent a8e30e4 commit ccb621b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion lib/solargraph/rspec/correctors/dsl_methods_corrector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def self.rspec_yardoc_registry
@rspec_yardoc_registry ||= begin
spec = Gem::Specification.find_by_name('rspec-core')
require_paths = spec.require_paths.map { |path| File.join(spec.full_gem_path, path) }
Solargraph.logger.debug "[RSpec] Loading YARD registry for rspec-core from #{require_paths}"
YARD::Registry.load(require_paths, true)
end
end
Expand Down Expand Up @@ -64,7 +65,15 @@ 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
# @type [YARD::CodeObjects::MethodObject, nil]
yardoc = self.class.rspec_yardoc_registry.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

# @return [Array<String>]
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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

ENV['SOLARGRAPH_DEBUG'] ||= 'true'

# Load support files
Expand Down

0 comments on commit ccb621b

Please sign in to comment.