rdoc 3.0.1 → 3.1

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.

data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,41 @@
1
+ === 3.1 / 2010-12-28
2
+
3
+ RDoc has moved to github. Releases after 3.1 reference github unless
4
+ otherwise noted.
5
+
6
+ * Minor enhancements
7
+ * RDoc::Task now features a #generator option to choose an alternate
8
+ generator. Pull Request #2 by Erik Hollensbe.
9
+ * Enhanced test for RDoc::Parser::binary? RubyForge patch #28538 by Eito
10
+ Katagiri.
11
+ * Generator list in --help is no longer static. Generator description comes
12
+ from the generator's DESCRIPTION constant.
13
+ * Documentation summary is now displayed with dynamic width.
14
+ * Bug fixes
15
+ * Strip encoding comment from input to avoid overriding file comment.
16
+ RubyForge Bug #22113 by James Gray.
17
+ * Restore call-seq parsing behavior when the call-seq is the only comment.
18
+ RubyForge Bug #26290 by Sylvain Joyeux.
19
+ * Coverage report no longer crashes for constant aliases. Pull Request #1
20
+ by Andy Lindeman.
21
+ * RDoc no longer looses ghost methods when followed by certain tokens.
22
+ RubyForge bug #27793 by Aaron Patterson.
23
+ * RDoc no longer crashes in ri if HOME is not set. Ruby Bug #4202 by
24
+ Shyouhei Urabe.
25
+ * ri no longer crashes with HTML format output. RubyForge bug #28675 by
26
+ 7rans.
27
+ * RDoc::Markup::ToHtml#gen_url now initializes #from_path to ''.
28
+ Additionally, #from_path is now settable. RubyForge bug #27838 by Claus
29
+ Folke Brobak.
30
+ * Comments in the C parser ar enow normalized before being combined.
31
+ RubyForge patch #28646 by Sven Herzberg.
32
+ * RDoc::Parser::C no longer requires a comment and finds more method bodies.
33
+ RubyForge patch #28643 by Sven Herzberg.
34
+ * Darkfish now has a "Class/Module Index" instead of a "Class Index".
35
+ RubyForge patch #28364 by James Tucker.
36
+ * RDoc::Parser::Ruby now parses negative numbers correctly. RubyForge patch
37
+ #28544 by Eito Katagiri.
38
+
1
39
  === 3.0.1 / 2010-12-19
2
40
 
3
41
  * Bug fix
data/README.txt CHANGED
@@ -6,18 +6,20 @@
6
6
 
7
7
  == DESCRIPTION:
8
8
 
9
- RDoc is an application that produces documentation for one or more Ruby source
10
- files. RDoc includes the +rdoc+ and +ri+ tools for generating and displaying
11
- online documentation.
12
-
13
- At this point in time, RDoc 2.x is a work in progress and may incur further
14
- API changes beyond what has been made to RDoc 1.0.1. Command-line tools are
15
- largely unaffected, but internal APIs may shift rapidly.
9
+ RDoc produces HTML and command-line documentation for Ruby projects. RDoc
10
+ includes the +rdoc+ and +ri+ tools for generating and displaying online
11
+ documentation.
16
12
 
17
13
  See RDoc for a description of RDoc's markup and basic use.
18
14
 
19
15
  == SYNOPSIS:
20
16
 
17
+ To generate HTML documentation:
18
+
19
+ rdoc .
20
+
21
+ To generate documentation programmatically:
22
+
21
23
  gem 'rdoc'
22
24
  require 'rdoc/rdoc'
23
25
  # ... see RDoc
data/Rakefile CHANGED
@@ -2,6 +2,10 @@ require 'hoe'
2
2
  $:.unshift 'lib'
3
3
  require 'rdoc/rdoc'
4
4
 
5
+ Hoe.plugin :git
6
+ Hoe.plugin :isolate
7
+ Hoe.plugin :minitest
8
+
5
9
  $rdoc_rakefile = true
6
10
 
7
11
  Hoe.spec 'rdoc' do
@@ -11,9 +15,12 @@ Hoe.spec 'rdoc' do
11
15
  developer 'Tony Strauss', 'tony.strauss@designingpatterns.com'
12
16
 
13
17
  self.remote_rdoc_dir = ''
18
+ self.rsync_args = '-avz'
14
19
  self.testlib = :minitest
20
+ self.isolate_dir = 'tmp/isolated'
15
21
 
16
22
  extra_dev_deps << ['minitest', '~> 2']
23
+ extra_dev_deps << ['isolate', '~> 3']
17
24
  extra_rdoc_files << 'Rakefile'
18
25
  spec_extras['required_rubygems_version'] = '>= 1.3'
19
26
  spec_extras['homepage'] = 'http://rdoc.rubyforge.org'
@@ -95,7 +95,7 @@ module RDoc
95
95
  ##
96
96
  # RDoc version you are using
97
97
 
98
- VERSION = '3.0.1'
98
+ VERSION = '3.1'
99
99
 
100
100
  ##
101
101
  # Method visibilities
@@ -118,7 +118,8 @@ class RDoc::ClassModule < RDoc::Context
118
118
  def comment= comment
119
119
  return if comment.empty?
120
120
 
121
- comment = "#{@comment}\n---\n#{normalize_comment comment}" unless
121
+ comment = normalize_comment comment
122
+ comment = "#{@comment}\n---\n#{comment}" unless
122
123
  @comment.empty?
123
124
 
124
125
  super
@@ -60,8 +60,6 @@ module RDoc::Encoding
60
60
  # Sets the encoding of +string+ based on the magic comment
61
61
 
62
62
  def self.set_encoding string
63
- return unless Object.const_defined? :Encoding
64
-
65
63
  first_line = string[/\A(?:#!.*\n)?.*\n/]
66
64
 
67
65
  name = case first_line
@@ -70,6 +68,10 @@ module RDoc::Encoding
70
68
  else return
71
69
  end
72
70
 
71
+ string.sub! first_line, ''
72
+
73
+ return unless Object.const_defined? :Encoding
74
+
73
75
  enc = Encoding.find name
74
76
  string.force_encoding enc if enc
75
77
  end
@@ -63,6 +63,11 @@ class RDoc::Generator::Darkfish
63
63
 
64
64
  VERSION = '2'
65
65
 
66
+ ##
67
+ # Description of this generator
68
+
69
+ DESCRIPTION = 'HTML generator, written by Michael Granger'
70
+
66
71
  ##
67
72
  # Initialize a few instance variables before we start
68
73
 
@@ -8,6 +8,11 @@ class RDoc::Generator::RI
8
8
 
9
9
  RDoc::RDoc.add_generator self
10
10
 
11
+ ##
12
+ # Description of this generator
13
+
14
+ DESCRIPTION = 'creates ri data files'
15
+
11
16
  ##
12
17
  # Set up a new ri generator
13
18
 
@@ -134,7 +134,7 @@
134
134
  <% end %>
135
135
 
136
136
  <div id="classindex-section" class="section project-section">
137
- <h3 class="section-header">Class Index
137
+ <h3 class="section-header">Class/Module Index
138
138
  <span class="search-toggle"><img src="<%= rel_prefix %>/images/find.png"
139
139
  height="16" width="16" alt="[+]"
140
140
  title="show/hide quicksearch" /></span></h3>
@@ -225,16 +225,22 @@
225
225
  <div id="<%= method.html_name %>-method" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
226
226
  <a name="<%= h method.aref %>"></a>
227
227
 
228
- <div class="method-heading">
229
228
  <% if method.call_seq %>
230
- <span class="method-callseq"><%= method.call_seq.strip.gsub(/->/, '&rarr;').gsub( /^\w.+\./m, '') %></span>
229
+ <% method.call_seq.strip.split("\n").each_with_index do |call_seq, i| %>
230
+ <div class="method-heading">
231
+ <span class="method-callseq"><%= call_seq.strip.gsub(/->/, '&rarr;').gsub( /^\w.+\./m, '') %></span>
232
+ <% if i == 0 %>
231
233
  <span class="method-click-advice">click to toggle source</span>
234
+ <% end %>
235
+ </div>
236
+ <% end %>
232
237
  <% else %>
238
+ <div class="method-heading">
233
239
  <span class="method-name"><%= h method.name %></span><span
234
240
  class="method-args"><%= method.params %></span>
235
241
  <span class="method-click-advice">click to toggle source</span>
236
- <% end %>
237
242
  </div>
243
+ <% end %>
238
244
 
239
245
  <div class="method-description">
240
246
  <% if method.comment %>
@@ -26,6 +26,11 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
26
26
  attr_reader :in_list_entry # :nodoc:
27
27
  attr_reader :list # :nodoc:
28
28
 
29
+ ##
30
+ # Path to this document for relative links
31
+
32
+ attr_accessor :from_path
33
+
29
34
  ##
30
35
  # Converts a target url to one that is relative to a given path
31
36
 
@@ -59,6 +64,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
59
64
  @th = nil
60
65
  @in_list_entry = nil
61
66
  @list = nil
67
+ @from_path = ''
62
68
 
63
69
  # external hyperlinks
64
70
  @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
@@ -79,8 +85,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
79
85
  end
80
86
 
81
87
  ##
82
- # Generate a hyperlink for url, labeled with text. Handle the
83
- # special cases for img: and link: described under handle_special_HYPERLINK
88
+ # Generate a hyperlink for +url+, labeled with +text+. Handles the special
89
+ # cases for img: and link: described under handle_special_HYPERLINK
84
90
 
85
91
  def gen_url(url, text)
86
92
  if url =~ /([A-Za-z]+):(.*)/ then
@@ -240,6 +240,32 @@ class RDoc::Options
240
240
  @title ||= string
241
241
  end
242
242
 
243
+ ##
244
+ # Returns a properly-space list of generators and their descriptions.
245
+
246
+ def generator_descriptions
247
+ lengths = []
248
+
249
+ generators = RDoc::RDoc::GENERATORS.map do |name, generator|
250
+ lengths << name.length
251
+
252
+ description = generator::DESCRIPTION if
253
+ generator.const_defined? :DESCRIPTION
254
+
255
+ [name, description]
256
+ end
257
+
258
+ longest = lengths.max
259
+
260
+ generators.sort.map do |name, description|
261
+ if description then
262
+ " %-*s - %s" % [longest, name, description]
263
+ else
264
+ " #{name}"
265
+ end
266
+ end.join "\n"
267
+ end
268
+
243
269
  ##
244
270
  # Parse command line options.
245
271
 
@@ -274,8 +300,9 @@ Usage: #{opt.program_name} [options] [names...]
274
300
  will make rdoc show hashes in method links by default. Command-line options
275
301
  always will override those in RDOCOPT.
276
302
 
277
- - Darkfish creates frameless HTML output by Michael Granger.
278
- - ri creates ri data files
303
+ Available formatters:
304
+
305
+ #{generator_descriptions}
279
306
 
280
307
  RDoc understands the following file formats:
281
308
 
@@ -371,7 +371,7 @@ class RDoc::Parser::C < RDoc::Parser
371
371
 
372
372
  def find_body(class_name, meth_name, meth_obj, body, quiet = false)
373
373
  case body
374
- when %r%((?>/\*.*?\*/\s*))
374
+ when %r%((?>/\*.*?\*/\s*)?)
375
375
  ((?:(?:static|SWIGINTERN)\s+)?
376
376
  (?:intern\s+)?VALUE\s+#{meth_name}
377
377
  \s*(\([^)]*\))([^;]|$))%xm then
@@ -547,7 +547,7 @@ class RDoc::Parser::C < RDoc::Parser
547
547
  # with ARGF at the same indent, but that are after the first description
548
548
  # paragraph.
549
549
 
550
- if comment =~ /call-seq:(.*?[^\s\*].*?)^\s*\*?\s*$/m then
550
+ if comment =~ /call-seq:(.*?(?:\S|\*\/?).*?)^\s*(?:\*\/?)?\s*$/m then
551
551
  all_start, all_stop = $~.offset(0)
552
552
  seq_start, seq_stop = $~.offset(1)
553
553
 
@@ -224,9 +224,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
224
224
  ##
225
225
  # Look for a 'call-seq' in the comment, and override the normal parameter
226
226
  # stuff
227
+ #--
228
+ # TODO handle undent
227
229
 
228
230
  def extract_call_seq(comment, meth)
229
- if comment.sub!(/:?call-seq:(.*?)^\s*\#?\s*$/m, '') then
231
+ if comment.sub!(/:?call-seq:(.*?)(^\s*#?\s*$|\z)/m, '') then
230
232
  seq = $1
231
233
  seq.gsub!(/^\s*\#\s*/, '')
232
234
  meth.call_seq = seq
@@ -779,6 +781,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
779
781
 
780
782
  @stats.add_attribute att
781
783
  end
784
+
785
+ true
782
786
  end
783
787
 
784
788
  ##
@@ -1230,10 +1234,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
1230
1234
  if TkCOMMENT === tk then
1231
1235
  if non_comment_seen then
1232
1236
  # Look for RDoc in a comment about to be thrown away
1233
- parse_comment container, tk, comment unless comment.empty?
1237
+ non_comment_seen = parse_comment container, tk, comment unless
1238
+ comment.empty?
1234
1239
 
1235
1240
  comment = ''
1236
- non_comment_seen = false
1237
1241
  end
1238
1242
 
1239
1243
  while TkCOMMENT === tk do
@@ -1360,6 +1364,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
1360
1364
 
1361
1365
  return
1362
1366
  end
1367
+ else
1368
+ non_comment_seen = parse_comment container, tk, comment unless
1369
+ comment.empty?
1370
+
1371
+ comment = ''
1363
1372
  end
1364
1373
 
1365
1374
  comment = '' unless keep_comment
@@ -610,7 +610,7 @@ Options may also be set in the 'RI' environment variable.
610
610
  end
611
611
 
612
612
  if class_methods or instance_methods or not klass.constants.empty? then
613
- out << RDoc::Markup::Rule.new
613
+ out << RDoc::Markup::Rule.new(1)
614
614
  end
615
615
 
616
616
  unless klass.constants.empty? then
@@ -19,8 +19,13 @@ module RDoc::RI::Paths
19
19
  SYSDIR = File.join base, "system"
20
20
  SITEDIR = File.join base, "site"
21
21
 
22
- homedir = File.expand_path('~') ||
23
- ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
22
+ homedir = begin
23
+ File.expand_path('~')
24
+ rescue ArgumentError
25
+ end
26
+
27
+ homedir ||= ENV['HOME'] ||
28
+ ENV['USERPROFILE'] || ENV['HOMEPATH'] # for 1.8 compatibility
24
29
 
25
30
  HOMEDIR = if homedir then
26
31
  File.join homedir, ".rdoc"
@@ -541,12 +541,12 @@ class RDoc::RubyLex
541
541
  catch(:RET) do
542
542
  if @lex_state == EXPR_ARG
543
543
  if @space_seen and peek(0) =~ /[0-9]/
544
- throw :RET, identify_number
544
+ throw :RET, identify_number(op)
545
545
  else
546
546
  @lex_state = EXPR_BEG
547
547
  end
548
548
  elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
549
- throw :RET, identify_number
549
+ throw :RET, identify_number(op)
550
550
  else
551
551
  @lex_state = EXPR_BEG
552
552
  end
@@ -1010,10 +1010,10 @@ class RDoc::RubyLex
1010
1010
  identify_string(lt, @quoted)
1011
1011
  end
1012
1012
 
1013
- def identify_number
1013
+ def identify_number(op = "")
1014
1014
  @lex_state = EXPR_END
1015
1015
 
1016
- num = ''
1016
+ num = op
1017
1017
 
1018
1018
  if peek(0) == "0" && peek(1) !~ /[.eE]/
1019
1019
  num << getc
@@ -24,6 +24,7 @@ class RDoc::Stats
24
24
  @files_so_far = 0
25
25
  @num_files = num_files
26
26
  @fully_documented = nil
27
+ @percent_doc = nil
27
28
 
28
29
  @start = Time.now
29
30
 
@@ -215,7 +216,9 @@ class RDoc::Stats
215
216
  report << nil
216
217
 
217
218
  cm.each_constant do |constant|
218
- next if constant.documented?
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
219
222
  report << " # in file #{constant.file.full_name}"
220
223
  report << " #{constant.name} = nil"
221
224
  end
@@ -255,22 +258,36 @@ class RDoc::Stats
255
258
  def summary
256
259
  calculate
257
260
 
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
+
258
271
  report = []
259
- report << 'Files: %5d' % @num_files
272
+ report << 'Files: %*d' % [num_width, @num_files]
273
+
260
274
  report << nil
261
- report << 'Classes: %5d (%5d undocumented)' % [@num_classes,
262
- @undoc_classes]
263
- report << 'Modules: %5d (%5d undocumented)' % [@num_modules,
264
- @undoc_modules]
265
- report << 'Constants: %5d (%5d undocumented)' % [@num_constants,
266
- @undoc_constants]
267
- report << 'Attributes: %5d (%5d undocumented)' % [@num_attributes,
268
- @undoc_attributes]
269
- report << 'Methods: %5d (%5d undocumented)' % [@num_methods,
270
- @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
+
271
287
  report << nil
272
- report << 'Total: %5d (%5d undocumented)' % [@num_items,
273
- @undoc_items]
288
+
289
+ report << 'Total: %*d (%*d undocumented)' % [
290
+ num_width, @num_items, nodoc_width, @undoc_items]
274
291
 
275
292
  report << '%6.2f%% documented' % @percent_doc if @percent_doc
276
293
  report << nil
@@ -53,6 +53,9 @@ require 'rake/tasklib'
53
53
  #
54
54
  # Simple Example:
55
55
  #
56
+ # gem 'rdoc'
57
+ # require 'rdoc/task'
58
+ #
56
59
  # RDoc::Task.new do |rd|
57
60
  # rd.main = "README.rdoc"
58
61
  # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
@@ -67,6 +70,9 @@ require 'rake/tasklib'
67
70
  # generating two sets of documentation. For instance, if you want to have a
68
71
  # development set of documentation including private methods:
69
72
  #
73
+ # gem 'rdoc'
74
+ # require 'rdoc/task'
75
+ #
70
76
  # RDoc::Task.new :rdoc_dev do |rd|
71
77
  # rd.main = "README.doc"
72
78
  # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
@@ -82,6 +88,9 @@ require 'rake/tasklib'
82
88
  #
83
89
  # For example:
84
90
  #
91
+ # gem 'rdoc'
92
+ # require 'rdoc/task'
93
+ #
85
94
  # RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean",
86
95
  # :rerdoc => "rdoc:force")
87
96
  #
@@ -116,6 +125,11 @@ class RDoc::Task < Rake::TaskLib
116
125
 
117
126
  attr_accessor :template
118
127
 
128
+ ##
129
+ # Name of format generator (--fmt) used by rdoc. (defaults to rdoc's default)
130
+
131
+ attr_accessor :generator
132
+
119
133
  ##
120
134
  # List of files to be included in the rdoc generation. (default is [])
121
135
 
@@ -151,11 +165,27 @@ class RDoc::Task < Rake::TaskLib
151
165
  @main = nil
152
166
  @title = nil
153
167
  @template = nil
168
+ @generator = nil
154
169
  @options = []
155
170
  yield self if block_given?
156
171
  define
157
172
  end
158
173
 
174
+ ##
175
+ # All source is inline now. This method is deprecated
176
+
177
+ def inline_source() # :nodoc:
178
+ warn "RDoc::Task#inline_source is deprecated"
179
+ true
180
+ end
181
+
182
+ ##
183
+ # All source is inline now. This method is deprecated
184
+
185
+ def inline_source=(value) # :nodoc:
186
+ warn "RDoc::Task#inline_source is deprecated"
187
+ end
188
+
159
189
  ##
160
190
  # Create the tasks defined by this task lib.
161
191
 
@@ -201,9 +231,10 @@ class RDoc::Task < Rake::TaskLib
201
231
  def option_list
202
232
  result = @options.dup
203
233
  result << "-o" << @rdoc_dir
204
- result << "--main" << main if main
205
- result << "--title" << title if title
206
- result << "-T" << template if template
234
+ result << "--main" << main if main
235
+ result << "--title" << title if title
236
+ result << "-T" << template if template
237
+ result << '-f' << generator if generator
207
238
  result
208
239
  end
209
240
 
@@ -30,7 +30,7 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
30
30
  expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
31
31
 
32
32
  contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
33
- assert_equal expected, contents
33
+ assert_equal "hi everybody", contents
34
34
  assert_equal Encoding::UTF_8, contents.encoding
35
35
  end
36
36
 
@@ -46,7 +46,7 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
46
46
 
47
47
  contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
48
48
  assert_equal Encoding::UTF_8, contents.encoding
49
- assert_equal "# coding: ISO-8859-1\nhi \u00e9verybody", contents.sub("\r", '')
49
+ assert_equal "hi \u00e9verybody", contents.sub("\r", '')
50
50
  end
51
51
 
52
52
  def test_class_read_file_encoding_fancy
@@ -62,7 +62,7 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
62
62
  expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /win32|mingw32/
63
63
 
64
64
  contents = RDoc::Encoding.read_file @tempfile.path, Encoding::UTF_8
65
- assert_equal expected, contents
65
+ assert_equal "hi everybody", contents
66
66
  assert_equal Encoding::UTF_8, contents.encoding
67
67
  end
68
68
 
@@ -115,6 +115,20 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
115
115
  assert_equal Encoding::UTF_8, s.encoding
116
116
  end
117
117
 
118
+ def test_class_set_encoding_strip
119
+ s = "# coding: UTF-8\n# more comments"
120
+
121
+ RDoc::Encoding.set_encoding s
122
+
123
+ assert_equal "# more comments", s
124
+
125
+ s = "#!/bin/ruby\n# coding: UTF-8\n# more comments"
126
+
127
+ RDoc::Encoding.set_encoding s
128
+
129
+ assert_equal "# more comments", s
130
+ end
131
+
118
132
  def test_class_set_encoding_bad
119
133
  skip "Encoding not implemented" unless Object.const_defined? :Encoding
120
134
 
@@ -141,5 +155,12 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
141
155
  end
142
156
  end
143
157
 
158
+ def test_sanity
159
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
160
+
161
+ assert_equal Encoding::US_ASCII, ''.encoding,
162
+ 'If this file is not ASCII tests may incorrectly pass'
163
+ end
164
+
144
165
  end
145
166
 
@@ -297,6 +297,11 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
297
297
  assert_equal '&lt;&gt;', @to.convert_string('<>')
298
298
  end
299
299
 
300
+ def test_gen_url
301
+ assert_equal '<a href="example">example</a>',
302
+ @to.gen_url('link:example', 'example')
303
+ end
304
+
300
305
  def test_list_verbatim_2
301
306
  str = "* one\n verb1\n verb2\n* two\n"
302
307
 
@@ -9,6 +9,11 @@ class TestRDocOptions < MiniTest::Unit::TestCase
9
9
 
10
10
  def setup
11
11
  @options = RDoc::Options.new
12
+ @generators = RDoc::RDoc::GENERATORS.dup
13
+ end
14
+
15
+ def teardown
16
+ RDoc::RDoc::GENERATORS.replace @generators
12
17
  end
13
18
 
14
19
  def test_check_files
@@ -47,6 +52,20 @@ file 'unreadable' not readable
47
52
  assert_equal Encoding.default_external, @options.encoding
48
53
  end
49
54
 
55
+ def test_generator_descriptions
56
+ # HACK autotest/isolate should take care of this
57
+ RDoc::RDoc::GENERATORS.clear
58
+ RDoc::RDoc::GENERATORS['darkfish'] = RDoc::Generator::Darkfish
59
+ RDoc::RDoc::GENERATORS['ri'] = RDoc::Generator::RI
60
+
61
+ expected = <<-EXPECTED.chomp
62
+ darkfish - HTML generator, written by Michael Granger
63
+ ri - creates ri data files
64
+ EXPECTED
65
+
66
+ assert_equal expected, @options.generator_descriptions
67
+ end
68
+
50
69
  def test_parse_dash_p
51
70
  out, err = capture_io do
52
71
  @options.parse %w[-p]
@@ -178,6 +197,27 @@ file 'unreadable' not readable
178
197
  assert_equal 1, out.scan(/ri generator options:/). length
179
198
  end
180
199
 
200
+ def test_parse_help_extra_generator
201
+ RDoc::RDoc::GENERATORS['test'] = Class.new do
202
+ def self.setup_options options
203
+ op = options.option_parser
204
+
205
+ op.separator 'test generator options:'
206
+ end
207
+ end
208
+
209
+ out, = capture_io do
210
+ begin
211
+ @options.parse %w[--help]
212
+ rescue SystemExit
213
+ end
214
+ end
215
+
216
+ assert_equal 1, out.scan(/HTML generator options:/).length
217
+ assert_equal 1, out.scan(/ri generator options:/). length
218
+ assert_equal 1, out.scan(/test generator options:/).length
219
+ end
220
+
181
221
  def test_parse_ignore_invalid
182
222
  out, err = capture_io do
183
223
  @options.parse %w[--ignore-invalid --bogus]
@@ -278,12 +318,13 @@ file 'unreadable' not readable
278
318
  end
279
319
 
280
320
  def test_setup_generator
281
- test_generator = Object.new
282
- def test_generator.setup_options(op)
283
- @op = op
284
- end
321
+ test_generator = Class.new do
322
+ def self.setup_options op
323
+ @op = op
324
+ end
285
325
 
286
- def test_generator.op() @op end
326
+ def self.op() @op end
327
+ end
287
328
 
288
329
  RDoc::RDoc::GENERATORS['TestGenerator'] = test_generator
289
330
 
@@ -293,6 +334,8 @@ file 'unreadable' not readable
293
334
  assert_equal [test_generator], @options.generator_options
294
335
 
295
336
  assert_equal @options, test_generator.op
337
+ ensure
338
+ RDoc::RDoc::GENERATORS.delete 'TestGenerator'
296
339
  end
297
340
 
298
341
  end
@@ -28,6 +28,11 @@ class TestRDocParser < MiniTest::Unit::TestCase
28
28
  refute @RP.binary?(file_name)
29
29
  end
30
30
 
31
+ def test_class_binary_large_japanese_rdoc
32
+ file_name = File.expand_path '../test.ja.large.rdoc', __FILE__
33
+ assert !@RP.binary?(file_name)
34
+ end
35
+
31
36
  def test_class_binary_japanese_rdoc
32
37
  skip "Encoding not implemented" unless Object.const_defined? :Encoding
33
38
 
@@ -532,6 +532,46 @@ Init_Foo(void) {
532
532
  assert_equal "VALUE\nother_function() ", code
533
533
  end
534
534
 
535
+ def test_find_body_2
536
+ content = <<-CONTENT
537
+ /* Copyright (C) 2010 Sven Herzberg
538
+ *
539
+ * This file is free software; the author(s) gives unlimited
540
+ * permission to copy and/or distribute it, with or without
541
+ * modifications, as long as this notice is preserved.
542
+ */
543
+
544
+ #include <ruby.h>
545
+
546
+ static VALUE
547
+ wrap_initialize (VALUE self)
548
+ {
549
+ return self;
550
+ }
551
+
552
+ /* */
553
+ static VALUE
554
+ wrap_shift (VALUE self,
555
+ VALUE arg)
556
+ {
557
+ return self;
558
+ }
559
+
560
+ void
561
+ init_gi_repository (void)
562
+ {
563
+ VALUE mTest = rb_define_module ("Test");
564
+ VALUE cTest = rb_define_class_under (mTest, "Test", rb_cObject);
565
+
566
+ rb_define_method (cTest, "initialize", wrap_initialize, 0);
567
+ rb_define_method (cTest, "shift", wrap_shift, 0);
568
+ }
569
+ CONTENT
570
+
571
+ klass = util_get_class content, 'cTest'
572
+ assert_equal 2, klass.method_list.length
573
+ end
574
+
535
575
  def test_find_body_define
536
576
  content = <<-EOF
537
577
  /*
@@ -633,6 +673,31 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
633
673
  assert_equal expected, method_obj.call_seq
634
674
  end
635
675
 
676
+ def test_find_modifiers_call_seq_no_blank
677
+ comment = <<-COMMENT
678
+ /* call-seq:
679
+ * commercial() -> Date <br />
680
+ * commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
681
+ * commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
682
+ */
683
+
684
+ COMMENT
685
+
686
+ parser = util_parser ''
687
+ method_obj = RDoc::AnyMethod.new nil, 'blah'
688
+
689
+ parser.find_modifiers comment, method_obj
690
+
691
+ expected = <<-CALL_SEQ.chomp
692
+ commercial() -> Date <br />
693
+ commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
694
+ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
695
+
696
+ CALL_SEQ
697
+
698
+ assert_equal expected, method_obj.call_seq
699
+ end
700
+
636
701
  def test_find_modifiers_nodoc
637
702
  comment = <<-COMMENT
638
703
  /* :nodoc:
@@ -32,6 +32,66 @@ class TestRDocParserRuby < MiniTest::Unit::TestCase
32
32
  @tempfile2.close
33
33
  end
34
34
 
35
+ def test_extract_call_seq
36
+ m = RDoc::AnyMethod.new nil, 'm'
37
+ p = util_parser ''
38
+
39
+ comment = <<-COMMENT
40
+ # call-seq:
41
+ # bla => true or false
42
+ #
43
+ # moar comment
44
+ COMMENT
45
+
46
+ p.extract_call_seq comment, m
47
+
48
+ assert_equal "bla => true or false\n", m.call_seq
49
+ end
50
+
51
+ def test_extract_call_seq_blank
52
+ m = RDoc::AnyMethod.new nil, 'm'
53
+ p = util_parser ''
54
+
55
+ comment = <<-COMMENT
56
+ # call-seq:
57
+ # bla => true or false
58
+ #
59
+ COMMENT
60
+
61
+ p.extract_call_seq comment, m
62
+
63
+ assert_equal "bla => true or false\n", m.call_seq
64
+ end
65
+
66
+ def test_extract_call_seq_no_blank
67
+ m = RDoc::AnyMethod.new nil, 'm'
68
+ p = util_parser ''
69
+
70
+ comment = <<-COMMENT
71
+ # call-seq:
72
+ # bla => true or false
73
+ COMMENT
74
+
75
+ p.extract_call_seq comment, m
76
+
77
+ assert_equal "bla => true or false\n", m.call_seq
78
+ end
79
+
80
+ def test_extract_call_seq_undent
81
+ m = RDoc::AnyMethod.new nil, 'm'
82
+ p = util_parser ''
83
+
84
+ comment = <<-COMMENT
85
+ # call-seq:
86
+ # bla => true or false
87
+ # moar comment
88
+ COMMENT
89
+
90
+ p.extract_call_seq comment, m
91
+
92
+ assert_equal "bla => true or false\nmoar comment\n", m.call_seq
93
+ end
94
+
35
95
  def test_get_symbol_or_name
36
96
  util_parser "* & | + 5 / 4"
37
97
 
@@ -503,6 +563,35 @@ end
503
563
  assert_equal @top_level, blah.file
504
564
  end
505
565
 
566
+ def test_parse_class_multi_ghost_methods
567
+ util_parser <<-'CLASS'
568
+ class Foo
569
+ ##
570
+ # :method: one
571
+ #
572
+ # my method
573
+
574
+ ##
575
+ # :method: two
576
+ #
577
+ # my method
578
+
579
+ [:one, :two].each do |t|
580
+ eval("def #{t}; \"#{t}\"; end")
581
+ end
582
+ end
583
+ CLASS
584
+
585
+ tk = @parser.get_tk
586
+
587
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
588
+
589
+ foo = @top_level.classes.first
590
+ assert_equal 'Foo', foo.full_name
591
+
592
+ assert_equal 2, foo.method_list.length
593
+ end
594
+
506
595
  def test_parse_class_nested_superclass
507
596
  util_top_level
508
597
  foo = @top_level.add_module RDoc::NormalModule, 'Foo'
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+ require 'rdoc/rdoc'
4
+ require 'rdoc/ruby_lex'
5
+
6
+ class TestRubyLex < MiniTest::Unit::TestCase
7
+ def test_unary_minus
8
+ ruby_lex = RDoc::RubyLex.new("-1", nil)
9
+ assert_equal("-1", ruby_lex.token.value)
10
+
11
+ ruby_lex = RDoc::RubyLex.new("a[-2]", nil)
12
+ 2.times { ruby_lex.token } # skip "a" and "["
13
+ assert_equal("-2", ruby_lex.token.value)
14
+
15
+ ruby_lex = RDoc::RubyLex.new("a[0..-12]", nil)
16
+ 4.times { ruby_lex.token } # skip "a", "[", "0", and ".."
17
+ assert_equal("-12", ruby_lex.token.value)
18
+
19
+ ruby_lex = RDoc::RubyLex.new("0+-0.1", nil)
20
+ 2.times { ruby_lex.token } # skip "0" and "+"
21
+ assert_equal("-0.1", ruby_lex.token.value)
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+ require 'rdoc/stats'
4
+ require 'rdoc/code_objects'
5
+ require 'rdoc/markup'
6
+ require 'rdoc/parser'
7
+
8
+ class TestRDocStats < MiniTest::Unit::TestCase
9
+
10
+ def setup
11
+ RDoc::TopLevel.reset
12
+
13
+ @s = RDoc::Stats.new 0
14
+ end
15
+
16
+ def test_report_constant_alias
17
+ tl = RDoc::TopLevel.new 'fake.rb'
18
+ mod = tl.add_module RDoc::NormalModule, 'M'
19
+
20
+ c = tl.add_class RDoc::NormalClass, 'C'
21
+ mod.add_constant c
22
+
23
+ ca = RDoc::Constant.new 'CA', nil, nil
24
+ ca.is_alias_for = c
25
+
26
+ tl.add_constant ca
27
+
28
+ RDoc::TopLevel.complete :public
29
+
30
+ report = @s.report
31
+
32
+ # TODO change this to refute match, aliases should be ignored as they are
33
+ # programmer convenience constructs
34
+ assert_match(/class Object/, report)
35
+ end
36
+
37
+ end
38
+
@@ -8,6 +8,26 @@ class TestRDocTask < MiniTest::Unit::TestCase
8
8
  Rake::Task.clear
9
9
  end
10
10
 
11
+ def test_inline_source
12
+ t = RDoc::Task.new
13
+
14
+ _, err = capture_io do
15
+ assert t.inline_source
16
+ end
17
+
18
+ assert_equal "RDoc::Task#inline_source is deprecated\n", err
19
+
20
+ _, err = capture_io do
21
+ t.inline_source = false
22
+ end
23
+
24
+ assert_equal "RDoc::Task#inline_source is deprecated\n", err
25
+
26
+ capture_io do
27
+ assert t.inline_source
28
+ end
29
+ end
30
+
11
31
  def test_tasks_creation
12
32
  RDoc::Task.new
13
33
  assert Rake::Task[:rdoc]
@@ -23,6 +43,14 @@ class TestRDocTask < MiniTest::Unit::TestCase
23
43
  assert_equal :rdoc_dev, rd.name
24
44
  end
25
45
 
46
+ def test_generator_option
47
+ rdoc_task = RDoc::Task.new do |rd|
48
+ rd.generator = "ri"
49
+ end
50
+
51
+ assert_equal %w[-o html -f ri], rdoc_task.option_list
52
+ end
53
+
26
54
  def test_tasks_creation_with_custom_name_string
27
55
  rd = RDoc::Task.new("rdoc_dev")
28
56
  assert Rake::Task[:rdoc_dev]
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
- - 0
9
8
  - 1
10
- version: 3.0.1
9
+ version: "3.1"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Eric Hodel
@@ -39,7 +38,7 @@ cert_chain:
39
38
  x52qPcexcYZR7w==
40
39
  -----END CERTIFICATE-----
41
40
 
42
- date: 2010-12-19 00:00:00 -08:00
41
+ date: 2010-12-28 00:00:00 -08:00
43
42
  default_executable:
44
43
  dependencies:
45
44
  - !ruby/object:Gem::Dependency
@@ -62,6 +61,22 @@ dependencies:
62
61
  name: minitest
63
62
  prerelease: false
64
63
  requirement: &id002 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 11
69
+ segments:
70
+ - 2
71
+ - 0
72
+ - 2
73
+ version: 2.0.2
74
+ type: :development
75
+ version_requirements: *id002
76
+ - !ruby/object:Gem::Dependency
77
+ name: minitest
78
+ prerelease: false
79
+ requirement: &id003 !ruby/object:Gem::Requirement
65
80
  none: false
66
81
  requirements:
67
82
  - - ~>
@@ -71,11 +86,25 @@ dependencies:
71
86
  - 2
72
87
  version: "2"
73
88
  type: :development
74
- version_requirements: *id002
89
+ version_requirements: *id003
90
+ - !ruby/object:Gem::Dependency
91
+ name: isolate
92
+ prerelease: false
93
+ requirement: &id004 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ hash: 5
99
+ segments:
100
+ - 3
101
+ version: "3"
102
+ type: :development
103
+ version_requirements: *id004
75
104
  - !ruby/object:Gem::Dependency
76
105
  name: hoe
77
106
  prerelease: false
78
- requirement: &id003 !ruby/object:Gem::Requirement
107
+ requirement: &id005 !ruby/object:Gem::Requirement
79
108
  none: false
80
109
  requirements:
81
110
  - - ">="
@@ -87,15 +116,11 @@ dependencies:
87
116
  - 0
88
117
  version: 2.7.0
89
118
  type: :development
90
- version_requirements: *id003
119
+ version_requirements: *id005
91
120
  description: |-
92
- RDoc is an application that produces documentation for one or more Ruby source
93
- files. RDoc includes the +rdoc+ and +ri+ tools for generating and displaying
94
- online documentation.
95
-
96
- At this point in time, RDoc 2.x is a work in progress and may incur further
97
- API changes beyond what has been made to RDoc 1.0.1. Command-line tools are
98
- largely unaffected, but internal APIs may shift rapidly.
121
+ RDoc produces HTML and command-line documentation for Ruby projects. RDoc
122
+ includes the +rdoc+ and +ri+ tools for generating and displaying online
123
+ documentation.
99
124
 
100
125
  See RDoc for a description of RDoc's markup and basic use.
101
126
  email:
@@ -274,6 +299,8 @@ files:
274
299
  - test/test_rdoc_top_level.rb
275
300
  - test/xref_data.rb
276
301
  - test/xref_test_case.rb
302
+ - test/test_rdoc_ruby_lex.rb
303
+ - test/test_rdoc_stats.rb
277
304
  has_rdoc: true
278
305
  homepage: http://rdoc.rubyforge.org
279
306
  licenses: []
@@ -326,7 +353,7 @@ rubyforge_project: rdoc
326
353
  rubygems_version: 1.3.7
327
354
  signing_key:
328
355
  specification_version: 3
329
- summary: RDoc is an application that produces documentation for one or more Ruby source files
356
+ summary: RDoc produces HTML and command-line documentation for Ruby projects
330
357
  test_files:
331
358
  - test/test_attribute_manager.rb
332
359
  - test/test_rdoc_alias.rb
@@ -365,6 +392,8 @@ test_files:
365
392
  - test/test_rdoc_ri_driver.rb
366
393
  - test/test_rdoc_ri_paths.rb
367
394
  - test/test_rdoc_ri_store.rb
395
+ - test/test_rdoc_ruby_lex.rb
396
+ - test/test_rdoc_stats.rb
368
397
  - test/test_rdoc_task.rb
369
398
  - test/test_rdoc_text.rb
370
399
  - test/test_rdoc_top_level.rb
metadata.gz.sig CHANGED
Binary file