rdoc 3.1 → 6.3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (247) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +129 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +84 -81
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/{bin → exe}/rdoc +11 -2
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +1 -2
  19. data/lib/rdoc/anon_class.rb +3 -2
  20. data/lib/rdoc/any_method.rb +234 -40
  21. data/lib/rdoc/attr.rb +79 -11
  22. data/lib/rdoc/class_module.rb +443 -71
  23. data/lib/rdoc/code_object.rb +216 -20
  24. data/lib/rdoc/code_objects.rb +4 -21
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +110 -9
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +392 -172
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +83 -28
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +8 -3
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +507 -84
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +27 -74
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +8 -62
  42. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  43. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  57. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  58. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  59. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  60. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
  72. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
  73. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  74. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  75. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  76. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  77. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  78. data/lib/rdoc/generator/template/json_index/.document +1 -0
  79. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  80. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  81. data/lib/rdoc/generator.rb +24 -13
  82. data/lib/rdoc/ghost_method.rb +1 -2
  83. data/lib/rdoc/i18n/locale.rb +102 -0
  84. data/lib/rdoc/i18n/text.rb +126 -0
  85. data/lib/rdoc/i18n.rb +10 -0
  86. data/lib/rdoc/include.rb +5 -95
  87. data/lib/rdoc/known_classes.rb +5 -2
  88. data/lib/rdoc/markdown/entities.rb +2132 -0
  89. data/lib/rdoc/markdown/literals.kpeg +23 -0
  90. data/lib/rdoc/markdown/literals.rb +416 -0
  91. data/lib/rdoc/markdown.kpeg +1237 -0
  92. data/lib/rdoc/markdown.rb +16684 -0
  93. data/lib/rdoc/markup/attr_changer.rb +23 -0
  94. data/lib/rdoc/markup/attr_span.rb +36 -0
  95. data/lib/rdoc/markup/attribute_manager.rb +135 -62
  96. data/lib/rdoc/markup/attributes.rb +71 -0
  97. data/lib/rdoc/markup/blank_line.rb +1 -0
  98. data/lib/rdoc/markup/block_quote.rb +15 -0
  99. data/lib/rdoc/markup/document.rb +96 -9
  100. data/lib/rdoc/markup/formatter.rb +138 -25
  101. data/lib/rdoc/markup/hard_break.rb +32 -0
  102. data/lib/rdoc/markup/heading.rb +61 -2
  103. data/lib/rdoc/markup/include.rb +43 -0
  104. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  105. data/lib/rdoc/markup/list.rb +25 -4
  106. data/lib/rdoc/markup/list_item.rb +18 -4
  107. data/lib/rdoc/markup/paragraph.rb +15 -0
  108. data/lib/rdoc/markup/parser.rb +180 -88
  109. data/lib/rdoc/markup/pre_process.rb +183 -38
  110. data/lib/rdoc/markup/raw.rb +6 -5
  111. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  112. data/lib/rdoc/markup/rule.rb +1 -0
  113. data/lib/rdoc/markup/table.rb +47 -0
  114. data/lib/rdoc/markup/to_ansi.rb +17 -7
  115. data/lib/rdoc/markup/to_bs.rb +5 -8
  116. data/lib/rdoc/markup/to_html.rb +238 -137
  117. data/lib/rdoc/markup/to_html_crossref.rb +125 -152
  118. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  119. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  120. data/lib/rdoc/markup/to_label.rb +75 -0
  121. data/lib/rdoc/markup/to_markdown.rb +192 -0
  122. data/lib/rdoc/markup/to_rdoc.rb +85 -15
  123. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  124. data/lib/rdoc/markup/to_test.rb +2 -4
  125. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  126. data/lib/rdoc/markup/verbatim.rb +39 -0
  127. data/lib/rdoc/markup.rb +388 -110
  128. data/lib/rdoc/meta_method.rb +1 -2
  129. data/lib/rdoc/method_attr.rb +87 -21
  130. data/lib/rdoc/mixin.rb +121 -0
  131. data/lib/rdoc/normal_class.rb +39 -10
  132. data/lib/rdoc/normal_module.rb +22 -7
  133. data/lib/rdoc/options.rb +613 -73
  134. data/lib/rdoc/parser/c.rb +621 -287
  135. data/lib/rdoc/parser/changelog.rb +335 -0
  136. data/lib/rdoc/parser/markdown.rb +24 -0
  137. data/lib/rdoc/parser/rd.rb +23 -0
  138. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  139. data/lib/rdoc/parser/ruby.rb +1368 -762
  140. data/lib/rdoc/parser/ruby_tools.rb +42 -35
  141. data/lib/rdoc/parser/simple.rb +23 -11
  142. data/lib/rdoc/parser/text.rb +12 -0
  143. data/lib/rdoc/parser.rb +162 -89
  144. data/lib/rdoc/rd/block_parser.rb +1056 -0
  145. data/lib/rdoc/rd/block_parser.ry +639 -0
  146. data/lib/rdoc/rd/inline.rb +72 -0
  147. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  148. data/lib/rdoc/rd/inline_parser.ry +593 -0
  149. data/lib/rdoc/rd.rb +100 -0
  150. data/lib/rdoc/rdoc.rb +208 -115
  151. data/lib/rdoc/require.rb +1 -2
  152. data/lib/rdoc/ri/driver.rb +734 -239
  153. data/lib/rdoc/ri/formatter.rb +1 -0
  154. data/lib/rdoc/ri/paths.rb +91 -48
  155. data/lib/rdoc/ri/store.rb +3 -261
  156. data/lib/rdoc/ri/task.rb +71 -0
  157. data/lib/rdoc/ri.rb +5 -2
  158. data/lib/rdoc/rubygems_hook.rb +246 -0
  159. data/lib/rdoc/servlet.rb +451 -0
  160. data/lib/rdoc/single_class.rb +14 -2
  161. data/lib/rdoc/stats/normal.rb +19 -12
  162. data/lib/rdoc/stats/quiet.rb +1 -0
  163. data/lib/rdoc/stats/verbose.rb +1 -0
  164. data/lib/rdoc/stats.rb +262 -104
  165. data/lib/rdoc/store.rb +979 -0
  166. data/lib/rdoc/task.rb +84 -44
  167. data/lib/rdoc/text.rb +117 -72
  168. data/lib/rdoc/token_stream.rb +73 -4
  169. data/lib/rdoc/tom_doc.rb +263 -0
  170. data/lib/rdoc/top_level.rb +111 -261
  171. data/lib/rdoc/version.rb +8 -0
  172. data/lib/rdoc.rb +127 -64
  173. data/man/ri.1 +247 -0
  174. data/rdoc.gemspec +249 -0
  175. metadata +171 -291
  176. data/.autotest +0 -16
  177. data/.document +0 -5
  178. data/History.txt +0 -594
  179. data/LICENSE.txt +0 -57
  180. data/Manifest.txt +0 -158
  181. data/README.txt +0 -45
  182. data/RI.txt +0 -58
  183. data/bin/ri +0 -5
  184. data/lib/rdoc/gauntlet.rb +0 -52
  185. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
  186. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  187. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
  188. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  189. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
  190. data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
  191. data/lib/rdoc/markup/formatter_test_case.rb +0 -689
  192. data/lib/rdoc/markup/inline.rb +0 -137
  193. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
  194. data/lib/rdoc/ruby_lex.rb +0 -1291
  195. data/lib/rdoc/ruby_token.rb +0 -416
  196. data/test/README +0 -1
  197. data/test/binary.dat +0 -0
  198. data/test/hidden.zip.txt +0 -1
  199. data/test/test.ja.rdoc +0 -10
  200. data/test/test.ja.txt +0 -8
  201. data/test/test.txt +0 -1
  202. data/test/test_attribute_manager.rb +0 -120
  203. data/test/test_rdoc_alias.rb +0 -13
  204. data/test/test_rdoc_any_method.rb +0 -126
  205. data/test/test_rdoc_attr.rb +0 -61
  206. data/test/test_rdoc_class_module.rb +0 -233
  207. data/test/test_rdoc_code_object.rb +0 -165
  208. data/test/test_rdoc_constant.rb +0 -15
  209. data/test/test_rdoc_context.rb +0 -370
  210. data/test/test_rdoc_encoding.rb +0 -166
  211. data/test/test_rdoc_generator_darkfish.rb +0 -119
  212. data/test/test_rdoc_generator_ri.rb +0 -76
  213. data/test/test_rdoc_include.rb +0 -96
  214. data/test/test_rdoc_markup.rb +0 -37
  215. data/test/test_rdoc_markup_attribute_manager.rb +0 -240
  216. data/test/test_rdoc_markup_document.rb +0 -51
  217. data/test/test_rdoc_markup_paragraph.rb +0 -9
  218. data/test/test_rdoc_markup_parser.rb +0 -1395
  219. data/test/test_rdoc_markup_pre_process.rb +0 -185
  220. data/test/test_rdoc_markup_raw.rb +0 -27
  221. data/test/test_rdoc_markup_to_ansi.rb +0 -328
  222. data/test/test_rdoc_markup_to_bs.rb +0 -341
  223. data/test/test_rdoc_markup_to_html.rb +0 -335
  224. data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
  225. data/test/test_rdoc_markup_to_rdoc.rb +0 -327
  226. data/test/test_rdoc_method_attr.rb +0 -122
  227. data/test/test_rdoc_normal_class.rb +0 -17
  228. data/test/test_rdoc_normal_module.rb +0 -31
  229. data/test/test_rdoc_options.rb +0 -342
  230. data/test/test_rdoc_parser.rb +0 -83
  231. data/test/test_rdoc_parser_c.rb +0 -912
  232. data/test/test_rdoc_parser_ruby.rb +0 -1754
  233. data/test/test_rdoc_parser_simple.rb +0 -99
  234. data/test/test_rdoc_rdoc.rb +0 -164
  235. data/test/test_rdoc_require.rb +0 -25
  236. data/test/test_rdoc_ri_driver.rb +0 -846
  237. data/test/test_rdoc_ri_paths.rb +0 -43
  238. data/test/test_rdoc_ri_store.rb +0 -352
  239. data/test/test_rdoc_ruby_lex.rb +0 -23
  240. data/test/test_rdoc_stats.rb +0 -38
  241. data/test/test_rdoc_task.rb +0 -92
  242. data/test/test_rdoc_text.rb +0 -251
  243. data/test/test_rdoc_top_level.rb +0 -120
  244. data/test/xref_data.rb +0 -62
  245. data/test/xref_test_case.rb +0 -61
  246. data.tar.gz.sig +0 -3
  247. metadata.gz.sig +0 -0
@@ -1,3 +1,11 @@
1
+ # frozen_string_literal: true
2
+ begin
3
+ require 'io/console/size'
4
+ rescue LoadError
5
+ # for JRuby
6
+ require 'io/console'
7
+ end
8
+
1
9
  ##
2
10
  # Stats printer that prints just the files being documented with a progress
3
11
  # bar
@@ -6,6 +14,7 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
6
14
 
7
15
  def begin_adding # :nodoc:
8
16
  puts "Parsing sources..."
17
+ @last_width = 0
9
18
  end
10
19
 
11
20
  ##
@@ -17,11 +26,12 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
17
26
  files_so_far,
18
27
  @num_files)
19
28
 
20
- if $stdout.tty? then
29
+ if $stdout.tty?
21
30
  # Print a progress bar, but make sure it fits on a single line. Filename
22
31
  # will be truncated if necessary.
23
- terminal_width = (ENV['COLUMNS'] || 80).to_i
24
- max_filename_size = terminal_width - progress_bar.size
32
+ size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
33
+ terminal_width = size[1].to_i.nonzero? || 80
34
+ max_filename_size = (terminal_width - progress_bar.size) - 1
25
35
 
26
36
  if filename.size > max_filename_size then
27
37
  # Turn "some_long_filename.rb" to "...ong_filename.rb"
@@ -29,17 +39,15 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
29
39
  filename[0..2] = "..."
30
40
  end
31
41
 
32
- # Pad the line with whitespaces so that leftover output from the
42
+ # Clean the line with whitespaces so that leftover output from the
33
43
  # previous line doesn't show up.
34
- line = "#{progress_bar}#{filename}"
35
- padding = terminal_width - line.size
36
- line << (" " * padding) if padding > 0
37
-
38
- $stdout.print("#{line}\r")
44
+ $stdout.print("\r\e[K") if @last_width && @last_width > 0
45
+ @last_width = progress_bar.size + filename.size
46
+ term = "\r"
39
47
  else
40
- $stdout.puts "#{progress_bar} #{filename}"
48
+ term = "\n"
41
49
  end
42
-
50
+ $stdout.print(progress_bar, filename, term)
43
51
  $stdout.flush
44
52
  end
45
53
 
@@ -48,4 +56,3 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
48
56
  end
49
57
 
50
58
  end
51
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Stats printer that prints nothing
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Stats printer that prints everything documented, including the documented
3
4
  # status
data/lib/rdoc/stats.rb CHANGED
@@ -1,11 +1,17 @@
1
- require 'rdoc'
2
-
1
+ # frozen_string_literal: true
3
2
  ##
4
3
  # RDoc statistics collector which prints a summary and report of a project's
5
4
  # documentation totals.
6
5
 
7
6
  class RDoc::Stats
8
7
 
8
+ include RDoc::Text
9
+
10
+ ##
11
+ # Output level for the coverage report
12
+
13
+ attr_reader :coverage_level
14
+
9
15
  ##
10
16
  # Count of files parsed during parsing
11
17
 
@@ -20,13 +26,18 @@ class RDoc::Stats
20
26
  # Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1
21
27
  # which will create an RDoc::Stats::Normal outputter.
22
28
 
23
- def initialize num_files, verbosity = 1
24
- @files_so_far = 0
29
+ def initialize store, num_files, verbosity = 1
25
30
  @num_files = num_files
26
- @fully_documented = nil
27
- @percent_doc = nil
31
+ @store = store
28
32
 
29
- @start = Time.now
33
+ @coverage_level = 0
34
+ @doc_items = nil
35
+ @files_so_far = 0
36
+ @fully_documented = false
37
+ @num_params = 0
38
+ @percent_doc = nil
39
+ @start = Time.now
40
+ @undoc_params = 0
30
41
 
31
42
  @display = case verbosity
32
43
  when 0 then Quiet.new num_files
@@ -93,12 +104,16 @@ class RDoc::Stats
93
104
  end
94
105
 
95
106
  ##
96
- # Calculates documentation totals and percentages
107
+ # Calculates documentation totals and percentages for classes, modules,
108
+ # constants, attributes and methods.
97
109
 
98
110
  def calculate
99
- return if @percent_doc
111
+ return if @doc_items
112
+
113
+ ucm = @store.unique_classes_and_modules
114
+
115
+ classes = @store.unique_classes.reject { |cm| cm.full_name == 'Object' }
100
116
 
101
- ucm = RDoc::TopLevel.unique_classes_and_modules
102
117
  constants = []
103
118
  ucm.each { |cm| constants.concat cm.constants }
104
119
 
@@ -109,37 +124,49 @@ class RDoc::Stats
109
124
  ucm.each { |cm| attributes.concat cm.attributes }
110
125
 
111
126
  @num_attributes, @undoc_attributes = doc_stats attributes
112
- @num_classes, @undoc_classes = doc_stats RDoc::TopLevel.unique_classes
127
+ @num_classes, @undoc_classes = doc_stats classes
113
128
  @num_constants, @undoc_constants = doc_stats constants
114
129
  @num_methods, @undoc_methods = doc_stats methods
115
- @num_modules, @undoc_modules = doc_stats RDoc::TopLevel.unique_modules
130
+ @num_modules, @undoc_modules = doc_stats @store.unique_modules
116
131
 
117
132
  @num_items =
118
133
  @num_attributes +
119
134
  @num_classes +
120
135
  @num_constants +
121
136
  @num_methods +
122
- @num_modules
137
+ @num_modules +
138
+ @num_params
123
139
 
124
140
  @undoc_items =
125
141
  @undoc_attributes +
126
142
  @undoc_classes +
127
143
  @undoc_constants +
128
144
  @undoc_methods +
129
- @undoc_modules
145
+ @undoc_modules +
146
+ @undoc_params
130
147
 
131
148
  @doc_items = @num_items - @undoc_items
149
+ end
132
150
 
133
- @fully_documented = (@num_items - @doc_items) == 0
151
+ ##
152
+ # Sets coverage report level. Accepted values are:
153
+ #
154
+ # false or nil:: No report
155
+ # 0:: Classes, modules, constants, attributes, methods
156
+ # 1:: Level 0 + method parameters
134
157
 
135
- @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
158
+ def coverage_level= level
159
+ level = -1 unless level
160
+
161
+ @coverage_level = level
136
162
  end
137
163
 
138
164
  ##
139
165
  # Returns the length and number of undocumented items in +collection+.
140
166
 
141
167
  def doc_stats collection
142
- [collection.length, collection.count { |item| not item.documented? }]
168
+ visible = collection.select { |item| item.display? }
169
+ [visible.length, visible.count { |item| not item.documented? }]
143
170
  end
144
171
 
145
172
  ##
@@ -159,97 +186,201 @@ class RDoc::Stats
159
186
  @fully_documented
160
187
  end
161
188
 
189
+ ##
190
+ # A report that says you did a great job!
191
+
192
+ def great_job
193
+ report = RDoc::Markup::Document.new
194
+
195
+ report << RDoc::Markup::Paragraph.new('100% documentation!')
196
+ report << RDoc::Markup::Paragraph.new('Great Job!')
197
+
198
+ report
199
+ end
200
+
201
+ ##
202
+ # Calculates the percentage of items documented.
203
+
204
+ def percent_doc
205
+ return @percent_doc if @percent_doc
206
+
207
+ @fully_documented = (@num_items - @doc_items) == 0
208
+
209
+ @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?
210
+ @percent_doc ||= 0
211
+
212
+ @percent_doc
213
+ end
214
+
162
215
  ##
163
216
  # Returns a report on which items are not documented
164
217
 
165
218
  def report
166
- report = []
167
-
168
- calculate
219
+ if @coverage_level > 0 then
220
+ extend RDoc::Text
221
+ end
169
222
 
170
- if @num_items == @doc_items then
171
- report << '100% documentation!'
172
- report << nil
173
- report << 'Great Job!'
223
+ if @coverage_level.zero? then
224
+ calculate
174
225
 
175
- return report.join "\n"
226
+ return great_job if @num_items == @doc_items
176
227
  end
177
228
 
178
- report << 'The following items are not documented:'
179
- report << nil
229
+ ucm = @store.unique_classes_and_modules
180
230
 
181
- ucm = RDoc::TopLevel.unique_classes_and_modules
231
+ report = RDoc::Markup::Document.new
232
+ report << RDoc::Markup::Paragraph.new('The following items are not documented:')
233
+ report << RDoc::Markup::BlankLine.new
182
234
 
183
235
  ucm.sort.each do |cm|
184
- type = case cm # TODO #definition
185
- when RDoc::NormalClass then 'class'
186
- when RDoc::SingleClass then 'class <<'
187
- when RDoc::NormalModule then 'module'
188
- end
189
-
190
- if cm.fully_documented? then
191
- next
192
- elsif cm.in_files.empty? or
193
- (cm.constants.empty? and cm.method_list.empty?) then
194
- report << "# #{type} #{cm.full_name} is referenced but empty."
195
- report << '#'
196
- report << '# It probably came from another project. ' \
197
- 'I\'m sorry I\'m holding it against you.'
198
- report << nil
199
-
200
- next
201
- elsif cm.documented? then
202
- report << "#{type} #{cm.full_name} # is documented"
203
- else
204
- report << '# in files:'
205
-
206
- cm.in_files.each do |file|
207
- report << "# #{file.full_name}"
208
- end
236
+ body = report_class_module(cm) {
237
+ [
238
+ report_constants(cm),
239
+ report_attributes(cm),
240
+ report_methods(cm),
241
+ ].compact
242
+ }
243
+
244
+ report << body if body
245
+ end
209
246
 
210
- report << nil
247
+ if @coverage_level > 0 then
248
+ calculate
211
249
 
212
- report << "#{type} #{cm.full_name}"
213
- end
250
+ return great_job if @num_items == @doc_items
251
+ end
214
252
 
215
- unless cm.constants.empty? then
216
- report << nil
253
+ report
254
+ end
217
255
 
218
- cm.each_constant do |constant|
219
- # TODO constant aliases are listed in the summary but not reported
220
- # figure out what to do here
221
- next if constant.documented? || constant.is_alias_for
222
- report << " # in file #{constant.file.full_name}"
223
- report << " #{constant.name} = nil"
224
- end
225
- end
256
+ ##
257
+ # Returns a report on undocumented attributes in ClassModule +cm+
226
258
 
227
- unless cm.attributes.empty? then
228
- report << nil
259
+ def report_attributes cm
260
+ return if cm.attributes.empty?
229
261
 
230
- cm.each_attribute do |attr|
231
- next if attr.documented?
232
- report << " #{attr.definition} #{attr.name} " \
233
- "# in file #{attr.file.full_name}"
234
- end
262
+ report = []
263
+
264
+ cm.each_attribute do |attr|
265
+ next if attr.documented?
266
+ line = attr.line ? ":#{attr.line}" : nil
267
+ report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n"
268
+ report << "\n"
269
+ end
270
+
271
+ report
272
+ end
273
+
274
+ ##
275
+ # Returns a report on undocumented items in ClassModule +cm+
276
+
277
+ def report_class_module cm
278
+ return if cm.fully_documented? and @coverage_level.zero?
279
+ return unless cm.display?
280
+
281
+ report = RDoc::Markup::Document.new
282
+
283
+ if cm.in_files.empty? then
284
+ report << RDoc::Markup::Paragraph.new("#{cm.definition} is referenced but empty.")
285
+ report << RDoc::Markup::Paragraph.new("It probably came from another project. I'm sorry I'm holding it against you.")
286
+
287
+ return report
288
+ elsif cm.documented? then
289
+ documented = true
290
+ klass = RDoc::Markup::Verbatim.new("#{cm.definition} # is documented\n")
291
+ else
292
+ report << RDoc::Markup::Paragraph.new('In files:')
293
+
294
+ list = RDoc::Markup::List.new :BULLET
295
+
296
+ cm.in_files.each do |file|
297
+ para = RDoc::Markup::Paragraph.new file.full_name
298
+ list << RDoc::Markup::ListItem.new(nil, para)
235
299
  end
236
300
 
237
- unless cm.method_list.empty? then
238
- report << nil
301
+ report << list
302
+ report << RDoc::Markup::BlankLine.new
303
+
304
+ klass = RDoc::Markup::Verbatim.new("#{cm.definition}\n")
305
+ end
306
+
307
+ klass << "\n"
308
+
309
+ body = yield.flatten # HACK remove #flatten
310
+
311
+ if body.empty? then
312
+ return if documented
313
+
314
+ klass.parts.pop
315
+ else
316
+ klass.parts.concat body
317
+ end
318
+
319
+ klass << "end\n"
320
+
321
+ report << klass
322
+
323
+ report
324
+ end
325
+
326
+ ##
327
+ # Returns a report on undocumented constants in ClassModule +cm+
328
+
329
+ def report_constants cm
330
+ return if cm.constants.empty?
331
+
332
+ report = []
333
+
334
+ cm.each_constant do |constant|
335
+ # TODO constant aliases are listed in the summary but not reported
336
+ # figure out what to do here
337
+ next if constant.documented? || constant.is_alias_for
338
+
339
+ line = constant.line ? ":#{constant.line}" : line
340
+ report << " # in file #{constant.file.full_name}#{line}\n"
341
+ report << " #{constant.name} = nil\n"
342
+ report << "\n"
343
+ end
344
+
345
+ report
346
+ end
239
347
 
240
- cm.each_method do |method|
241
- next if method.documented?
242
- report << " # in file #{method.file.full_name}"
243
- report << " def #{method.name}#{method.params}; end"
244
- report << nil
348
+ ##
349
+ # Returns a report on undocumented methods in ClassModule +cm+
350
+
351
+ def report_methods cm
352
+ return if cm.method_list.empty?
353
+
354
+ report = []
355
+
356
+ cm.each_method do |method|
357
+ next if method.documented? and @coverage_level.zero?
358
+
359
+ if @coverage_level > 0 then
360
+ params, undoc = undoc_params method
361
+
362
+ @num_params += params
363
+
364
+ unless undoc.empty? then
365
+ @undoc_params += undoc.length
366
+
367
+ undoc = undoc.map do |param| "+#{param}+" end
368
+ param_report = " # #{undoc.join ', '} is not documented\n"
245
369
  end
246
370
  end
247
371
 
248
- report << 'end'
249
- report << nil
372
+ next if method.documented? and not param_report
373
+
374
+ line = method.line ? ":#{method.line}" : nil
375
+ scope = method.singleton ? 'self.' : nil
376
+
377
+ report << " # in file #{method.file.full_name}#{line}\n"
378
+ report << param_report if param_report
379
+ report << " def #{scope}#{method.name}#{method.params}; end\n"
380
+ report << "\n"
250
381
  end
251
382
 
252
- report.join "\n"
383
+ report
253
384
  end
254
385
 
255
386
  ##
@@ -259,41 +390,68 @@ class RDoc::Stats
259
390
  calculate
260
391
 
261
392
  num_width = [@num_files, @num_items].max.to_s.length
262
- nodoc_width = [
393
+ undoc_width = [
263
394
  @undoc_attributes,
264
395
  @undoc_classes,
265
396
  @undoc_constants,
266
397
  @undoc_items,
267
398
  @undoc_methods,
268
399
  @undoc_modules,
400
+ @undoc_params,
269
401
  ].max.to_s.length
270
402
 
271
- report = []
272
- report << 'Files: %*d' % [num_width, @num_files]
403
+ report = RDoc::Markup::Verbatim.new
404
+
405
+ report << "Files: %*d\n" % [num_width, @num_files]
406
+
407
+ report << "\n"
408
+
409
+ report << "Classes: %*d (%*d undocumented)\n" % [
410
+ num_width, @num_classes, undoc_width, @undoc_classes]
411
+ report << "Modules: %*d (%*d undocumented)\n" % [
412
+ num_width, @num_modules, undoc_width, @undoc_modules]
413
+ report << "Constants: %*d (%*d undocumented)\n" % [
414
+ num_width, @num_constants, undoc_width, @undoc_constants]
415
+ report << "Attributes: %*d (%*d undocumented)\n" % [
416
+ num_width, @num_attributes, undoc_width, @undoc_attributes]
417
+ report << "Methods: %*d (%*d undocumented)\n" % [
418
+ num_width, @num_methods, undoc_width, @undoc_methods]
419
+ report << "Parameters: %*d (%*d undocumented)\n" % [
420
+ num_width, @num_params, undoc_width, @undoc_params] if
421
+ @coverage_level > 0
422
+
423
+ report << "\n"
424
+
425
+ report << "Total: %*d (%*d undocumented)\n" % [
426
+ num_width, @num_items, undoc_width, @undoc_items]
427
+
428
+ report << "%6.2f%% documented\n" % percent_doc
429
+ report << "\n"
430
+ report << "Elapsed: %0.1fs\n" % (Time.now - @start)
431
+
432
+ RDoc::Markup::Document.new report
433
+ end
434
+
435
+ ##
436
+ # Determines which parameters in +method+ were not documented. Returns a
437
+ # total parameter count and an Array of undocumented methods.
438
+
439
+ def undoc_params method
440
+ @formatter ||= RDoc::Markup::ToTtOnly.new
441
+
442
+ params = method.param_list
273
443
 
274
- report << nil
444
+ params = params.map { |param| param.gsub(/^\*\*?/, '') }
275
445
 
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]
446
+ return 0, [] if params.empty?
286
447
 
287
- report << nil
448
+ document = parse method.comment
288
449
 
289
- report << 'Total: %*d (%*d undocumented)' % [
290
- num_width, @num_items, nodoc_width, @undoc_items]
450
+ tts = document.accept @formatter
291
451
 
292
- report << '%6.2f%% documented' % @percent_doc if @percent_doc
293
- report << nil
294
- report << 'Elapsed: %0.1fs' % (Time.now - @start)
452
+ undoc = params - tts
295
453
 
296
- report.join "\n"
454
+ [params.length, undoc]
297
455
  end
298
456
 
299
457
  autoload :Quiet, 'rdoc/stats/quiet'