Skip to content

Commit

Permalink
Merge pull request #96 from connorshea/better-superclass
Browse files Browse the repository at this point in the history
Return fully-qualified superclasses
  • Loading branch information
AaronC81 authored Jul 20, 2019
2 parents d2f7120 + da8c0e5 commit 39fb085
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
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

0 comments on commit 39fb085

Please sign in to comment.