rdoc 4.0.1 → 4.1.0.preview.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 (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +1 -3
  5. data/{DEVELOPERS.rdoc → CONTRIBUTING.rdoc} +28 -3
  6. data/ExampleMarkdown.md +37 -0
  7. data/ExampleRDoc.rdoc +208 -0
  8. data/History.rdoc +81 -0
  9. data/Manifest.txt +11 -2
  10. data/README.rdoc +5 -5
  11. data/Rakefile +34 -4
  12. data/lib/rdoc.rb +4 -3
  13. data/lib/rdoc/any_method.rb +48 -4
  14. data/lib/rdoc/class_module.rb +16 -2
  15. data/lib/rdoc/code_object.rb +85 -24
  16. data/lib/rdoc/comment.rb +0 -3
  17. data/lib/rdoc/constant.rb +9 -1
  18. data/lib/rdoc/context.rb +20 -2
  19. data/lib/rdoc/cross_reference.rb +1 -1
  20. data/lib/rdoc/extend.rb +4 -112
  21. data/lib/rdoc/generator/darkfish.rb +46 -7
  22. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +4 -4
  23. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -8
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +4 -3
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +3 -3
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +3 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +4 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +3 -4
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +3 -3
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +4 -4
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +9 -5
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -3
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +12 -7
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +5 -4
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +6 -7
  37. data/lib/rdoc/generator/template/darkfish/class.rhtml +36 -41
  38. data/lib/rdoc/generator/template/darkfish/fonts.css +167 -0
  39. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  40. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  41. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  42. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  43. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  44. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  48. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  49. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -7
  50. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -15
  51. data/lib/rdoc/generator/template/darkfish/js/search.js +12 -4
  52. data/lib/rdoc/generator/template/darkfish/page.rhtml +9 -9
  53. data/lib/rdoc/generator/template/darkfish/rdoc.css +226 -241
  54. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +5 -5
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +13 -6
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +17 -14
  57. data/lib/rdoc/include.rb +4 -114
  58. data/lib/rdoc/known_classes.rb +1 -0
  59. data/lib/rdoc/markdown.kpeg +126 -117
  60. data/lib/rdoc/markdown.rb +404 -389
  61. data/lib/rdoc/markdown/literals_1_8.kpeg +1 -1
  62. data/lib/rdoc/markdown/literals_1_8.rb +15 -12
  63. data/lib/rdoc/markdown/literals_1_9.kpeg +1 -1
  64. data/lib/rdoc/markdown/literals_1_9.rb +15 -12
  65. data/lib/rdoc/markup.rb +10 -13
  66. data/lib/rdoc/markup/attribute_manager.rb +3 -2
  67. data/lib/rdoc/markup/formatter.rb +3 -3
  68. data/lib/rdoc/markup/heading.rb +13 -0
  69. data/lib/rdoc/markup/parser.rb +10 -3
  70. data/lib/rdoc/markup/pre_process.rb +1 -1
  71. data/lib/rdoc/markup/to_html.rb +46 -31
  72. data/lib/rdoc/markup/to_html_crossref.rb +3 -0
  73. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  74. data/lib/rdoc/markup/to_markdown.rb +7 -5
  75. data/lib/rdoc/markup/verbatim.rb +1 -1
  76. data/lib/rdoc/method_attr.rb +13 -1
  77. data/lib/rdoc/mixin.rb +120 -0
  78. data/lib/rdoc/normal_class.rb +4 -0
  79. data/lib/rdoc/normal_module.rb +4 -0
  80. data/lib/rdoc/options.rb +42 -8
  81. data/lib/rdoc/parser.rb +4 -2
  82. data/lib/rdoc/parser/c.rb +13 -7
  83. data/lib/rdoc/parser/ruby.rb +683 -480
  84. data/lib/rdoc/rdoc.rb +4 -3
  85. data/lib/rdoc/ri/driver.rb +174 -103
  86. data/lib/rdoc/ri/paths.rb +6 -6
  87. data/lib/rdoc/ruby_lex.rb +125 -102
  88. data/lib/rdoc/ruby_token.rb +41 -40
  89. data/lib/rdoc/servlet.rb +16 -6
  90. data/lib/rdoc/stats.rb +61 -48
  91. data/lib/rdoc/store.rb +5 -3
  92. data/lib/rdoc/test_case.rb +39 -0
  93. data/lib/rdoc/tom_doc.rb +28 -4
  94. data/lib/rdoc/top_level.rb +2 -2
  95. data/test/test_rdoc_any_method.rb +104 -1
  96. data/test/test_rdoc_class_module.rb +9 -15
  97. data/test/test_rdoc_code_object.rb +133 -8
  98. data/test/test_rdoc_context.rb +17 -0
  99. data/test/test_rdoc_context_section.rb +0 -7
  100. data/test/test_rdoc_cross_reference.rb +4 -3
  101. data/test/test_rdoc_generator_darkfish.rb +61 -19
  102. data/test/test_rdoc_generator_json_index.rb +0 -11
  103. data/test/test_rdoc_generator_ri.rb +0 -8
  104. data/test/test_rdoc_markdown.rb +15 -12
  105. data/test/test_rdoc_markdown_test.rb +0 -7
  106. data/test/test_rdoc_markup_attribute_manager.rb +121 -0
  107. data/test/test_rdoc_markup_document.rb +0 -7
  108. data/test/test_rdoc_markup_formatter.rb +29 -3
  109. data/test/test_rdoc_markup_heading.rb +9 -0
  110. data/test/test_rdoc_markup_parser.rb +0 -7
  111. data/test/test_rdoc_markup_pre_process.rb +15 -3
  112. data/test/test_rdoc_markup_raw.rb +0 -7
  113. data/test/test_rdoc_markup_to_html.rb +50 -8
  114. data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
  115. data/test/test_rdoc_markup_to_html_snippet.rb +4 -4
  116. data/test/test_rdoc_markup_to_markdown.rb +6 -0
  117. data/test/test_rdoc_method_attr.rb +8 -0
  118. data/test/test_rdoc_normal_class.rb +5 -0
  119. data/test/test_rdoc_normal_module.rb +5 -0
  120. data/test/test_rdoc_options.rb +61 -22
  121. data/test/test_rdoc_parser.rb +10 -0
  122. data/test/test_rdoc_parser_c.rb +17 -5
  123. data/test/test_rdoc_parser_changelog.rb +0 -7
  124. data/test/test_rdoc_parser_rd.rb +0 -7
  125. data/test/test_rdoc_parser_ruby.rb +305 -28
  126. data/test/test_rdoc_rd_block_parser.rb +0 -8
  127. data/test/test_rdoc_rd_inline_parser.rb +0 -1
  128. data/test/test_rdoc_rdoc.rb +27 -1
  129. data/test/test_rdoc_ri_driver.rb +19 -7
  130. data/test/test_rdoc_ruby_lex.rb +116 -9
  131. data/test/test_rdoc_rubygems_hook.rb +1 -1
  132. data/test/test_rdoc_servlet.rb +44 -6
  133. data/test/test_rdoc_stats.rb +161 -141
  134. data/test/test_rdoc_store.rb +11 -19
  135. data/test/test_rdoc_text.rb +0 -7
  136. data/test/test_rdoc_tom_doc.rb +44 -16
  137. data/test/xref_test_case.rb +2 -0
  138. metadata +28 -27
  139. metadata.gz.sig +0 -0
  140. data/test/test_attribute_manager.rb +0 -120
@@ -15,13 +15,6 @@ class TestRDocParserChangeLog < RDoc::TestCase
15
15
  @tempfile.close
16
16
  end
17
17
 
18
- def mu_pp obj
19
- s = ''
20
- s = PP.pp obj, s
21
- s = s.force_encoding Encoding.default_external if defined? Encoding
22
- s.chomp
23
- end
24
-
25
18
  def test_class_can_parse
26
19
  parser = RDoc::Parser::ChangeLog
27
20
 
@@ -22,13 +22,6 @@ class TestRDocParserRd < RDoc::TestCase
22
22
  @tempfile.close
23
23
  end
24
24
 
25
- def mu_pp obj
26
- s = ''
27
- s = PP.pp obj, s
28
- s = s.force_encoding Encoding.default_external if defined? Encoding
29
- s.chomp
30
- end
31
-
32
25
  def test_file
33
26
  assert_kind_of RDoc::Parser::Text, util_parser('')
34
27
  end
@@ -33,13 +33,6 @@ class TestRDocParserRuby < RDoc::TestCase
33
33
  @tempfile2.close
34
34
  end
35
35
 
36
- def mu_pp obj
37
- s = ''
38
- s = PP.pp obj, s
39
- s = s.force_encoding(Encoding.default_external) if defined? Encoding
40
- s.chomp
41
- end
42
-
43
36
  def test_collect_first_comment
44
37
  p = util_parser <<-CONTENT
45
38
  # first
@@ -163,6 +156,35 @@ class C; end
163
156
  assert_equal '/', @parser.get_symbol_or_name
164
157
  end
165
158
 
159
+ def test_suppress_parents
160
+ a = @top_level.add_class RDoc::NormalClass, 'A'
161
+ b = a.add_class RDoc::NormalClass, 'B'
162
+ c = b.add_class RDoc::NormalClass, 'C'
163
+
164
+ util_parser ''
165
+
166
+ @parser.suppress_parents c, a
167
+
168
+ assert c.suppressed?
169
+ assert b.suppressed?
170
+ refute a.suppressed?
171
+ end
172
+
173
+ def test_suppress_parents_documented
174
+ a = @top_level.add_class RDoc::NormalClass, 'A'
175
+ b = a.add_class RDoc::NormalClass, 'B'
176
+ b.add_comment RDoc::Comment.new("hello"), @top_level
177
+ c = b.add_class RDoc::NormalClass, 'C'
178
+
179
+ util_parser ''
180
+
181
+ @parser.suppress_parents c, a
182
+
183
+ assert c.suppressed?
184
+ refute b.suppressed?
185
+ refute a.suppressed?
186
+ end
187
+
166
188
  def test_look_for_directives_in_attr
167
189
  util_parser ""
168
190
 
@@ -392,6 +414,23 @@ class C; end
392
414
  assert_equal 0, klass.attributes.length
393
415
  end
394
416
 
417
+ def test_parse_attr_accessor_nodoc_track
418
+ klass = RDoc::NormalClass.new 'Foo'
419
+ klass.parent = @top_level
420
+
421
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
422
+
423
+ @options.visibility = :nodoc
424
+
425
+ util_parser "attr_accessor :foo, :bar # :nodoc:"
426
+
427
+ tk = @parser.get_tk
428
+
429
+ @parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
430
+
431
+ refute_empty klass.attributes
432
+ end
433
+
395
434
  def test_parse_attr_accessor_stopdoc
396
435
  klass = RDoc::NormalClass.new 'Foo'
397
436
  klass.parent = @top_level
@@ -568,6 +607,26 @@ class C; end
568
607
  assert_equal 1, foo.line
569
608
  end
570
609
 
610
+ def test_parse_class_singleton
611
+ comment = RDoc::Comment.new "##\n# my class\n", @top_level
612
+
613
+ util_parser <<-RUBY
614
+ class C
615
+ class << self
616
+ end
617
+ end
618
+ RUBY
619
+
620
+ tk = @parser.get_tk
621
+
622
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, comment
623
+
624
+ c = @top_level.classes.first
625
+ assert_equal 'C', c.full_name
626
+ assert_equal 0, c.offset
627
+ assert_equal 1, c.line
628
+ end
629
+
571
630
  def test_parse_class_ghost_method
572
631
  util_parser <<-CLASS
573
632
  class Foo
@@ -589,6 +648,29 @@ end
589
648
  assert_equal @top_level, blah.file
590
649
  end
591
650
 
651
+ def test_parse_class_ghost_method_yields
652
+ util_parser <<-CLASS
653
+ class Foo
654
+ ##
655
+ # :method:
656
+ # :call-seq:
657
+ # yields(name)
658
+ end
659
+ CLASS
660
+
661
+ tk = @parser.get_tk
662
+
663
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
664
+
665
+ foo = @top_level.classes.first
666
+ assert_equal 'Foo', foo.full_name
667
+
668
+ blah = foo.method_list.first
669
+ assert_equal 'Foo#yields', blah.full_name
670
+ assert_equal 'yields(name)', blah.call_seq
671
+ assert_equal @top_level, blah.file
672
+ end
673
+
592
674
  def test_parse_class_multi_ghost_methods
593
675
  util_parser <<-'CLASS'
594
676
  class Foo
@@ -691,7 +773,7 @@ end
691
773
  assert_equal 2, foo.method_list.length
692
774
  end
693
775
 
694
- def test_parse_const_fail_w_meta
776
+ def test_parse_const_fail_w_meta_method
695
777
  util_parser <<-CLASS
696
778
  class ConstFailMeta
697
779
  ##
@@ -713,6 +795,27 @@ end
713
795
  assert_equal 1, const_fail_meta.attributes.length
714
796
  end
715
797
 
798
+ def test_parse_const_third_party
799
+ util_parser <<-CLASS
800
+ class A
801
+ true if B::C
802
+ true if D::E::F
803
+ end
804
+ CLASS
805
+
806
+ tk = @parser.get_tk
807
+
808
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
809
+
810
+ a = @top_level.classes.first
811
+ assert_equal 'A', a.full_name
812
+
813
+ visible = @store.all_modules.reject { |mod| mod.suppressed? }
814
+ visible = visible.map { |mod| mod.full_name }
815
+
816
+ assert_empty visible
817
+ end
818
+
716
819
  def test_parse_class_nested_superclass
717
820
  foo = @top_level.add_module RDoc::NormalModule, 'Foo'
718
821
 
@@ -1002,6 +1105,23 @@ EOF
1002
1105
  assert_equal klass.current_section, foo.section
1003
1106
  end
1004
1107
 
1108
+ def test_parse_comment_attr_attr_reader
1109
+ klass = RDoc::NormalClass.new 'Foo'
1110
+ klass.parent = @top_level
1111
+
1112
+ comment = RDoc::Comment.new "##\n# :attr_reader: foo\n", @top_level
1113
+
1114
+ util_parser "\n"
1115
+
1116
+ tk = @parser.get_tk
1117
+
1118
+ @parser.parse_comment klass, tk, comment
1119
+
1120
+ foo = klass.attributes.first
1121
+ assert_equal 'foo', foo.name
1122
+ assert_equal 'R', foo.rw
1123
+ end
1124
+
1005
1125
  def test_parse_comment_attr_stopdoc
1006
1126
  klass = RDoc::NormalClass.new 'Foo'
1007
1127
  klass.parent = @top_level
@@ -1064,6 +1184,23 @@ EOF
1064
1184
  assert_equal stream, foo.token_stream
1065
1185
  end
1066
1186
 
1187
+ def test_parse_comment_method_args
1188
+ klass = RDoc::NormalClass.new 'Foo'
1189
+ klass.parent = @top_level
1190
+
1191
+
1192
+ util_parser "\n"
1193
+
1194
+ tk = @parser.get_tk
1195
+
1196
+ @parser.parse_comment klass, tk,
1197
+ comment("##\n# :method: foo\n# :args: a, b\n")
1198
+
1199
+ foo = klass.method_list.first
1200
+ assert_equal 'foo', foo.name
1201
+ assert_equal 'a, b', foo.params
1202
+ end
1203
+
1067
1204
  def test_parse_comment_method_stopdoc
1068
1205
  klass = RDoc::NormalClass.new 'Foo'
1069
1206
  klass.parent = @top_level
@@ -1203,44 +1340,44 @@ A::B::C = 1
1203
1340
  assert_equal 'comment', c.comment
1204
1341
  end
1205
1342
 
1206
- def test_parse_include
1343
+ def test_parse_extend_or_include_extend
1207
1344
  klass = RDoc::NormalClass.new 'C'
1208
1345
  klass.parent = @top_level
1209
1346
 
1210
- comment = RDoc::Comment.new "# my include\n", @top_level
1347
+ comment = RDoc::Comment.new "# my extend\n", @top_level
1211
1348
 
1212
- util_parser "include I"
1349
+ util_parser "extend I"
1213
1350
 
1214
- @parser.get_tk # include
1351
+ @parser.get_tk # extend
1215
1352
 
1216
- @parser.parse_include klass, comment
1353
+ @parser.parse_extend_or_include RDoc::Extend, klass, comment
1217
1354
 
1218
- assert_equal 1, klass.includes.length
1355
+ assert_equal 1, klass.extends.length
1219
1356
 
1220
- incl = klass.includes.first
1221
- assert_equal 'I', incl.name
1222
- assert_equal 'my include', incl.comment.text
1223
- assert_equal @top_level, incl.file
1357
+ ext = klass.extends.first
1358
+ assert_equal 'I', ext.name
1359
+ assert_equal 'my extend', ext.comment.text
1360
+ assert_equal @top_level, ext.file
1224
1361
  end
1225
1362
 
1226
- def test_parse_extend
1363
+ def test_parse_extend_or_include_include
1227
1364
  klass = RDoc::NormalClass.new 'C'
1228
1365
  klass.parent = @top_level
1229
1366
 
1230
- comment = RDoc::Comment.new "# my extend\n", @top_level
1367
+ comment = RDoc::Comment.new "# my include\n", @top_level
1231
1368
 
1232
- util_parser "extend I"
1369
+ util_parser "include I"
1233
1370
 
1234
- @parser.get_tk # extend
1371
+ @parser.get_tk # include
1235
1372
 
1236
- @parser.parse_extend klass, comment
1373
+ @parser.parse_extend_or_include RDoc::Include, klass, comment
1237
1374
 
1238
- assert_equal 1, klass.extends.length
1375
+ assert_equal 1, klass.includes.length
1239
1376
 
1240
- ext = klass.extends.first
1241
- assert_equal 'I', ext.name
1242
- assert_equal 'my extend', ext.comment.text
1243
- assert_equal @top_level, ext.file
1377
+ incl = klass.includes.first
1378
+ assert_equal 'I', incl.name
1379
+ assert_equal 'my include', incl.comment.text
1380
+ assert_equal @top_level, incl.file
1244
1381
  end
1245
1382
 
1246
1383
  def test_parse_meta_method
@@ -1644,6 +1781,34 @@ end
1644
1781
  assert_equal 'foo', foo.name
1645
1782
  end
1646
1783
 
1784
+ def test_parse_method_nodoc
1785
+ klass = RDoc::NormalClass.new 'Foo'
1786
+ klass.parent = @top_level
1787
+
1788
+ util_parser "def foo # :nodoc:\nend"
1789
+
1790
+ tk = @parser.get_tk
1791
+
1792
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment('')
1793
+
1794
+ assert_empty klass.method_list
1795
+ end
1796
+
1797
+ def test_parse_method_nodoc_track
1798
+ klass = RDoc::NormalClass.new 'Foo'
1799
+ klass.parent = @top_level
1800
+
1801
+ @options.visibility = :nodoc
1802
+
1803
+ util_parser "def foo # :nodoc:\nend"
1804
+
1805
+ tk = @parser.get_tk
1806
+
1807
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, comment('')
1808
+
1809
+ refute_empty klass.method_list
1810
+ end
1811
+
1647
1812
  def test_parse_method_no_parens
1648
1813
  klass = RDoc::NormalClass.new 'Foo'
1649
1814
  klass.parent = @top_level
@@ -1884,6 +2049,24 @@ end
1884
2049
  assert_equal Encoding::CP852, foo.comment.text.encoding
1885
2050
  end
1886
2051
 
2052
+ def test_parse_statements_enddoc
2053
+ klass = @top_level.add_class RDoc::NormalClass, 'Foo'
2054
+
2055
+ util_parser "\n# :enddoc:"
2056
+
2057
+ @parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
2058
+
2059
+ assert klass.done_documenting
2060
+ end
2061
+
2062
+ def test_parse_statements_enddoc_top_level
2063
+ util_parser "\n# :enddoc:"
2064
+
2065
+ assert_throws :eof do
2066
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
2067
+ end
2068
+ end
2069
+
1887
2070
  def test_parse_statements_identifier_meta_method
1888
2071
  content = <<-EOF
1889
2072
  class Foo
@@ -2367,6 +2550,16 @@ end
2367
2550
  # HACK where are the assertions?
2368
2551
  end
2369
2552
 
2553
+ def test_parse_top_level_statements_enddoc
2554
+ util_parser <<-CONTENT
2555
+ # :enddoc:
2556
+ CONTENT
2557
+
2558
+ assert_throws :eof do
2559
+ @parser.parse_top_level_statements @top_level
2560
+ end
2561
+ end
2562
+
2370
2563
  def test_parse_top_level_statements_stopdoc
2371
2564
  @top_level.stop_doc
2372
2565
  content = "# this is the top-level comment"
@@ -2690,6 +2883,21 @@ end
2690
2883
  assert_equal 'A nice girl', m.comment.text
2691
2884
  end
2692
2885
 
2886
+ def test_scan_class_nested_nodoc
2887
+ content = <<-CONTENT
2888
+ class A::B # :nodoc:
2889
+ end
2890
+ CONTENT
2891
+
2892
+ util_parser content
2893
+
2894
+ @parser.scan
2895
+
2896
+ visible = @store.all_classes_and_modules.select { |mod| mod.display? }
2897
+
2898
+ assert_empty visible.map { |mod| mod.full_name }
2899
+ end
2900
+
2693
2901
  def test_scan_constant_in_method
2694
2902
  content = <<-CONTENT # newline is after M is important
2695
2903
  module M
@@ -2826,6 +3034,32 @@ class C
2826
3034
  assert_equal 2, @top_level.classes.first.method_list.length
2827
3035
  end
2828
3036
 
3037
+ def test_scan_method_semi_method
3038
+ content = <<-CONTENT
3039
+ class A
3040
+ def self.m() end; def self.m=() end
3041
+ end
3042
+
3043
+ class B
3044
+ def self.m() end
3045
+ end
3046
+ CONTENT
3047
+
3048
+ util_parser content
3049
+
3050
+ @parser.scan
3051
+
3052
+ a = @store.find_class_named 'A'
3053
+ assert a, 'missing A'
3054
+
3055
+ assert_equal 2, a.method_list.length
3056
+
3057
+ b = @store.find_class_named 'B'
3058
+ assert b, 'missing B'
3059
+
3060
+ assert_equal 1, b.method_list.length
3061
+ end
3062
+
2829
3063
  def test_scan_markup_override
2830
3064
  content = <<-CONTENT
2831
3065
  # *awesome*
@@ -2871,6 +3105,20 @@ end
2871
3105
  assert_equal 'rd', c.method_list.first.comment.format
2872
3106
  end
2873
3107
 
3108
+ def test_scan_rails_routes
3109
+ util_parser <<-ROUTES_RB
3110
+ namespace :api do
3111
+ scope module: :v1 do
3112
+ end
3113
+ end
3114
+ ROUTES_RB
3115
+
3116
+ @parser.scan
3117
+
3118
+ assert_empty @top_level.classes
3119
+ assert_empty @top_level.modules
3120
+ end
3121
+
2874
3122
  def test_scan_tomdoc_meta
2875
3123
  util_parser <<-RUBY
2876
3124
  # :markup: tomdoc
@@ -2977,6 +3225,35 @@ end
2977
3225
  assert_equal %w[C::[]], c.method_list.map { |m| m.full_name }
2978
3226
  end
2979
3227
 
3228
+ def test_scan_visibility
3229
+ util_parser <<-RUBY
3230
+ class C
3231
+ def a() end
3232
+
3233
+ private :a
3234
+
3235
+ class << self
3236
+ def b() end
3237
+ private :b
3238
+ end
3239
+ end
3240
+ RUBY
3241
+
3242
+ @parser.scan
3243
+
3244
+ c = @store.find_class_named 'C'
3245
+
3246
+ c_a = c.find_method_named 'a'
3247
+
3248
+ assert_equal :private, c_a.visibility
3249
+ refute c_a.singleton
3250
+
3251
+ c_b = c.find_method_named 'b'
3252
+
3253
+ assert_equal :private, c_b.visibility
3254
+ refute c_b.singleton
3255
+ end
3256
+
2980
3257
  def test_stopdoc_after_comment
2981
3258
  util_parser <<-EOS
2982
3259
  module Bar