Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return fully-qualified superclasses #96

Merged
merged 1 commit into from
Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/sord/rbi_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ def add_methods(item)
def add_namespace(item)
count_namespace

superclass =
item.type == :class && item.superclass.to_s != "Object" \
? item.superclass.name.to_s : nil
superclass = nil
superclass = item.superclass.path.to_s if item.type == :class && item.superclass.to_s != "Object"

parent = @current_object
@current_object = item.type == :class \
Expand Down
29 changes: 29 additions & 0 deletions spec/rbi_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,33 @@ def x(array, hash, range, set, enumerator, enumerable); end
end
RUBY
end

it 'returns fully qualified superclasses' 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
end