Skip to content

Commit fd3cfbb

Browse files
committed
Use dynamic widths in the rdoc summary
1 parent 0e147ef commit fd3cfbb

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ otherwise noted.
1010
Katagiri.
1111
* Generator list in --help is no longer static. Generator description comes
1212
from the generator's DESCRIPTION constant.
13+
* Documentation summary is now displayed with dynamic width.
1314
* Bug fixes
1415
* Strip encoding comment from input to avoid overriding file comment.
1516
RubyForge Bug #22113 by James Gray.

lib/rdoc/stats.rb

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,36 @@ def report
258258
def summary
259259
calculate
260260

261+
num_width = [@num_files, @num_items].max.to_s.length
262+
nodoc_width = [
263+
@undoc_attributes,
264+
@undoc_classes,
265+
@undoc_constants,
266+
@undoc_items,
267+
@undoc_methods,
268+
@undoc_modules,
269+
].max.to_s.length
270+
261271
report = []
262-
report << 'Files: %5d' % @num_files
272+
report << 'Files: %*d' % [num_width, @num_files]
273+
263274
report << nil
264-
report << 'Classes: %5d (%5d undocumented)' % [@num_classes,
265-
@undoc_classes]
266-
report << 'Modules: %5d (%5d undocumented)' % [@num_modules,
267-
@undoc_modules]
268-
report << 'Constants: %5d (%5d undocumented)' % [@num_constants,
269-
@undoc_constants]
270-
report << 'Attributes: %5d (%5d undocumented)' % [@num_attributes,
271-
@undoc_attributes]
272-
report << 'Methods: %5d (%5d undocumented)' % [@num_methods,
273-
@undoc_methods]
275+
276+
report << 'Classes: %*d (%*d undocumented)' % [
277+
num_width, @num_classes, nodoc_width, @undoc_classes]
278+
report << 'Modules: %*d (%*d undocumented)' % [
279+
num_width, @num_modules, nodoc_width, @undoc_modules]
280+
report << 'Constants: %*d (%*d undocumented)' % [
281+
num_width, @num_constants, nodoc_width, @undoc_constants]
282+
report << 'Attributes: %*d (%*d undocumented)' % [
283+
num_width, @num_attributes, nodoc_width, @undoc_attributes]
284+
report << 'Methods: %*d (%*d undocumented)' % [
285+
num_width, @num_methods, nodoc_width, @undoc_methods]
286+
274287
report << nil
275-
report << 'Total: %5d (%5d undocumented)' % [@num_items,
276-
@undoc_items]
288+
289+
report << 'Total: %*d (%*d undocumented)' % [
290+
num_width, @num_items, nodoc_width, @undoc_items]
277291

278292
report << '%6.2f%% documented' % @percent_doc if @percent_doc
279293
report << nil

0 commit comments

Comments
 (0)