Skip to content

Commit

Permalink
stats update - none stable sort
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Nov 18, 2017
1 parent c546a8a commit c373be6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/yard/cli/stats.rb
Expand Up @@ -79,8 +79,9 @@ def print_undocumented_objects
log.puts
log.puts "Undocumented Objects:"

objects = @undoc_list.sort_by {|o| o.file.to_s }
max = objects.sort_by {|o| o.path.length }.last.path.length
# array needed for sort due to unstable sort
objects = @undoc_list.sort_by {|o| [o.file.to_s, o.path] }
max = objects.max {|a, b| a.path.length <=> b.path.length }.path.length
if @compact
objects.each do |object|
log.puts("%-#{max}s (%s)" % [object.path,
Expand Down
8 changes: 4 additions & 4 deletions spec/cli/stats_spec.rb
Expand Up @@ -41,10 +41,10 @@ module B; end
Undocumented Objects:
(in file: (stdin))
B
A
A::CONST
A#foo
A::CONST
B
eof
end

Expand All @@ -69,10 +69,10 @@ def foo; end
expect(@output.string).to eq <<-eof
#{@main_stats}
Undocumented Objects:
B ((stdin):11)
A ((stdin):1)
A::CONST ((stdin):2)
A#foo ((stdin):4)
A::CONST ((stdin):2)
B ((stdin):11)
eof
end

Expand Down

0 comments on commit c373be6

Please sign in to comment.