Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stats update - none stable sort #1123

Merged
merged 1 commit into from
Nov 18, 2017
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
5 changes: 3 additions & 2 deletions lib/yard/cli/stats.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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