Skip to content

Commit 4e58ee5

Browse files
committed
Fix class/module alias document having wrong name
Stop aliased class/module document file overwrite original one. Fix aliasing-to-toplevel check.
1 parent 85ac545 commit 4e58ee5

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

lib/rdoc/code_object/class_module.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,13 @@ def update_aliases
807807
cm_alias = cm.dup
808808
cm_alias.name = const.name
809809

810-
# Don't move top-level aliases under Object, they look ugly there
811-
unless RDoc::TopLevel === cm_alias.parent then
810+
if full_name == 'Object'
811+
# Don't move top-level aliases under Object, they look ugly there
812+
cm_alias.parent = top_level
813+
else
812814
cm_alias.parent = self
813-
cm_alias.full_name = nil # force update for new parent
814815
end
816+
cm_alias.full_name = nil # force update for new parent
815817

816818
cm_alias.aliases.clear
817819
cm_alias.is_alias_for = cm

lib/rdoc/generator/darkfish.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ def generate_class(klass, template_file = nil)
322322

323323
debug_msg " working on %s (%s)" % [klass.full_name, klass.path]
324324
out_file = @outputdir + klass.path
325+
326+
# If klass is an alias, out_file is already generated by the original class/module
327+
return if klass.is_alias_for
328+
325329
rel_prefix = @outputdir.relative_path_from out_file.dirname
326330
search_index_rel_prefix = rel_prefix
327331
search_index_rel_prefix += @asset_rel_path if @file_output

test/rdoc/generator/darkfish_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,13 @@ def test_install_rdoc_static_file_missing
297297
def test_setup
298298
@g.setup
299299

300-
assert_equal [@klass_alias, @ignored, @klass, @object],
300+
assert_equal %w[Ignored Klass Klass::A Object],
301+
[@ignored, @klass, @klass_alias, @object].map(&:full_name)
302+
assert_equal [@ignored, @klass, @klass_alias, @object],
301303
@g.classes.sort_by { |klass| klass.full_name }
302304
assert_equal [@top_level], @g.files
303305
assert_equal [@meth, @meth, @meth_bang, @meth_bang, @meth_with_html_tag_yield, @meth_with_html_tag_yield], @g.methods
304-
assert_equal [@klass_alias, @klass, @object], @g.modsort
306+
assert_equal [@klass, @klass_alias, @object], @g.modsort
305307
end
306308

307309
def test_template_for
@@ -338,7 +340,7 @@ def test_generated_method_with_html_tag_yield
338340

339341
@g.generate
340342

341-
path = File.join @tmpdir, 'A.html'
343+
path = File.join @tmpdir, 'Klass.html'
342344

343345
f = open(path)
344346
internal_file = f.read

0 commit comments

Comments
 (0)