rdoc 4.0.0.preview2.1 → 4.0.0.rc.2

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 (64) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CVE-2013-0256.rdoc +49 -0
  5. data/History.rdoc +33 -1
  6. data/Manifest.txt +3 -1
  7. data/Rakefile +2 -1
  8. data/lib/rdoc.rb +1 -1
  9. data/lib/rdoc/any_method.rb +2 -0
  10. data/lib/rdoc/attr.rb +2 -0
  11. data/lib/rdoc/class_module.rb +1 -0
  12. data/lib/rdoc/code_object.rb +7 -0
  13. data/lib/rdoc/cross_reference.rb +1 -1
  14. data/lib/rdoc/encoding.rb +3 -1
  15. data/lib/rdoc/generator/darkfish.rb +1 -1
  16. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +9 -7
  17. data/lib/rdoc/generator/template/darkfish/rdoc.css +21 -0
  18. data/lib/rdoc/generator/template/json_index/.document +1 -0
  19. data/lib/rdoc/markup/attribute_manager.rb +5 -7
  20. data/lib/rdoc/markup/formatter.rb +75 -0
  21. data/lib/rdoc/markup/to_html.rb +9 -57
  22. data/lib/rdoc/markup/to_markdown.rb +55 -0
  23. data/lib/rdoc/parser.rb +35 -11
  24. data/lib/rdoc/parser/changelog.rb +9 -1
  25. data/lib/rdoc/parser/ruby.rb +23 -4
  26. data/lib/rdoc/rd/block_parser.rb +3 -2
  27. data/lib/rdoc/rd/block_parser.ry +3 -2
  28. data/lib/rdoc/rd/inline_parser.rb +1 -1
  29. data/lib/rdoc/rd/inline_parser.ry +1 -1
  30. data/lib/rdoc/ruby_lex.rb +20 -4
  31. data/lib/rdoc/ruby_token.rb +1 -0
  32. data/lib/rdoc/servlet.rb +25 -16
  33. data/lib/rdoc/store.rb +9 -4
  34. data/lib/rdoc/tom_doc.rb +1 -1
  35. data/lib/rdoc/top_level.rb +2 -1
  36. data/test/{test.ja.large.rdoc → test.ja.largedoc} +0 -0
  37. data/test/test_rdoc_any_method.rb +16 -7
  38. data/test/test_rdoc_attr.rb +4 -0
  39. data/test/test_rdoc_class_module.rb +2 -0
  40. data/test/test_rdoc_comment.rb +1 -1
  41. data/test/test_rdoc_constant.rb +4 -0
  42. data/test/test_rdoc_cross_reference.rb +15 -0
  43. data/test/test_rdoc_encoding.rb +1 -1
  44. data/test/test_rdoc_generator_markup.rb +4 -1
  45. data/test/test_rdoc_markup_formatter.rb +91 -0
  46. data/test/test_rdoc_markup_to_html.rb +52 -23
  47. data/test/test_rdoc_markup_to_markdown.rb +31 -0
  48. data/test/test_rdoc_options.rb +11 -0
  49. data/test/test_rdoc_parser.rb +50 -5
  50. data/test/test_rdoc_parser_c.rb +34 -11
  51. data/test/test_rdoc_parser_changelog.rb +32 -4
  52. data/test/test_rdoc_parser_markdown.rb +11 -5
  53. data/test/test_rdoc_parser_rd.rb +15 -5
  54. data/test/test_rdoc_parser_ruby.rb +23 -0
  55. data/test/test_rdoc_rd_block_parser.rb +141 -123
  56. data/test/test_rdoc_rd_inline_parser.rb +6 -1
  57. data/test/test_rdoc_rdoc.rb +5 -2
  58. data/test/test_rdoc_ruby_lex.rb +51 -5
  59. data/test/test_rdoc_servlet.rb +43 -5
  60. data/test/test_rdoc_store.rb +55 -4
  61. data/test/test_rdoc_tom_doc.rb +37 -0
  62. data/test/test_rdoc_top_level.rb +17 -1
  63. metadata +29 -34
  64. metadata.gz.sig +0 -0
data/lib/rdoc/tom_doc.rb CHANGED
@@ -218,7 +218,7 @@ class RDoc::TomDoc < RDoc::Markup::Parser
218
218
  @tokens << [:HEADER, 3, *token_pos(pos)]
219
219
 
220
220
  [:TEXT, @s[1], *token_pos(pos)]
221
- when @s.scan(/([:\w]\w*)[ ]+- /) then
221
+ when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
222
222
  [:NOTE, @s[1], *token_pos(pos)]
223
223
  else
224
224
  @s.scan(/.*/)
@@ -187,6 +187,7 @@ class RDoc::TopLevel < RDoc::Context
187
187
 
188
188
  ##
189
189
  # Dumps this TopLevel for use by ri. See also #marshal_load
190
+
190
191
  def marshal_dump
191
192
  [
192
193
  MARSHAL_VERSION,
@@ -226,7 +227,7 @@ class RDoc::TopLevel < RDoc::Context
226
227
 
227
228
  def page_name
228
229
  basename = File.basename @relative_name
229
- basename =~ /\.[^.]*$/
230
+ basename =~ /\.(rb|rdoc|txt|md)$/i
230
231
 
231
232
  $` || basename
232
233
  end
File without changes
@@ -100,24 +100,31 @@ method(a, b) { |c, d| ... }
100
100
  assert_equal section, loaded.section
101
101
  end
102
102
 
103
- def test_marshal_load
104
- instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
105
-
106
- assert_equal 'C1#m', instance_method.full_name
107
- assert_equal 'C1', instance_method.parent_name
108
- assert_equal '(foo)', instance_method.params
109
-
103
+ def test_marshal_load_aliased_method
110
104
  aliased_method = Marshal.load Marshal.dump(@c2.method_list.last)
111
105
 
112
106
  assert_equal 'C2#a', aliased_method.full_name
113
107
  assert_equal 'C2', aliased_method.parent_name
114
108
  assert_equal '()', aliased_method.params
109
+ assert aliased_method.display?
110
+ end
115
111
 
112
+ def test_marshal_load_class_method
116
113
  class_method = Marshal.load Marshal.dump(@c1.method_list.first)
117
114
 
118
115
  assert_equal 'C1::m', class_method.full_name
119
116
  assert_equal 'C1', class_method.parent_name
120
117
  assert_equal '()', class_method.params
118
+ assert class_method.display?
119
+ end
120
+
121
+ def test_marshal_load_instance_method
122
+ instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
123
+
124
+ assert_equal 'C1#m', instance_method.full_name
125
+ assert_equal 'C1', instance_method.parent_name
126
+ assert_equal '(foo)', instance_method.params
127
+ assert instance_method.display?
121
128
  end
122
129
 
123
130
  def test_marshal_load_version_0
@@ -163,6 +170,8 @@ method(a, b) { |c, d| ... }
163
170
  assert_equal nil, loaded.file
164
171
  assert_equal cm, loaded.parent
165
172
  assert_equal section, loaded.section
173
+
174
+ assert loaded.display?
166
175
  end
167
176
 
168
177
  def test_name
@@ -137,6 +137,8 @@ class TestRDocAttr < RDoc::TestCase
137
137
  # version 3
138
138
  assert_equal cm, loaded.parent
139
139
  assert_equal section, loaded.section
140
+
141
+ assert loaded.display?
140
142
  end
141
143
 
142
144
  def test_marshal_load_version_2
@@ -165,6 +167,8 @@ class TestRDocAttr < RDoc::TestCase
165
167
  # version 3
166
168
  assert_equal cm, loaded.parent
167
169
  assert_equal section, loaded.section
170
+
171
+ assert loaded.display?
168
172
  end
169
173
 
170
174
  def test_params
@@ -289,6 +289,8 @@ class TestRDocClassModule < XrefTestCase
289
289
 
290
290
  expected = { nil => s0 }
291
291
  assert_equal expected, loaded.sections_hash
292
+
293
+ assert loaded.display?
292
294
  end
293
295
 
294
296
  def test_marshal_load_version_1
@@ -70,7 +70,7 @@ call-seq:
70
70
  comment = RDoc::Comment.new <<-COMMENT, @top_level
71
71
  # call-seq:
72
72
  # bla => true or false
73
- #
73
+ #
74
74
  # moar comment
75
75
  COMMENT
76
76
 
@@ -86,6 +86,8 @@ class TestRDocConstant < XrefTestCase
86
86
  assert_nil loaded.visibility
87
87
  assert_equal cm, loaded.parent
88
88
  assert_equal section, loaded.section
89
+
90
+ assert loaded.display?
89
91
  end
90
92
 
91
93
  def test_marshal_load_version_0
@@ -116,6 +118,8 @@ class TestRDocConstant < XrefTestCase
116
118
  assert_nil loaded.visibility
117
119
  assert_equal cm, loaded.parent
118
120
  assert_equal section, loaded.section
121
+
122
+ assert loaded.display?
119
123
  end
120
124
 
121
125
  def test_marshal_round_trip
@@ -16,6 +16,14 @@ class TestRDocCrossReference < XrefTestCase
16
16
  assert_equal name, @xref.resolve(name, name)
17
17
  end
18
18
 
19
+ def test_METHOD_REGEXP_STR
20
+ re = /#{RDoc::CrossReference::METHOD_REGEXP_STR}/
21
+
22
+ re =~ '==='
23
+
24
+ assert_equal '===', $&
25
+ end
26
+
19
27
  def test_resolve_C2
20
28
  @xref = RDoc::CrossReference.new @c2
21
29
 
@@ -129,6 +137,13 @@ class TestRDocCrossReference < XrefTestCase
129
137
  assert_ref @c2_c3_m, '::C2::C3#m(*)'
130
138
  end
131
139
 
140
+ def test_resolve_method_equals3
141
+ m = RDoc::AnyMethod.new '', '==='
142
+ @c1.add_method m
143
+
144
+ assert_ref m, '==='
145
+ end
146
+
132
147
  def test_resolve_page
133
148
  page = @store.add_file 'README.txt'
134
149
  page.parser = RDoc::Parser::Simple
@@ -164,7 +164,7 @@ class TestRDocEncoding < RDoc::TestCase
164
164
 
165
165
  RDoc::Encoding.set_encoding s
166
166
 
167
- assert_equal "# more comments", s
167
+ assert_equal "#!/bin/ruby\n# more comments", s
168
168
  end
169
169
 
170
170
  def test_class_set_encoding_bad
@@ -37,7 +37,10 @@ class TestRDocGeneratorMarkup < RDoc::TestCase
37
37
  def test_description
38
38
  @comment = '= Hello'
39
39
 
40
- assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", description
40
+ links = '<span><a href="#label-Hello">&para;</a> ' +
41
+ '<a href="#documentation">&uarr;</a></span>'
42
+
43
+ assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", description
41
44
  end
42
45
 
43
46
  def test_formatter
@@ -48,6 +48,97 @@ class TestRDocMarkupFormatter < RDoc::TestCase
48
48
  @tt = @attributes.bitmap_for :TT
49
49
  end
50
50
 
51
+ def test_class_gen_relative_url
52
+ def gen(from, to)
53
+ RDoc::Markup::ToHtml.gen_relative_url from, to
54
+ end
55
+
56
+ assert_equal 'a.html', gen('a.html', 'a.html')
57
+ assert_equal 'b.html', gen('a.html', 'b.html')
58
+
59
+ assert_equal 'd.html', gen('a/c.html', 'a/d.html')
60
+ assert_equal '../a.html', gen('a/c.html', 'a.html')
61
+ assert_equal 'a/c.html', gen('a.html', 'a/c.html')
62
+ end
63
+
64
+ def special_names
65
+ @attribute_manager.special.map do |_, mask|
66
+ @attributes.as_string mask
67
+ end
68
+ end
69
+
70
+ def test_add_special_RDOCLINK
71
+ @to.add_special_RDOCLINK
72
+
73
+ assert_includes special_names, 'RDOCLINK'
74
+ end
75
+
76
+ def test_add_special_TIDYLINK
77
+ @to.add_special_TIDYLINK
78
+
79
+ assert_includes special_names, 'TIDYLINK'
80
+ end
81
+
82
+ def test_parse_url
83
+ scheme, url, id = @to.parse_url 'example/foo'
84
+
85
+ assert_equal 'http', scheme
86
+ assert_equal 'http://example/foo', url
87
+ assert_equal nil, id
88
+ end
89
+
90
+ def test_parse_url_anchor
91
+ scheme, url, id = @to.parse_url '#foottext-1'
92
+
93
+ assert_equal nil, scheme
94
+ assert_equal '#foottext-1', url
95
+ assert_equal nil, id
96
+ end
97
+
98
+ def test_parse_url_link
99
+ scheme, url, id = @to.parse_url 'link:README.txt'
100
+
101
+ assert_equal 'link', scheme
102
+ assert_equal 'README.txt', url
103
+ assert_equal nil, id
104
+ end
105
+
106
+ def test_parse_url_link_id
107
+ scheme, url, id = @to.parse_url 'link:README.txt#label-foo'
108
+
109
+ assert_equal 'link', scheme
110
+ assert_equal 'README.txt#label-foo', url
111
+ assert_equal nil, id
112
+ end
113
+
114
+ def test_parse_url_rdoc_label
115
+ scheme, url, id = @to.parse_url 'rdoc-label:foo'
116
+
117
+ assert_equal 'link', scheme
118
+ assert_equal '#foo', url
119
+ assert_equal nil, id
120
+
121
+ scheme, url, id = @to.parse_url 'rdoc-label:foo:bar'
122
+
123
+ assert_equal 'link', scheme
124
+ assert_equal '#foo', url
125
+ assert_equal ' id="bar"', id
126
+ end
127
+
128
+ def test_parse_url_scheme
129
+ scheme, url, id = @to.parse_url 'http://example/foo'
130
+
131
+ assert_equal 'http', scheme
132
+ assert_equal 'http://example/foo', url
133
+ assert_equal nil, id
134
+
135
+ scheme, url, id = @to.parse_url 'https://example/foo'
136
+
137
+ assert_equal 'https', scheme
138
+ assert_equal 'https://example/foo', url
139
+ assert_equal nil, id
140
+ end
141
+
51
142
  def test_convert_tt_special
52
143
  converted = @to.convert '<code>AAA</code>'
53
144
 
@@ -10,19 +10,6 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
10
10
  @to = RDoc::Markup::ToHtml.new @options
11
11
  end
12
12
 
13
- def test_class_gen_relative_url
14
- def gen(from, to)
15
- RDoc::Markup::ToHtml.gen_relative_url from, to
16
- end
17
-
18
- assert_equal 'a.html', gen('a.html', 'a.html')
19
- assert_equal 'b.html', gen('a.html', 'b.html')
20
-
21
- assert_equal 'd.html', gen('a/c.html', 'a/d.html')
22
- assert_equal '../a.html', gen('a/c.html', 'a.html')
23
- assert_equal 'a/c.html', gen('a.html', 'a/c.html')
24
- end
25
-
26
13
  def accept_blank_line
27
14
  assert_empty @to.res.join
28
15
  end
@@ -36,32 +23,55 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
36
23
  end
37
24
 
38
25
  def accept_heading
39
- assert_equal "\n<h5 id=\"label-Hello\">Hello</h5>\n", @to.res.join
26
+ links = '<span><a href="#label-Hello">&para;</a> ' +
27
+ '<a href="#documentation">&uarr;</a></span>'
28
+ expected = "\n<h5 id=\"label-Hello\">Hello#{links}</h5>\n"
29
+
30
+ assert_equal expected, @to.res.join
40
31
  end
41
32
 
42
33
  def accept_heading_1
43
- assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
34
+ links = '<span><a href="#label-Hello">&para;</a> ' +
35
+ '<a href="#documentation">&uarr;</a></span>'
36
+
37
+ assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
44
38
  end
45
39
 
46
40
  def accept_heading_2
47
- assert_equal "\n<h2 id=\"label-Hello\">Hello</h2>\n", @to.res.join
41
+ links = '<span><a href="#label-Hello">&para;</a> ' +
42
+ '<a href="#documentation">&uarr;</a></span>'
43
+
44
+ assert_equal "\n<h2 id=\"label-Hello\">Hello#{links}</h2>\n", @to.res.join
48
45
  end
49
46
 
50
47
  def accept_heading_3
51
- assert_equal "\n<h3 id=\"label-Hello\">Hello</h3>\n", @to.res.join
48
+ links = '<span><a href="#label-Hello">&para;</a> ' +
49
+ '<a href="#documentation">&uarr;</a></span>'
50
+
51
+ assert_equal "\n<h3 id=\"label-Hello\">Hello#{links}</h3>\n", @to.res.join
52
52
  end
53
53
 
54
54
  def accept_heading_4
55
- assert_equal "\n<h4 id=\"label-Hello\">Hello</h4>\n", @to.res.join
55
+ links = '<span><a href="#label-Hello">&para;</a> ' +
56
+ '<a href="#documentation">&uarr;</a></span>'
57
+
58
+ assert_equal "\n<h4 id=\"label-Hello\">Hello#{links}</h4>\n", @to.res.join
56
59
  end
57
60
 
58
61
  def accept_heading_b
59
- assert_equal "\n<h1 id=\"label-Hello\"><strong>Hello</strong></h1>\n",
62
+ links = '<span><a href="#label-Hello">&para;</a> ' +
63
+ '<a href="#documentation">&uarr;</a></span>'
64
+ inner = "<strong>Hello</strong>"
65
+
66
+ assert_equal "\n<h1 id=\"label-Hello\">#{inner}#{links}</h1>\n",
60
67
  @to.res.join
61
68
  end
62
69
 
63
70
  def accept_heading_suppressed_crossref
64
- assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
71
+ links = '<span><a href="#label-Hello">&para;</a> ' +
72
+ '<a href="#documentation">&uarr;</a></span>'
73
+
74
+ assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n", @to.res.join
65
75
  end
66
76
 
67
77
  def accept_list_end_bullet
@@ -337,7 +347,10 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
337
347
 
338
348
  @to.accept_heading @RM::Heading.new(7, 'Hello')
339
349
 
340
- assert_equal "\n<h6 id=\"label-Hello\">Hello</h6>\n", @to.res.join
350
+ links = '<span><a href="#label-Hello">&para;</a> ' +
351
+ '<a href="#documentation">&uarr;</a></span>'
352
+
353
+ assert_equal "\n<h6 id=\"label-Hello\">Hello#{links}</h6>\n", @to.res.join
341
354
  end
342
355
 
343
356
  def test_accept_heading_aref_class
@@ -346,7 +359,10 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
346
359
 
347
360
  @to.accept_heading @RM::Heading.new(1, 'Hello')
348
361
 
349
- assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n",
362
+ links = '<span><a href="#label-Hello">&para;</a> ' +
363
+ '<a href="#documentation">&uarr;</a></span>'
364
+
365
+ assert_equal "\n<h1 id=\"label-Hello\">Hello#{links}</h1>\n",
350
366
  @to.res.join
351
367
  end
352
368
 
@@ -356,10 +372,23 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
356
372
 
357
373
  @to.accept_heading @RM::Heading.new(1, 'Hello')
358
374
 
359
- assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello</h1>\n",
375
+ links = '<span><a href="#method-i-foo-label-Hello">&para;</a> ' +
376
+ '<a href="#documentation">&uarr;</a></span>'
377
+
378
+ assert_equal "\n<h1 id=\"method-i-foo-label-Hello\">Hello#{links}</h1>\n",
360
379
  @to.res.join
361
380
  end
362
381
 
382
+ def test_accept_heading_pipe
383
+ @options.pipe = true
384
+
385
+ @to.start_accepting
386
+
387
+ @to.accept_heading @RM::Heading.new(1, 'Hello')
388
+
389
+ assert_equal "\n<h1 id=\"label-Hello\">Hello</h1>\n", @to.res.join
390
+ end
391
+
363
392
  def test_accept_verbatim_parseable
364
393
  verb = @RM::Verbatim.new("class C\n", "end\n")
365
394
 
@@ -348,5 +348,36 @@ words words words words
348
348
  assert_equal expected, @to.end_accepting
349
349
  end
350
350
 
351
+ def test_convert_RDOCLINK
352
+ result = @to.convert 'rdoc-garbage:C'
353
+
354
+ assert_equal "C\n", result
355
+ end
356
+
357
+ def test_convert_TIDYLINK
358
+ result = @to.convert \
359
+ '{DSL}[http://en.wikipedia.org/wiki/Domain-specific_language]'
360
+
361
+ expected = "[DSL](http://en.wikipedia.org/wiki/Domain-specific_language)\n"
362
+
363
+ assert_equal expected, result
364
+ end
365
+
366
+ def test_handle_rdoc_link_label_footmark
367
+ assert_equal '[^1]:', @to.handle_rdoc_link('rdoc-label:footmark-1:x')
368
+ end
369
+
370
+ def test_handle_rdoc_link_label_foottext
371
+ assert_equal '[^1]', @to.handle_rdoc_link('rdoc-label:foottext-1:x')
372
+ end
373
+
374
+ def test_handle_rdoc_link_label_label
375
+ assert_equal '[x](#label-x)', @to.handle_rdoc_link('rdoc-label:label-x')
376
+ end
377
+
378
+ def test_handle_rdoc_link_ref
379
+ assert_equal 'x', @to.handle_rdoc_link('rdoc-ref:x')
380
+ end
381
+
351
382
  end
352
383