Sord strips important information from included constants
Describe the bug
In YARD, this file can be found at lib/yard/server/commands/list_command.rb:
# frozen_string_literal: true
module YARD
module Server
module Commands
class ListCommand < LibraryCommand
include Templates::Helpers::BaseHelper
def run
# code
end
end
end
end
end
To Reproduce
Run Sord on YARD and search for include BaseHelper in class ListCommand.
Expected behavior
class ListCommand < LibraryCommand
include Templates::Helpers::BaseHelper
# methods
end
Actual behavior
Just BaseHelper is generated, which causes an error:
class ListCommand < LibraryCommand
include BaseHelper
# methods
end
You can also see something similar happen in bundler.rbi where class RGProxy < ::Gem::SilentUI becomes class RGProxy < SilentUI, causing an Sorbet error.
Changing name to path in https://github.com/AaronC81/sord/blob/master/lib/sord/rbi_generator.rb#L68-L73 produces this result instead:
class ListCommand < LibraryCommand
include YARD::Templates::Helpers::BaseHelper
# ...
end
This is probably better than the current behaviour, but still not identical to the original include.
With that change (after #90), it goes from 209 errors to 175 in sord_examples.
Here's a related test:
it 'returns fully qualified classes' do
YARD.parse_string(<<-RUBY)
class Alphabet
end
class Letters < Alphabet
end
class A < Alphabet::Letters
# @return [void]
def x; end
end
RUBY
expect(subject.generate.strip).to eq fix_heredoc(<<-RUBY)
# typed: strong
class Alphabet
end
class Letters < Alphabet
end
class A < Alphabet::Letters
sig { void }
def x; end
end
RUBY
end