gitlab-rdoc 6.3.2

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 (196) 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 +133 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +101 -0
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/exe/rdoc +44 -0
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +112 -0
  19. data/lib/rdoc/anon_class.rb +11 -0
  20. data/lib/rdoc/any_method.rb +361 -0
  21. data/lib/rdoc/attr.rb +176 -0
  22. data/lib/rdoc/class_module.rb +802 -0
  23. data/lib/rdoc/code_object.rb +421 -0
  24. data/lib/rdoc/code_objects.rb +6 -0
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +187 -0
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +1266 -0
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +136 -0
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +42 -0
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +790 -0
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +160 -0
  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 +31 -0
  42. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  44. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  58. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  59. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  72. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  73. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  74. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  75. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  76. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  77. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  78. data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  79. data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  80. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  81. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  82. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  83. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  84. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  85. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  86. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  87. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  88. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  89. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  90. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  91. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  92. data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
  93. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
  94. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  95. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  96. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  97. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  98. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  99. data/lib/rdoc/generator/template/json_index/.document +1 -0
  100. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  101. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  102. data/lib/rdoc/generator.rb +51 -0
  103. data/lib/rdoc/ghost_method.rb +7 -0
  104. data/lib/rdoc/i18n/locale.rb +102 -0
  105. data/lib/rdoc/i18n/text.rb +126 -0
  106. data/lib/rdoc/i18n.rb +10 -0
  107. data/lib/rdoc/include.rb +10 -0
  108. data/lib/rdoc/known_classes.rb +73 -0
  109. data/lib/rdoc/markdown/entities.rb +2132 -0
  110. data/lib/rdoc/markdown/literals.kpeg +23 -0
  111. data/lib/rdoc/markdown/literals.rb +417 -0
  112. data/lib/rdoc/markdown.kpeg +1237 -0
  113. data/lib/rdoc/markdown.rb +16685 -0
  114. data/lib/rdoc/markup/attr_changer.rb +23 -0
  115. data/lib/rdoc/markup/attr_span.rb +36 -0
  116. data/lib/rdoc/markup/attribute_manager.rb +409 -0
  117. data/lib/rdoc/markup/attributes.rb +71 -0
  118. data/lib/rdoc/markup/blank_line.rb +28 -0
  119. data/lib/rdoc/markup/block_quote.rb +15 -0
  120. data/lib/rdoc/markup/document.rb +165 -0
  121. data/lib/rdoc/markup/formatter.rb +266 -0
  122. data/lib/rdoc/markup/hard_break.rb +32 -0
  123. data/lib/rdoc/markup/heading.rb +79 -0
  124. data/lib/rdoc/markup/include.rb +43 -0
  125. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  126. data/lib/rdoc/markup/list.rb +102 -0
  127. data/lib/rdoc/markup/list_item.rb +100 -0
  128. data/lib/rdoc/markup/paragraph.rb +29 -0
  129. data/lib/rdoc/markup/parser.rb +575 -0
  130. data/lib/rdoc/markup/pre_process.rb +296 -0
  131. data/lib/rdoc/markup/raw.rb +70 -0
  132. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  133. data/lib/rdoc/markup/rule.rb +21 -0
  134. data/lib/rdoc/markup/table.rb +47 -0
  135. data/lib/rdoc/markup/to_ansi.rb +94 -0
  136. data/lib/rdoc/markup/to_bs.rb +77 -0
  137. data/lib/rdoc/markup/to_html.rb +444 -0
  138. data/lib/rdoc/markup/to_html_crossref.rb +176 -0
  139. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  140. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  141. data/lib/rdoc/markup/to_label.rb +75 -0
  142. data/lib/rdoc/markup/to_markdown.rb +192 -0
  143. data/lib/rdoc/markup/to_rdoc.rb +362 -0
  144. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  145. data/lib/rdoc/markup/to_test.rb +70 -0
  146. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  147. data/lib/rdoc/markup/verbatim.rb +84 -0
  148. data/lib/rdoc/markup.rb +867 -0
  149. data/lib/rdoc/meta_method.rb +7 -0
  150. data/lib/rdoc/method_attr.rb +419 -0
  151. data/lib/rdoc/mixin.rb +121 -0
  152. data/lib/rdoc/normal_class.rb +93 -0
  153. data/lib/rdoc/normal_module.rb +74 -0
  154. data/lib/rdoc/options.rb +1285 -0
  155. data/lib/rdoc/parser/c.rb +1225 -0
  156. data/lib/rdoc/parser/changelog.rb +335 -0
  157. data/lib/rdoc/parser/markdown.rb +24 -0
  158. data/lib/rdoc/parser/rd.rb +23 -0
  159. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  160. data/lib/rdoc/parser/ruby.rb +2327 -0
  161. data/lib/rdoc/parser/ruby_tools.rb +167 -0
  162. data/lib/rdoc/parser/simple.rb +61 -0
  163. data/lib/rdoc/parser/text.rb +12 -0
  164. data/lib/rdoc/parser.rb +277 -0
  165. data/lib/rdoc/rd/block_parser.rb +1056 -0
  166. data/lib/rdoc/rd/block_parser.ry +639 -0
  167. data/lib/rdoc/rd/inline.rb +72 -0
  168. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  169. data/lib/rdoc/rd/inline_parser.ry +593 -0
  170. data/lib/rdoc/rd.rb +100 -0
  171. data/lib/rdoc/rdoc.rb +579 -0
  172. data/lib/rdoc/require.rb +52 -0
  173. data/lib/rdoc/ri/driver.rb +1572 -0
  174. data/lib/rdoc/ri/formatter.rb +6 -0
  175. data/lib/rdoc/ri/paths.rb +171 -0
  176. data/lib/rdoc/ri/store.rb +7 -0
  177. data/lib/rdoc/ri/task.rb +71 -0
  178. data/lib/rdoc/ri.rb +21 -0
  179. data/lib/rdoc/rubygems_hook.rb +246 -0
  180. data/lib/rdoc/servlet.rb +451 -0
  181. data/lib/rdoc/single_class.rb +26 -0
  182. data/lib/rdoc/stats/normal.rb +58 -0
  183. data/lib/rdoc/stats/quiet.rb +60 -0
  184. data/lib/rdoc/stats/verbose.rb +46 -0
  185. data/lib/rdoc/stats.rb +462 -0
  186. data/lib/rdoc/store.rb +979 -0
  187. data/lib/rdoc/task.rb +329 -0
  188. data/lib/rdoc/text.rb +304 -0
  189. data/lib/rdoc/token_stream.rb +119 -0
  190. data/lib/rdoc/tom_doc.rb +263 -0
  191. data/lib/rdoc/top_level.rb +289 -0
  192. data/lib/rdoc/version.rb +8 -0
  193. data/lib/rdoc.rb +201 -0
  194. data/man/ri.1 +247 -0
  195. data/rdoc.gemspec +249 -0
  196. metadata +279 -0
@@ -0,0 +1,58 @@
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
+
9
+ ##
10
+ # Stats printer that prints just the files being documented with a progress
11
+ # bar
12
+
13
+ class RDoc::Stats::Normal < RDoc::Stats::Quiet
14
+
15
+ def begin_adding # :nodoc:
16
+ puts "Parsing sources..."
17
+ @last_width = 0
18
+ end
19
+
20
+ ##
21
+ # Prints a file with a progress bar
22
+
23
+ def print_file files_so_far, filename
24
+ progress_bar = sprintf("%3d%% [%2d/%2d] ",
25
+ 100 * files_so_far / @num_files,
26
+ files_so_far,
27
+ @num_files)
28
+
29
+ if $stdout.tty?
30
+ # Print a progress bar, but make sure it fits on a single line. Filename
31
+ # will be truncated if necessary.
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
35
+
36
+ if filename.size > max_filename_size then
37
+ # Turn "some_long_filename.rb" to "...ong_filename.rb"
38
+ filename = filename[(filename.size - max_filename_size) .. -1]
39
+ filename[0..2] = "..."
40
+ end
41
+
42
+ # Clean the line with whitespaces so that leftover output from the
43
+ # previous line doesn't show up.
44
+ $stdout.print("\r\e[K") if @last_width && @last_width > 0
45
+ @last_width = progress_bar.size + filename.size
46
+ term = "\r"
47
+ else
48
+ term = "\n"
49
+ end
50
+ $stdout.print(progress_bar, filename, term)
51
+ $stdout.flush
52
+ end
53
+
54
+ def done_adding # :nodoc:
55
+ puts
56
+ end
57
+
58
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Stats printer that prints nothing
4
+
5
+ class RDoc::Stats::Quiet
6
+
7
+ ##
8
+ # Creates a new Quiet that will print nothing
9
+
10
+ def initialize num_files
11
+ @num_files = num_files
12
+ end
13
+
14
+ ##
15
+ # Prints a message at the beginning of parsing
16
+
17
+ def begin_adding(*) end
18
+
19
+ ##
20
+ # Prints when an alias is added
21
+
22
+ def print_alias(*) end
23
+
24
+ ##
25
+ # Prints when an attribute is added
26
+
27
+ def print_attribute(*) end
28
+
29
+ ##
30
+ # Prints when a class is added
31
+
32
+ def print_class(*) end
33
+
34
+ ##
35
+ # Prints when a constant is added
36
+
37
+ def print_constant(*) end
38
+
39
+ ##
40
+ # Prints when a file is added
41
+
42
+ def print_file(*) end
43
+
44
+ ##
45
+ # Prints when a method is added
46
+
47
+ def print_method(*) end
48
+
49
+ ##
50
+ # Prints when a module is added
51
+
52
+ def print_module(*) end
53
+
54
+ ##
55
+ # Prints when RDoc is done
56
+
57
+ def done_adding(*) end
58
+
59
+ end
60
+
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Stats printer that prints everything documented, including the documented
4
+ # status
5
+
6
+ class RDoc::Stats::Verbose < RDoc::Stats::Normal
7
+
8
+ ##
9
+ # Returns a marker for RDoc::CodeObject +co+ being undocumented
10
+
11
+ def nodoc co
12
+ " (undocumented)" unless co.documented?
13
+ end
14
+
15
+ def print_alias as # :nodoc:
16
+ puts " alias #{as.new_name} #{as.old_name}#{nodoc as}"
17
+ end
18
+
19
+ def print_attribute attribute # :nodoc:
20
+ puts " #{attribute.definition} #{attribute.name}#{nodoc attribute}"
21
+ end
22
+
23
+ def print_class(klass) # :nodoc:
24
+ puts " class #{klass.full_name}#{nodoc klass}"
25
+ end
26
+
27
+ def print_constant(constant) # :nodoc:
28
+ puts " #{constant.name}#{nodoc constant}"
29
+ end
30
+
31
+ def print_file(files_so_far, file) # :nodoc:
32
+ super
33
+ puts
34
+ end
35
+
36
+ def print_method(method) # :nodoc:
37
+ puts " #{method.singleton ? '::' : '#'}#{method.name}#{nodoc method}"
38
+ end
39
+
40
+ def print_module(mod) # :nodoc:
41
+ puts " module #{mod.full_name}#{nodoc mod}"
42
+ end
43
+
44
+ end
45
+
46
+
data/lib/rdoc/stats.rb ADDED
@@ -0,0 +1,462 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # RDoc statistics collector which prints a summary and report of a project's
4
+ # documentation totals.
5
+
6
+ class RDoc::Stats
7
+
8
+ include RDoc::Text
9
+
10
+ ##
11
+ # Output level for the coverage report
12
+
13
+ attr_reader :coverage_level
14
+
15
+ ##
16
+ # Count of files parsed during parsing
17
+
18
+ attr_reader :files_so_far
19
+
20
+ ##
21
+ # Total number of files found
22
+
23
+ attr_reader :num_files
24
+
25
+ ##
26
+ # Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1
27
+ # which will create an RDoc::Stats::Normal outputter.
28
+
29
+ def initialize store, num_files, verbosity = 1
30
+ @num_files = num_files
31
+ @store = store
32
+
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
41
+
42
+ @display = case verbosity
43
+ when 0 then Quiet.new num_files
44
+ when 1 then Normal.new num_files
45
+ else Verbose.new num_files
46
+ end
47
+ end
48
+
49
+ ##
50
+ # Records the parsing of an alias +as+.
51
+
52
+ def add_alias as
53
+ @display.print_alias as
54
+ end
55
+
56
+ ##
57
+ # Records the parsing of an attribute +attribute+
58
+
59
+ def add_attribute attribute
60
+ @display.print_attribute attribute
61
+ end
62
+
63
+ ##
64
+ # Records the parsing of a class +klass+
65
+
66
+ def add_class klass
67
+ @display.print_class klass
68
+ end
69
+
70
+ ##
71
+ # Records the parsing of +constant+
72
+
73
+ def add_constant constant
74
+ @display.print_constant constant
75
+ end
76
+
77
+ ##
78
+ # Records the parsing of +file+
79
+
80
+ def add_file(file)
81
+ @files_so_far += 1
82
+ @display.print_file @files_so_far, file
83
+ end
84
+
85
+ ##
86
+ # Records the parsing of +method+
87
+
88
+ def add_method(method)
89
+ @display.print_method method
90
+ end
91
+
92
+ ##
93
+ # Records the parsing of a module +mod+
94
+
95
+ def add_module(mod)
96
+ @display.print_module mod
97
+ end
98
+
99
+ ##
100
+ # Call this to mark the beginning of parsing for display purposes
101
+
102
+ def begin_adding
103
+ @display.begin_adding
104
+ end
105
+
106
+ ##
107
+ # Calculates documentation totals and percentages for classes, modules,
108
+ # constants, attributes and methods.
109
+
110
+ def calculate
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' }
116
+
117
+ constants = []
118
+ ucm.each { |cm| constants.concat cm.constants }
119
+
120
+ methods = []
121
+ ucm.each { |cm| methods.concat cm.method_list }
122
+
123
+ attributes = []
124
+ ucm.each { |cm| attributes.concat cm.attributes }
125
+
126
+ @num_attributes, @undoc_attributes = doc_stats attributes
127
+ @num_classes, @undoc_classes = doc_stats classes
128
+ @num_constants, @undoc_constants = doc_stats constants
129
+ @num_methods, @undoc_methods = doc_stats methods
130
+ @num_modules, @undoc_modules = doc_stats @store.unique_modules
131
+
132
+ @num_items =
133
+ @num_attributes +
134
+ @num_classes +
135
+ @num_constants +
136
+ @num_methods +
137
+ @num_modules +
138
+ @num_params
139
+
140
+ @undoc_items =
141
+ @undoc_attributes +
142
+ @undoc_classes +
143
+ @undoc_constants +
144
+ @undoc_methods +
145
+ @undoc_modules +
146
+ @undoc_params
147
+
148
+ @doc_items = @num_items - @undoc_items
149
+ end
150
+
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
157
+
158
+ def coverage_level= level
159
+ level = -1 unless level
160
+
161
+ @coverage_level = level
162
+ end
163
+
164
+ ##
165
+ # Returns the length and number of undocumented items in +collection+.
166
+
167
+ def doc_stats collection
168
+ visible = collection.select { |item| item.display? }
169
+ [visible.length, visible.count { |item| not item.documented? }]
170
+ end
171
+
172
+ ##
173
+ # Call this to mark the end of parsing for display purposes
174
+
175
+ def done_adding
176
+ @display.done_adding
177
+ end
178
+
179
+ ##
180
+ # The documentation status of this project. +true+ when 100%, +false+ when
181
+ # less than 100% and +nil+ when unknown.
182
+ #
183
+ # Set by calling #calculate
184
+
185
+ def fully_documented?
186
+ @fully_documented
187
+ end
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
+
215
+ ##
216
+ # Returns a report on which items are not documented
217
+
218
+ def report
219
+ if @coverage_level > 0 then
220
+ extend RDoc::Text
221
+ end
222
+
223
+ if @coverage_level.zero? then
224
+ calculate
225
+
226
+ return great_job if @num_items == @doc_items
227
+ end
228
+
229
+ ucm = @store.unique_classes_and_modules
230
+
231
+ report = RDoc::Markup::Document.new
232
+ report << RDoc::Markup::Paragraph.new('The following items are not documented:')
233
+ report << RDoc::Markup::BlankLine.new
234
+
235
+ ucm.sort.each do |cm|
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
246
+
247
+ if @coverage_level > 0 then
248
+ calculate
249
+
250
+ return great_job if @num_items == @doc_items
251
+ end
252
+
253
+ report
254
+ end
255
+
256
+ ##
257
+ # Returns a report on undocumented attributes in ClassModule +cm+
258
+
259
+ def report_attributes cm
260
+ return if cm.attributes.empty?
261
+
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)
299
+ end
300
+
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
347
+
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"
369
+ end
370
+ end
371
+
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"
381
+ end
382
+
383
+ report
384
+ end
385
+
386
+ ##
387
+ # Returns a summary of the collected statistics.
388
+
389
+ def summary
390
+ calculate
391
+
392
+ num_width = [@num_files, @num_items].max.to_s.length
393
+ undoc_width = [
394
+ @undoc_attributes,
395
+ @undoc_classes,
396
+ @undoc_constants,
397
+ @undoc_items,
398
+ @undoc_methods,
399
+ @undoc_modules,
400
+ @undoc_params,
401
+ ].max.to_s.length
402
+
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
443
+
444
+ params = params.map { |param| param.gsub(/^\*\*?/, '') }
445
+
446
+ return 0, [] if params.empty?
447
+
448
+ document = parse method.comment
449
+
450
+ tts = document.accept @formatter
451
+
452
+ undoc = params - tts
453
+
454
+ [params.length, undoc]
455
+ end
456
+
457
+ autoload :Quiet, 'rdoc/stats/quiet'
458
+ autoload :Normal, 'rdoc/stats/normal'
459
+ autoload :Verbose, 'rdoc/stats/verbose'
460
+
461
+ end
462
+