Skip to content
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
8 changes: 5 additions & 3 deletions lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,13 @@ def update_aliases
cm_alias = cm.dup
cm_alias.name = const.name

# Don't move top-level aliases under Object, they look ugly there
unless RDoc::TopLevel === cm_alias.parent then
if full_name == 'Object'
# Don't move top-level aliases under Object, they look ugly there
cm_alias.parent = top_level
else
cm_alias.parent = self
cm_alias.full_name = nil # force update for new parent
end
cm_alias.full_name = nil # force update for new parent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a ClassModule/CodeObject level test to prevent regression too?


cm_alias.aliases.clear
cm_alias.is_alias_for = cm
Expand Down
4 changes: 3 additions & 1 deletion lib/rdoc/generator/darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ def generate_class_files

current = nil

@classes.each do |klass|
# Document files are generated only for non-alias classes/modules
@classes.reject(&:is_alias_for).each do |klass|

current = klass

generate_class klass, template_file
Expand Down
13 changes: 13 additions & 0 deletions test/rdoc/generator/aliki_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def setup
@top_level.parser = RDoc::Parser::Ruby
@klass = @top_level.add_class RDoc::NormalClass, 'Klass'

@alias_constant = RDoc::Constant.new 'A', nil, ''
@alias_constant.record_location @top_level

@top_level.add_constant @alias_constant

@klass.add_module_alias @klass, @klass.name, @alias_constant, @top_level

@meth = RDoc::AnyMethod.new nil, 'method'
@meth_with_html_tag_yield = RDoc::AnyMethod.new nil, 'method_with_html_tag_yield'
@meth_with_html_tag_yield.block_params = '%<<script>alert("atui")</script>>, yield_arg'
Expand All @@ -57,6 +64,12 @@ def test_inheritance_and_template_dir
assert_match %r{/template/aliki\z}, @g.template_dir.to_s
end

def test_aliased_classes_full_name
@g.generate

assert_equal(%w[Klass Klass::A Object], @g.classes.map(&:full_name).sort)
end

def test_write_style_sheet_copies_css_and_js_only
@g.generate

Expand Down
8 changes: 5 additions & 3 deletions test/rdoc/generator/darkfish_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,13 @@ def test_install_rdoc_static_file_missing
def test_setup
@g.setup

assert_equal [@klass_alias, @ignored, @klass, @object],
assert_equal %w[Ignored Klass Klass::A Object],
[@ignored, @klass, @klass_alias, @object].map(&:full_name)
assert_equal [@ignored, @klass, @klass_alias, @object],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add one of these tests to Aliki’s generator test as well?

@g.classes.sort_by { |klass| klass.full_name }
assert_equal [@top_level], @g.files
assert_equal [@meth, @meth, @meth_bang, @meth_bang, @meth_with_html_tag_yield, @meth_with_html_tag_yield], @g.methods
assert_equal [@klass_alias, @klass, @object], @g.modsort
assert_equal [@klass, @klass_alias, @object], @g.modsort
end

def test_template_for
Expand Down Expand Up @@ -338,7 +340,7 @@ def test_generated_method_with_html_tag_yield

@g.generate

path = File.join @tmpdir, 'A.html'
path = File.join @tmpdir, 'Klass.html'

f = open(path)
internal_file = f.read
Expand Down