Skip to content

Commit 174e243

Browse files
Merge pull request rubyapi#2440: Fix missing parents when superclass is namespaced
Preserve fully qualified superclass constants during documentation generation and cover the association with a parser-backed regression test.
2 parents c6b2081 + 617de4e commit 174e243

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎lib/rubyapi_rdoc_generator.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def superclass_for_doc(doc)
166166
if doc.superclass.is_a?(String)
167167
doc.superclass
168168
else
169-
doc.superclass.name
169+
doc.superclass.full_name
170170
end
171171
end
172172
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module Namespaced
4+
class Parent
5+
end
6+
7+
class Child < Parent
8+
end
9+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
class RubyAPIRDocGeneratorTest < ActiveSupport::TestCase
6+
test "namespaced superclass association" do
7+
document "namespaced_superclass.rb"
8+
object = RubyObject.find_by!(constant: "Namespaced::Child")
9+
10+
assert_equal "Namespaced::Parent", object.superclass_constant
11+
assert_equal RubyObject.find_by!(constant: "Namespaced::Parent"), object.superclass
12+
end
13+
14+
private
15+
16+
def document(filename)
17+
opts = RDoc::Options.load_options.tap do |options|
18+
options.generator = RubyAPIRDocGenerator
19+
options.generator_options = [ RubyRelease.new(version: "test", signatures: false) ]
20+
options.root = Rails.root.join("test/fixtures/doc").to_s
21+
options.files = [ Rails.root.join("test/fixtures/doc", filename).to_s ]
22+
options.op_dir = Rails.root.join("tmp/rdoc_test").to_s
23+
options.visibility = :private
24+
options.verbosity = 0
25+
options.template = ""
26+
end
27+
RDoc::RDoc.new.document(opts)
28+
end
29+
end

0 commit comments

Comments
 (0)