rdoc 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
data/lib/rdoc/stats.rb CHANGED
@@ -1,484 +1,486 @@
1
1
  # frozen_string_literal: true
2
- ##
3
- # RDoc statistics collector which prints a summary and report of a project's
4
- # documentation totals.
2
+ module RDoc
3
+ ##
4
+ # RDoc statistics collector which prints a summary and report of a project's
5
+ # documentation totals.
5
6
 
6
- class RDoc::Stats
7
+ class Stats
7
8
 
8
- include RDoc::Text
9
+ include Text
9
10
 
10
- ##
11
- # Display order for item types in the coverage report
11
+ ##
12
+ # Display order for item types in the coverage report
12
13
 
13
- TYPE_ORDER = %w[Class Module Constant Attribute Method].freeze
14
+ TYPE_ORDER = %w[Class Module Constant Attribute Method].freeze
14
15
 
15
- ##
16
- # Message displayed when all items are documented
16
+ ##
17
+ # Message displayed when all items are documented
17
18
 
18
- GREAT_JOB_MESSAGE = <<~MSG
19
+ GREAT_JOB_MESSAGE = <<~MSG
19
20
  100% documentation!
20
21
  Great Job!
21
22
  MSG
22
23
 
23
- ##
24
- # Output level for the coverage report
24
+ ##
25
+ # Output level for the coverage report
25
26
 
26
- attr_reader :coverage_level
27
+ attr_reader :coverage_level
27
28
 
28
- ##
29
- # Count of files parsed during parsing
29
+ ##
30
+ # Count of files parsed during parsing
30
31
 
31
- attr_reader :files_so_far
32
+ attr_reader :files_so_far
32
33
 
33
- ##
34
- # Total number of files found
34
+ ##
35
+ # Total number of files found
35
36
 
36
- attr_reader :num_files
37
+ attr_reader :num_files
37
38
 
38
- ##
39
- # Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1
40
- # which will create an RDoc::Stats::Normal outputter.
41
-
42
- def initialize(store, num_files, verbosity = 1)
43
- @num_files = num_files
44
- @store = store
45
-
46
- @coverage_level = 0
47
- @doc_items = nil
48
- @files_so_far = 0
49
- @fully_documented = false
50
- @num_params = 0
51
- @percent_doc = nil
52
- @start = Time.now
53
- @undoc_params = 0
54
-
55
- self.verbosity = verbosity
56
- end
39
+ ##
40
+ # Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1
41
+ # which will create an RDoc::Stats::Normal outputter.
57
42
 
58
- ##
59
- # Sets the verbosity level, rebuilding the display outputter.
60
-
61
- def verbosity=(verbosity)
62
- @display = case verbosity
63
- when 0 then Quiet.new @num_files
64
- when 1 then Normal.new @num_files
65
- else Verbose.new @num_files
66
- end
67
- end
43
+ def initialize(store, num_files, verbosity = 1)
44
+ @num_files = num_files
45
+ @store = store
68
46
 
69
- ##
70
- # Records the parsing of an alias +as+.
47
+ @coverage_level = 0
48
+ @doc_items = nil
49
+ @files_so_far = 0
50
+ @fully_documented = false
51
+ @num_params = 0
52
+ @percent_doc = nil
53
+ @start = Time.now
54
+ @undoc_params = 0
71
55
 
72
- def add_alias(as)
73
- @display.print_alias as
74
- end
56
+ self.verbosity = verbosity
57
+ end
75
58
 
76
- ##
77
- # Records the parsing of an attribute +attribute+
59
+ ##
60
+ # Sets the verbosity level, rebuilding the display outputter.
78
61
 
79
- def add_attribute(attribute)
80
- @display.print_attribute attribute
81
- end
62
+ def verbosity=(verbosity)
63
+ @display = case verbosity
64
+ when 0 then Quiet.new @num_files
65
+ when 1 then Normal.new @num_files
66
+ else Verbose.new @num_files
67
+ end
68
+ end
82
69
 
83
- ##
84
- # Records the parsing of a class +klass+
70
+ ##
71
+ # Records the parsing of an alias +as+.
85
72
 
86
- def add_class(klass)
87
- @display.print_class klass
88
- end
73
+ def add_alias(as)
74
+ @display.print_alias as
75
+ end
89
76
 
90
- ##
91
- # Records the parsing of +constant+
77
+ ##
78
+ # Records the parsing of an attribute +attribute+
92
79
 
93
- def add_constant(constant)
94
- @display.print_constant constant
95
- end
80
+ def add_attribute(attribute)
81
+ @display.print_attribute attribute
82
+ end
96
83
 
97
- ##
98
- # Records the parsing of +file+
84
+ ##
85
+ # Records the parsing of a class +klass+
99
86
 
100
- def add_file(file)
101
- @files_so_far += 1
102
- @display.print_file @files_so_far, file
103
- end
87
+ def add_class(klass)
88
+ @display.print_class klass
89
+ end
104
90
 
105
- ##
106
- # Records the parsing of +method+
91
+ ##
92
+ # Records the parsing of +constant+
107
93
 
108
- def add_method(method)
109
- @display.print_method method
110
- end
94
+ def add_constant(constant)
95
+ @display.print_constant constant
96
+ end
111
97
 
112
- ##
113
- # Records the parsing of a module +mod+
98
+ ##
99
+ # Records the parsing of +file+
114
100
 
115
- def add_module(mod)
116
- @display.print_module mod
117
- end
101
+ def add_file(file)
102
+ @files_so_far += 1
103
+ @display.print_file @files_so_far, file
104
+ end
118
105
 
119
- ##
120
- # Call this to mark the beginning of parsing for display purposes
106
+ ##
107
+ # Records the parsing of +method+
121
108
 
122
- def begin_adding
123
- @display.begin_adding
124
- end
109
+ def add_method(method)
110
+ @display.print_method method
111
+ end
125
112
 
126
- ##
127
- # Calculates documentation totals and percentages for classes, modules,
128
- # constants, attributes and methods.
113
+ ##
114
+ # Records the parsing of a module +mod+
129
115
 
130
- def calculate
131
- return if @doc_items
116
+ def add_module(mod)
117
+ @display.print_module mod
118
+ end
132
119
 
133
- ucm = @store.unique_classes_and_modules
120
+ ##
121
+ # Call this to mark the beginning of parsing for display purposes
134
122
 
135
- classes = @store.unique_classes.reject { |cm| cm.full_name == 'Object' }
123
+ def begin_adding
124
+ @display.begin_adding
125
+ end
136
126
 
137
- constants = []
138
- ucm.each { |cm| constants.concat cm.constants }
127
+ ##
128
+ # Calculates documentation totals and percentages for classes, modules,
129
+ # constants, attributes and methods.
139
130
 
140
- methods = []
141
- ucm.each { |cm| methods.concat cm.method_list }
131
+ def calculate
132
+ return if @doc_items
142
133
 
143
- attributes = []
144
- ucm.each { |cm| attributes.concat cm.attributes }
134
+ ucm = @store.unique_classes_and_modules
145
135
 
146
- @num_attributes, @undoc_attributes = doc_stats attributes
147
- @num_classes, @undoc_classes = doc_stats classes
148
- @num_constants, @undoc_constants = doc_stats constants
149
- @num_methods, @undoc_methods = doc_stats methods
150
- @num_modules, @undoc_modules = doc_stats @store.unique_modules
136
+ classes = @store.unique_classes.reject { |cm| cm.full_name == 'Object' }
151
137
 
152
- @num_items =
153
- @num_attributes +
154
- @num_classes +
155
- @num_constants +
156
- @num_methods +
157
- @num_modules +
158
- @num_params
138
+ constants = []
139
+ ucm.each { |cm| constants.concat cm.constants }
159
140
 
160
- @undoc_items =
161
- @undoc_attributes +
162
- @undoc_classes +
163
- @undoc_constants +
164
- @undoc_methods +
165
- @undoc_modules +
166
- @undoc_params
141
+ methods = []
142
+ ucm.each { |cm| methods.concat cm.method_list }
167
143
 
168
- @doc_items = @num_items - @undoc_items
169
- end
144
+ attributes = []
145
+ ucm.each { |cm| attributes.concat cm.attributes }
170
146
 
171
- ##
172
- # Sets coverage report level. Accepted values are:
173
- #
174
- # false or nil:: No report
175
- # 0:: Classes, modules, constants, attributes, methods
176
- # 1:: Level 0 + method parameters
147
+ @num_attributes, @undoc_attributes = doc_stats attributes
148
+ @num_classes, @undoc_classes = doc_stats classes
149
+ @num_constants, @undoc_constants = doc_stats constants
150
+ @num_methods, @undoc_methods = doc_stats methods
151
+ @num_modules, @undoc_modules = doc_stats @store.unique_modules
177
152
 
178
- def coverage_level=(level)
179
- level = -1 unless level
153
+ @num_items =
154
+ @num_attributes +
155
+ @num_classes +
156
+ @num_constants +
157
+ @num_methods +
158
+ @num_modules +
159
+ @num_params
180
160
 
181
- @coverage_level = level
182
- end
161
+ @undoc_items =
162
+ @undoc_attributes +
163
+ @undoc_classes +
164
+ @undoc_constants +
165
+ @undoc_methods +
166
+ @undoc_modules +
167
+ @undoc_params
183
168
 
184
- ##
185
- # Returns the length and number of undocumented items in +collection+.
169
+ @doc_items = @num_items - @undoc_items
170
+ end
186
171
 
187
- def doc_stats(collection)
188
- visible = collection.select { |item| item.display? }
189
- [visible.length, visible.count { |item| not item.documented? }]
190
- end
172
+ ##
173
+ # Sets coverage report level. Accepted values are:
174
+ #
175
+ # false or nil:: No report
176
+ # 0:: Classes, modules, constants, attributes, methods
177
+ # 1:: Level 0 + method parameters
191
178
 
192
- ##
193
- # Call this to mark the end of parsing for display purposes
179
+ def coverage_level=(level)
180
+ level = -1 unless level
194
181
 
195
- def done_adding
196
- @display.done_adding
197
- end
182
+ @coverage_level = level
183
+ end
198
184
 
199
- ##
200
- # The documentation status of this project. +true+ when 100%, +false+ when
201
- # less than 100% and +nil+ when unknown.
202
- #
203
- # Set by calling #calculate
185
+ ##
186
+ # Returns the length and number of undocumented items in +collection+.
204
187
 
205
- def fully_documented?
206
- @fully_documented
207
- end
188
+ def doc_stats(collection)
189
+ visible = collection.select { |item| item.display? }
190
+ [visible.length, visible.count { |item| not item.documented? }]
191
+ end
208
192
 
209
- ##
210
- # Calculates the percentage of items documented.
193
+ ##
194
+ # Call this to mark the end of parsing for display purposes
211
195
 
212
- def percent_doc
213
- return @percent_doc if @percent_doc
196
+ def done_adding
197
+ @display.done_adding
198
+ end
214
199
 
215
- @fully_documented = (@num_items - @doc_items) == 0
200
+ ##
201
+ # The documentation status of this project. +true+ when 100%, +false+ when
202
+ # less than 100% and +nil+ when unknown.
203
+ #
204
+ # Set by calling #calculate
216
205
 
217
- @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
218
- @percent_doc ||= 0
206
+ def fully_documented?
207
+ @fully_documented
208
+ end
219
209
 
220
- @percent_doc
221
- end
210
+ ##
211
+ # Calculates the percentage of items documented.
222
212
 
223
- ##
224
- # Returns a report on which items are not documented
213
+ def percent_doc
214
+ return @percent_doc if @percent_doc
225
215
 
226
- def report
227
- if @coverage_level > 0 then
228
- extend RDoc::Text
229
- end
216
+ @fully_documented = (@num_items - @doc_items) == 0
230
217
 
231
- if @coverage_level.zero? then
232
- calculate
218
+ @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
219
+ @percent_doc ||= 0
233
220
 
234
- return GREAT_JOB_MESSAGE if @num_items == @doc_items
221
+ @percent_doc
235
222
  end
236
223
 
237
- items, empty_classes = collect_undocumented_items
224
+ ##
225
+ # Returns a report on which items are not documented
238
226
 
239
- if @coverage_level > 0 then
240
- calculate
227
+ def report
228
+ if @coverage_level > 0
229
+ extend Text
230
+ end
241
231
 
242
- return GREAT_JOB_MESSAGE if @num_items == @doc_items
243
- end
232
+ if @coverage_level.zero?
233
+ calculate
244
234
 
245
- report = +""
246
- report << "The following items are not documented:\n\n"
235
+ return GREAT_JOB_MESSAGE if @num_items == @doc_items
236
+ end
247
237
 
248
- # Referenced-but-empty classes
249
- empty_classes.each do |cm|
250
- report << "#{cm.full_name} is referenced but empty.\n"
251
- report << "It probably came from another project. I'm sorry I'm holding it against you.\n\n"
252
- end
238
+ items, empty_classes = collect_undocumented_items
253
239
 
254
- # Group items by file, then by type
255
- by_file = items.group_by { |item| item[:file] }
240
+ if @coverage_level > 0
241
+ calculate
256
242
 
257
- by_file.sort_by { |file, _| file }.each do |file, file_items|
258
- report << "#{file}:\n"
243
+ return GREAT_JOB_MESSAGE if @num_items == @doc_items
244
+ end
259
245
 
260
- by_type = file_items.group_by { |item| item[:type] }
246
+ report = +""
247
+ report << "The following items are not documented:\n\n"
261
248
 
262
- TYPE_ORDER.each do |type|
263
- next unless by_type[type]
249
+ # Referenced-but-empty classes
250
+ empty_classes.each do |cm|
251
+ report << "#{cm.full_name} is referenced but empty.\n"
252
+ report << "It probably came from another project. I'm sorry I'm holding it against you.\n\n"
253
+ end
264
254
 
265
- report << " #{type}:\n"
255
+ # Group items by file, then by type
256
+ by_file = items.group_by { |item| item[:file] }
266
257
 
267
- sorted = by_type[type].sort_by { |item| [item[:line] || 0, item[:name]] }
268
- name_width = sorted.reduce(0) { |max, item| item[:line] && item[:name].length > max ? item[:name].length : max }
258
+ by_file.sort_by { |file, _| file }.each do |file, file_items|
259
+ report << "#{file}:\n"
269
260
 
270
- sorted.each do |item|
271
- if item[:line]
272
- report << " %-*s %s:%d\n" % [name_width, item[:name], item[:file], item[:line]]
273
- else
274
- report << " #{item[:name]}\n"
275
- end
261
+ by_type = file_items.group_by { |item| item[:type] }
276
262
 
277
- if item[:undoc_params]
278
- report << " Undocumented params: #{item[:undoc_params].join(', ')}\n"
263
+ TYPE_ORDER.each do |type|
264
+ next unless by_type[type]
265
+
266
+ report << " #{type}:\n"
267
+
268
+ sorted = by_type[type].sort_by { |item| [item[:line] || 0, item[:name]] }
269
+ name_width = sorted.reduce(0) { |max, item| item[:line] && item[:name].length > max ? item[:name].length : max }
270
+
271
+ sorted.each do |item|
272
+ if item[:line]
273
+ report << " %-*s %s:%d\n" % [name_width, item[:name], item[:file], item[:line]]
274
+ else
275
+ report << " #{item[:name]}\n"
276
+ end
277
+
278
+ if item[:undoc_params]
279
+ report << " Undocumented params: #{item[:undoc_params].join(', ')}\n"
280
+ end
279
281
  end
280
282
  end
283
+
284
+ report << "\n"
281
285
  end
282
286
 
283
- report << "\n"
287
+ report
284
288
  end
285
289
 
286
- report
287
- end
290
+ ##
291
+ # Collects all undocumented items across all classes and modules.
292
+ # Returns [items, empty_classes] where items is an Array of Hashes
293
+ # with keys :type, :name, :file, :line, and empty_classes is an
294
+ # Array of ClassModule objects that are referenced but have no files.
288
295
 
289
- ##
290
- # Collects all undocumented items across all classes and modules.
291
- # Returns [items, empty_classes] where items is an Array of Hashes
292
- # with keys :type, :name, :file, :line, and empty_classes is an
293
- # Array of ClassModule objects that are referenced but have no files.
296
+ def collect_undocumented_items
297
+ empty_classes = []
298
+ items = []
294
299
 
295
- def collect_undocumented_items
296
- empty_classes = []
297
- items = []
300
+ @store.unique_classes_and_modules.each do |class_module|
301
+ next unless class_module.display?
298
302
 
299
- @store.unique_classes_and_modules.each do |class_module|
300
- next unless class_module.display?
303
+ if class_module.in_files.empty?
304
+ empty_classes << class_module
305
+ next
306
+ end
301
307
 
302
- if class_module.in_files.empty?
303
- empty_classes << class_module
304
- next
305
- end
308
+ unless class_module.documented? || class_module.full_name == 'Object'
309
+ collect_undocumented_class_module(class_module, items)
310
+ end
306
311
 
307
- unless class_module.documented? || class_module.full_name == 'Object'
308
- collect_undocumented_class_module(class_module, items)
312
+ collect_undocumented_constants(class_module, items)
313
+ collect_undocumented_attributes(class_module, items)
314
+ collect_undocumented_methods(class_module, items)
309
315
  end
310
316
 
311
- collect_undocumented_constants(class_module, items)
312
- collect_undocumented_attributes(class_module, items)
313
- collect_undocumented_methods(class_module, items)
317
+ [items, empty_classes]
314
318
  end
315
319
 
316
- [items, empty_classes]
317
- end
318
-
319
- ##
320
- # Collects undocumented classes or modules from +class_module+ into +items+.
321
- # Reopened classes/modules are reported in every file they appear in.
322
-
323
- def collect_undocumented_class_module(class_module, items)
324
- class_module.in_files.map(&:full_name).uniq.each do |file|
325
- items << {
326
- type: class_module.type.capitalize,
327
- name: class_module.full_name,
328
- file: file,
329
- line: nil,
330
- }
320
+ ##
321
+ # Collects undocumented classes or modules from +class_module+ into +items+.
322
+ # Reopened classes/modules are reported in every file they appear in.
323
+
324
+ def collect_undocumented_class_module(class_module, items)
325
+ class_module.in_files.map(&:full_name).uniq.each do |file|
326
+ items << {
327
+ type: class_module.type.capitalize,
328
+ name: class_module.full_name,
329
+ file: file,
330
+ line: nil,
331
+ }
332
+ end
331
333
  end
332
- end
333
334
 
334
- ##
335
- # Collects undocumented constants from +class_module+ into +items+.
336
-
337
- def collect_undocumented_constants(class_module, items)
338
- class_module.constants.each do |constant|
339
- next unless constant.display?
340
- next if constant.documented? || constant.is_alias_for
341
-
342
- file = constant.file&.full_name
343
- next unless file
344
-
345
- items << {
346
- type: "Constant",
347
- name: constant.full_name,
348
- file: file,
349
- line: constant.line,
350
- }
335
+ ##
336
+ # Collects undocumented constants from +class_module+ into +items+.
337
+
338
+ def collect_undocumented_constants(class_module, items)
339
+ class_module.constants.each do |constant|
340
+ next unless constant.display?
341
+ next if constant.documented? || constant.is_alias_for
342
+
343
+ file = constant.file&.full_name
344
+ next unless file
345
+
346
+ items << {
347
+ type: "Constant",
348
+ name: constant.full_name,
349
+ file: file,
350
+ line: constant.line,
351
+ }
352
+ end
351
353
  end
352
- end
353
354
 
354
- ##
355
- # Collects undocumented attributes from +class_module+ into +items+.
356
-
357
- def collect_undocumented_attributes(class_module, items)
358
- class_module.attributes.each do |attr|
359
- next unless attr.display?
360
- next if attr.documented?
361
-
362
- file = attr.file&.full_name
363
- next unless file
364
-
365
- scope = attr.singleton ? "." : "#"
366
- items << {
367
- type: "Attribute",
368
- name: "#{class_module.full_name}#{scope}#{attr.name}",
369
- file: file,
370
- line: attr.line,
371
- }
355
+ ##
356
+ # Collects undocumented attributes from +class_module+ into +items+.
357
+
358
+ def collect_undocumented_attributes(class_module, items)
359
+ class_module.attributes.each do |attr|
360
+ next unless attr.display?
361
+ next if attr.documented?
362
+
363
+ file = attr.file&.full_name
364
+ next unless file
365
+
366
+ scope = attr.singleton ? "." : "#"
367
+ items << {
368
+ type: "Attribute",
369
+ name: "#{class_module.full_name}#{scope}#{attr.name}",
370
+ file: file,
371
+ line: attr.line,
372
+ }
373
+ end
372
374
  end
373
- end
374
375
 
375
- ##
376
- # Collects undocumented methods from +class_module+ into +items+.
377
- # At coverage level > 0, also counts undocumented parameters.
376
+ ##
377
+ # Collects undocumented methods from +class_module+ into +items+.
378
+ # At coverage level > 0, also counts undocumented parameters.
378
379
 
379
- def collect_undocumented_methods(class_module, items)
380
- class_module.each_method do |method|
381
- next unless method.display?
382
- next if method.documented? && @coverage_level.zero?
380
+ def collect_undocumented_methods(class_module, items)
381
+ class_module.each_method do |method|
382
+ next unless method.display?
383
+ next if method.documented? && @coverage_level.zero?
383
384
 
384
- undoc_param_names = nil
385
+ undoc_param_names = nil
385
386
 
386
- if @coverage_level > 0
387
- params, undoc = undoc_params method
388
- @num_params += params
387
+ if @coverage_level > 0
388
+ params, undoc = undoc_params method
389
+ @num_params += params
389
390
 
390
- unless undoc.empty?
391
- @undoc_params += undoc.length
392
- undoc_param_names = undoc
391
+ unless undoc.empty?
392
+ @undoc_params += undoc.length
393
+ undoc_param_names = undoc
394
+ end
393
395
  end
394
- end
395
396
 
396
- next if method.documented? && !undoc_param_names
397
+ next if method.documented? && !undoc_param_names
397
398
 
398
- file = method.file&.full_name
399
- next unless file
399
+ file = method.file&.full_name
400
+ next unless file
400
401
 
401
- scope = method.singleton ? "." : "#"
402
- item = {
403
- type: "Method",
404
- name: "#{class_module.full_name}#{scope}#{method.name}",
405
- file: file,
406
- line: method.line,
407
- }
408
- item[:undoc_params] = undoc_param_names if undoc_param_names
402
+ scope = method.singleton ? "." : "#"
403
+ item = {
404
+ type: "Method",
405
+ name: "#{class_module.full_name}#{scope}#{method.name}",
406
+ file: file,
407
+ line: method.line,
408
+ }
409
+ item[:undoc_params] = undoc_param_names if undoc_param_names
409
410
 
410
- items << item
411
+ items << item
412
+ end
411
413
  end
412
- end
413
414
 
414
- ##
415
- # Returns a summary of the collected statistics.
416
-
417
- def summary
418
- calculate
419
-
420
- num_width = [@num_files, @num_items].max.to_s.length
421
- undoc_width = [
422
- @undoc_attributes,
423
- @undoc_classes,
424
- @undoc_constants,
425
- @undoc_items,
426
- @undoc_methods,
427
- @undoc_modules,
428
- @undoc_params,
429
- ].max.to_s.length
430
-
431
- report = +""
432
-
433
- report << "Files: %*d\n" % [num_width, @num_files]
434
- report << "\n"
435
- report << "Classes: %*d (%*d undocumented)\n" % [
436
- num_width, @num_classes, undoc_width, @undoc_classes]
437
- report << "Modules: %*d (%*d undocumented)\n" % [
438
- num_width, @num_modules, undoc_width, @undoc_modules]
439
- report << "Constants: %*d (%*d undocumented)\n" % [
440
- num_width, @num_constants, undoc_width, @undoc_constants]
441
- report << "Attributes: %*d (%*d undocumented)\n" % [
442
- num_width, @num_attributes, undoc_width, @undoc_attributes]
443
- report << "Methods: %*d (%*d undocumented)\n" % [
444
- num_width, @num_methods, undoc_width, @undoc_methods]
445
- report << "Parameters: %*d (%*d undocumented)\n" % [
446
- num_width, @num_params, undoc_width, @undoc_params] if
447
- @coverage_level > 0
448
- report << "\n"
449
- report << "Total: %*d (%*d undocumented)\n" % [
450
- num_width, @num_items, undoc_width, @undoc_items]
451
- report << "%6.2f%% documented\n" % percent_doc
452
- report << "\n"
453
- report << "Elapsed: %0.1fs\n" % (Time.now - @start)
454
-
455
- report
456
- end
415
+ ##
416
+ # Returns a summary of the collected statistics.
457
417
 
458
- ##
459
- # Determines which parameters in +method+ were not documented. Returns a
460
- # total parameter count and an Array of undocumented methods.
418
+ def summary
419
+ calculate
461
420
 
462
- def undoc_params(method)
463
- @formatter ||= RDoc::Markup::ToTtOnly.new
421
+ num_width = [@num_files, @num_items].max.to_s.length
422
+ undoc_width = [
423
+ @undoc_attributes,
424
+ @undoc_classes,
425
+ @undoc_constants,
426
+ @undoc_items,
427
+ @undoc_methods,
428
+ @undoc_modules,
429
+ @undoc_params,
430
+ ].max.to_s.length
464
431
 
465
- params = method.param_list
432
+ report = +""
466
433
 
467
- params = params.map { |param| param.gsub(/^\*\*?/, '') }
434
+ report << "Files: %*d\n" % [num_width, @num_files]
435
+ report << "\n"
436
+ report << "Classes: %*d (%*d undocumented)\n" % [
437
+ num_width, @num_classes, undoc_width, @undoc_classes]
438
+ report << "Modules: %*d (%*d undocumented)\n" % [
439
+ num_width, @num_modules, undoc_width, @undoc_modules]
440
+ report << "Constants: %*d (%*d undocumented)\n" % [
441
+ num_width, @num_constants, undoc_width, @undoc_constants]
442
+ report << "Attributes: %*d (%*d undocumented)\n" % [
443
+ num_width, @num_attributes, undoc_width, @undoc_attributes]
444
+ report << "Methods: %*d (%*d undocumented)\n" % [
445
+ num_width, @num_methods, undoc_width, @undoc_methods]
446
+ report << "Parameters: %*d (%*d undocumented)\n" % [
447
+ num_width, @num_params, undoc_width, @undoc_params] if
448
+ @coverage_level > 0
449
+ report << "\n"
450
+ report << "Total: %*d (%*d undocumented)\n" % [
451
+ num_width, @num_items, undoc_width, @undoc_items]
452
+ report << "%6.2f%% documented\n" % percent_doc
453
+ report << "\n"
454
+ report << "Elapsed: %0.1fs\n" % (Time.now - @start)
468
455
 
469
- return 0, [] if params.empty?
456
+ report
457
+ end
470
458
 
471
- document = parse method.comment
459
+ ##
460
+ # Determines which parameters in +method+ were not documented. Returns a
461
+ # total parameter count and an Array of undocumented methods.
472
462
 
473
- tts = document.accept @formatter
463
+ def undoc_params(method)
464
+ @formatter ||= Markup::ToTtOnly.new
474
465
 
475
- undoc = params - tts
466
+ params = method.param_list
476
467
 
477
- [params.length, undoc]
478
- end
468
+ params = params.map { |param| param.gsub(/^\*\*?/, '') }
479
469
 
480
- autoload :Quiet, "#{__dir__}/stats/quiet"
481
- autoload :Normal, "#{__dir__}/stats/normal"
482
- autoload :Verbose, "#{__dir__}/stats/verbose"
470
+ return 0, [] if params.empty?
483
471
 
472
+ document = parse method.comment
473
+
474
+ tts = document.accept @formatter
475
+
476
+ undoc = params - tts
477
+
478
+ [params.length, undoc]
479
+ end
480
+
481
+ autoload :Quiet, "#{__dir__}/stats/quiet"
482
+ autoload :Normal, "#{__dir__}/stats/normal"
483
+ autoload :Verbose, "#{__dir__}/stats/verbose"
484
+
485
+ end
484
486
  end