rdoc 3.12.2 → 4.0.0.preview2

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 (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -0,0 +1,23 @@
1
+ ##
2
+ # Parse a Markdown format file. The parsed RDoc::Markup::Document is attached
3
+ # as a file comment.
4
+
5
+ class RDoc::Parser::Markdown < RDoc::Parser
6
+
7
+ include RDoc::Parser::Text
8
+
9
+ parse_files_matching(/\.(md|markdown)(?:\.[^.]+)?$/)
10
+
11
+ ##
12
+ # Creates an Markdown-format TopLevel for the given file.
13
+
14
+ def scan
15
+ comment = RDoc::Comment.new @content, @top_level
16
+ comment.format = 'markdown'
17
+
18
+ @top_level.comment = comment
19
+ end
20
+
21
+ end
22
+
23
+
@@ -94,7 +94,7 @@ $TOKEN_DEBUG ||= nil
94
94
  # You can force the name of a method using the :method: directive:
95
95
  #
96
96
  # ##
97
- # # :method: woo_hoo!
97
+ # # :method: some_method!
98
98
  #
99
99
  # By default, meta-methods are instance methods. To indicate that a method is
100
100
  # a singleton method instead use the :singleton-method: directive:
@@ -105,7 +105,7 @@ $TOKEN_DEBUG ||= nil
105
105
  # You can also use the :singleton-method: directive with a name:
106
106
  #
107
107
  # ##
108
- # # :singleton-method: woo_hoo!
108
+ # # :singleton-method: some_method!
109
109
  #
110
110
  # Additionally you can mark a method as an attribute by
111
111
  # using :attr:, :attr_reader:, :attr_writer: or :attr_accessor:. Just like
@@ -240,7 +240,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
240
240
  # with :: separated named) and return the ultimate name, the associated
241
241
  # container, and the given name (with the ::).
242
242
 
243
- def get_class_or_module(container)
243
+ def get_class_or_module container
244
244
  skip_tkspace
245
245
  name_t = get_tk
246
246
  given_name = ''
@@ -259,14 +259,18 @@ class RDoc::Parser::Ruby < RDoc::Parser
259
259
  while TkCOLON2 === peek_tk do
260
260
  prev_container = container
261
261
  container = container.find_module_named name_t.name
262
- unless container then
263
- container = prev_container.add_module RDoc::NormalModule, name_t.name
264
- end
262
+ container ||= prev_container.add_module RDoc::NormalModule, name_t.name
263
+
264
+ container.ignore unless prev_container.document_children
265
+
265
266
  get_tk
267
+ skip_tkspace false
266
268
  name_t = get_tk
267
269
  given_name << '::' << name_t.name
268
270
  end
271
+
269
272
  skip_tkspace false
273
+
270
274
  return [container, name_t, given_name]
271
275
  end
272
276
 
@@ -275,9 +279,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
275
279
 
276
280
  def get_class_specification
277
281
  tk = get_tk
278
- return "self" if TkSELF === tk
282
+ return 'self' if TkSELF === tk
283
+ return '' if TkGVAR === tk
279
284
 
280
- res = ""
285
+ res = ''
281
286
  while TkCOLON2 === tk or TkCOLON3 === tk or TkCONSTANT === tk do
282
287
  res += tk.name
283
288
  tk = get_tk
@@ -587,6 +592,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
587
592
  name = name_t.name
588
593
  superclass = '::Object'
589
594
 
595
+ if given_name =~ /^::/ then
596
+ declaration_context = @top_level
597
+ given_name = $'
598
+ end
599
+
590
600
  if TkLT === peek_tk then
591
601
  get_tk
592
602
  skip_tkspace
@@ -611,17 +621,25 @@ class RDoc::Parser::Ruby < RDoc::Parser
611
621
  parse_statements cls
612
622
  when TkLSHFT
613
623
  case name = get_class_specification
614
- when "self", container.name
624
+ when 'self', container.name
615
625
  parse_statements container, SINGLE
616
626
  else
617
- other = RDoc::TopLevel.find_class_named name
627
+ other = @store.find_class_named name
618
628
 
619
629
  unless other then
630
+ if name =~ /^::/ then
631
+ name = $'
632
+ container = @top_level
633
+ end
634
+
620
635
  other = container.add_module RDoc::NormalModule, name
621
636
  other.record_location @top_level
622
637
  other.offset = offset
623
638
  other.line = line_no
624
639
 
640
+ # class << $gvar
641
+ other.ignore if name.empty?
642
+
625
643
  other.add_comment comment, @top_level
626
644
  end
627
645
 
@@ -701,7 +719,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
701
719
 
702
720
  if nest <= 0 and TkNL === peek_tk then
703
721
  mod = if rhs_name =~ /^::/ then
704
- RDoc::TopLevel.find_class_or_module rhs_name
722
+ @store.find_class_or_module rhs_name
705
723
  else
706
724
  container.find_module_named rhs_name
707
725
  end
@@ -767,7 +785,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
767
785
  indent.set_text " " * column
768
786
 
769
787
  position_comment = TkCOMMENT.new 0, line_no, 1
770
- position_comment.set_text "# File #{@top_level.absolute_name}, line #{line_no}"
788
+ position_comment.set_text "# File #{@top_level.relative_name}, line #{line_no}"
771
789
  meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
772
790
 
773
791
  meth.params = ''
@@ -825,7 +843,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
825
843
  indent.set_text " " * offset
826
844
 
827
845
  position_comment = TkCOMMENT.new 0, line_no, 1
828
- position_comment.set_text "# File #{@top_level.absolute_name}, line #{line_no}"
846
+ position_comment.set_text "# File #{@top_level.relative_name}, line #{line_no}"
829
847
  meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
830
848
 
831
849
  meth.call_seq = signature
@@ -861,6 +879,26 @@ class RDoc::Parser::Ruby < RDoc::Parser
861
879
  end
862
880
  end
863
881
 
882
+ ##
883
+ # Parses an +extend+ in +context+ with +comment+
884
+
885
+ def parse_extend context, comment
886
+ loop do
887
+ skip_tkspace_comment
888
+
889
+ name = get_constant_with_optional_parens
890
+
891
+ unless name.empty? then
892
+ incl = context.add_extend RDoc::Extend.new(name, comment)
893
+ incl.record_location @top_level
894
+ end
895
+
896
+ return unless TkCOMMA === peek_tk
897
+
898
+ get_tk
899
+ end
900
+ end
901
+
864
902
  ##
865
903
  # Parses a meta-programmed attribute and creates an RDoc::Attr.
866
904
  #
@@ -924,6 +962,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
924
962
  @stats.add_attribute att
925
963
  end
926
964
  end
965
+
966
+ att
927
967
  end
928
968
 
929
969
  ##
@@ -975,7 +1015,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
975
1015
  indent.set_text " " * column
976
1016
 
977
1017
  position_comment = TkCOMMENT.new 0, line_no, 1
978
- position_comment.value = "# File #{@top_level.absolute_name}, line #{line_no}"
1018
+ position_comment.value = "# File #{@top_level.relative_name}, line #{line_no}"
979
1019
  meth.add_tokens [position_comment, NEWLINE_TOKEN, indent]
980
1020
  meth.add_tokens @token_stream
981
1021
 
@@ -998,7 +1038,6 @@ class RDoc::Parser::Ruby < RDoc::Parser
998
1038
  when TkSPACE then
999
1039
  # expression continues
1000
1040
  when TkDO then
1001
- unget_tk tk
1002
1041
  parse_statements container, single, meth
1003
1042
  break
1004
1043
  else
@@ -1010,6 +1049,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1010
1049
  meth.comment = comment
1011
1050
 
1012
1051
  @stats.add_method meth
1052
+
1053
+ meth
1013
1054
  end
1014
1055
 
1015
1056
  ##
@@ -1035,15 +1076,23 @@ class RDoc::Parser::Ruby < RDoc::Parser
1035
1076
  meth = nil
1036
1077
  added_container = false
1037
1078
 
1038
- dot = get_tk
1039
- if TkDOT === dot or TkCOLON2 === dot then
1079
+ case dot = get_tk
1080
+ when TkDOT, TkCOLON2 then
1040
1081
  @scanner.instance_eval do @lex_state = EXPR_FNAME end
1041
1082
  skip_tkspace
1042
1083
  name_t2 = get_tk
1043
1084
 
1044
1085
  case name_t
1045
1086
  when TkSELF, TkMOD then
1046
- name = name_t2.name
1087
+ name = case name_t2
1088
+ # NOTE: work around '[' being consumed early and not being
1089
+ # re-tokenized as a TkAREF
1090
+ when TkfLBRACK then
1091
+ get_tk
1092
+ '[]'
1093
+ else
1094
+ name_t2.name
1095
+ end
1047
1096
  when TkCONSTANT then
1048
1097
  name = name_t2.name
1049
1098
  prev_container = container
@@ -1072,11 +1121,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
1072
1121
  when TkIDENTIFIER, TkIVAR, TkGVAR then
1073
1122
  dummy = RDoc::Context.new
1074
1123
  dummy.parent = container
1124
+ dummy.store = container.store
1075
1125
  skip_method dummy
1076
1126
  return
1077
1127
  when TkTRUE, TkFALSE, TkNIL then
1078
1128
  klass_name = "#{name_t.name.capitalize}Class"
1079
- container = RDoc::TopLevel.find_class_named klass_name
1129
+ container = @store.find_class_named klass_name
1080
1130
  container ||= @top_level.add_class RDoc::NormalClass, klass_name
1081
1131
 
1082
1132
  name = name_t2.name
@@ -1121,7 +1171,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1121
1171
  indent.set_text " " * column
1122
1172
 
1123
1173
  token = TkCOMMENT.new 0, line_no, 1
1124
- token.set_text "# File #{@top_level.absolute_name}, line #{line_no}"
1174
+ token.set_text "# File #{@top_level.relative_name}, line #{line_no}"
1125
1175
  meth.add_tokens [token, NEWLINE_TOKEN, indent]
1126
1176
  meth.add_tokens @token_stream
1127
1177
 
@@ -1200,7 +1250,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1200
1250
  when end_token then
1201
1251
  if end_token == TkRPAREN
1202
1252
  nest -= 1
1203
- break if @scanner.lex_state == EXPR_END and nest <= 0
1253
+ break if nest <= 0
1204
1254
  else
1205
1255
  break unless @scanner.continue
1206
1256
  end
@@ -1344,7 +1394,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1344
1394
  non_comment_seen = true
1345
1395
  end
1346
1396
 
1347
- unget_tk tk # TODO peek instead of get then unget
1397
+ unget_tk tk
1348
1398
  keep_comment = true
1349
1399
 
1350
1400
  when TkCLASS then
@@ -1388,6 +1438,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
1388
1438
  when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN then
1389
1439
  nest += 1
1390
1440
 
1441
+ when TkSUPER then
1442
+ current_method.calls_super = true if current_method
1443
+
1391
1444
  when TkIDENTIFIER then
1392
1445
  if nest == 1 and current_method.nil? then
1393
1446
  case tk.name
@@ -1409,7 +1462,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
1409
1462
  when /^# +:?attr(_reader|_writer|_accessor)?:/ then
1410
1463
  parse_meta_attr container, single, tk, comment
1411
1464
  else
1412
- parse_meta_method container, single, tk, comment
1465
+ method = parse_meta_method container, single, tk, comment
1466
+ method.params = container.params if
1467
+ container.params
1468
+ method.block_params = container.block_params if
1469
+ container.block_params
1413
1470
  end
1414
1471
  end
1415
1472
  end
@@ -1420,6 +1477,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1420
1477
  parse_require container, comment
1421
1478
  when "include" then
1422
1479
  parse_include container, comment
1480
+ when "extend" then
1481
+ parse_extend container, comment
1423
1482
  end
1424
1483
 
1425
1484
  when TkEND then
@@ -1446,6 +1505,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1446
1505
  unless keep_comment then
1447
1506
  comment = new_comment ''
1448
1507
  comment.force_encoding @encoding if @encoding
1508
+ container.params = nil
1509
+ container.block_params = nil
1449
1510
  end
1450
1511
 
1451
1512
  begin
@@ -1453,6 +1514,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
1453
1514
  skip_tkspace false
1454
1515
  end while peek_tk == TkNL
1455
1516
  end
1517
+
1518
+ container.params = nil
1519
+ container.block_params = nil
1456
1520
  end
1457
1521
 
1458
1522
  ##
@@ -1641,28 +1705,44 @@ class RDoc::Parser::Ruby < RDoc::Parser
1641
1705
  #
1642
1706
  # class MyClass # :nodoc:
1643
1707
  #
1644
- # We return the directive name and any parameters as a two element array
1708
+ # We return the directive name and any parameters as a two element array if
1709
+ # the name is in +allowed+. A directive can be found anywhere up to the end
1710
+ # of the current line.
1645
1711
 
1646
1712
  def read_directive allowed
1647
- tk = get_tk
1713
+ tokens = []
1648
1714
 
1649
- if TkCOMMENT === tk then
1650
- return unless tk.text =~ /\s*:?(\w+):\s*(.*)/
1715
+ while tk = get_tk do
1716
+ tokens << tk
1717
+
1718
+ case tk
1719
+ when TkNL then return
1720
+ when TkCOMMENT then
1721
+ return unless tk.text =~ /\s*:?([\w-]+):\s*(.*)/
1651
1722
 
1652
- directive = $1.downcase
1723
+ directive = $1.downcase
1653
1724
 
1654
- return [directive, $2] if allowed.include? directive
1655
- else
1656
- unget_tk tk
1725
+ return [directive, $2] if allowed.include? directive
1726
+
1727
+ return
1728
+ end
1729
+ end
1730
+ ensure
1731
+ unless tokens.length == 1 and TkCOMMENT === tokens.first then
1732
+ tokens.reverse_each do |token|
1733
+ unget_tk token
1734
+ end
1657
1735
  end
1658
1736
  end
1659
1737
 
1660
1738
  ##
1661
- # Handles the directive for +context+ if the directive is listed in +allow+.
1662
- # This method is called for directives following a definition.
1739
+ # Handles directives following the definition for +context+ (any
1740
+ # RDoc::CodeObject) if the directives are +allowed+ at this point.
1741
+ #
1742
+ # See also RDoc::Markup::PreProcess#handle_directive
1663
1743
 
1664
- def read_documentation_modifiers context, allow
1665
- directive, value = read_directive allow
1744
+ def read_documentation_modifiers context, allowed
1745
+ directive, value = read_directive allowed
1666
1746
 
1667
1747
  return unless directive
1668
1748
 
@@ -43,8 +43,7 @@ module RDoc::Parser::RubyTools
43
43
  tk = Token(TkSYMBOL).set_text(":" + tk1.text)
44
44
  end
45
45
 
46
- # remove the identifier we just read (we're about to replace it with a
47
- # symbol)
46
+ # remove the identifier we just read to replace it with a symbol
48
47
  @token_listeners.each do |obj|
49
48
  obj.pop_token
50
49
  end if @token_listeners
@@ -70,7 +69,13 @@ module RDoc::Parser::RubyTools
70
69
 
71
70
  loop do
72
71
  tk = get_tk
73
- case tk when *tokens then unget_tk tk; break end
72
+
73
+ case tk
74
+ when *tokens then
75
+ unget_tk tk
76
+ break
77
+ end
78
+
74
79
  read << tk
75
80
  end
76
81
 
@@ -1,7 +1,11 @@
1
1
  ##
2
2
  # RDoc::RD implements the RD format from the rdtool gem.
3
3
  #
4
- # = LICENSE
4
+ # To choose RD as your only default format see
5
+ # RDoc::Options@Saved+Options for instructions on setting up a
6
+ # <code>.doc_options</code> file to store your project default.
7
+ #
8
+ # == LICENSE
5
9
  #
6
10
  # The grammar that produces RDoc::RD::BlockParser and RDoc::RD::InlineParser
7
11
  # is included in RDoc under the Ruby License.
@@ -10,7 +14,7 @@
10
14
  # https://github.com/uwabami/rdtool/
11
15
  #
12
16
  # You can use, re-distribute or change these files under Ruby's License or GPL.
13
- #
17
+ #
14
18
  # 1. You may make and give away verbatim copies of the source form of the
15
19
  # software without restriction, provided that you duplicate all of the
16
20
  # original copyright notices and associated disclaimers.
@@ -53,9 +57,9 @@
53
57
  # For the list of those files and their copying conditions, see the
54
58
  # file LEGAL.
55
59
  #
56
- # 5. The scripts and library files supplied as input to or produced as
60
+ # 5. The scripts and library files supplied as input to or produced as
57
61
  # output from the software do not automatically fall under the
58
- # copyright of the software, but belong to whomever generated them,
62
+ # copyright of the software, but belong to whomever generated them,
59
63
  # and may be sold commercially, and may be aggregated with this
60
64
  # software.
61
65
  #
@@ -10,7 +10,7 @@ class RDoc::RD
10
10
 
11
11
  ##
12
12
  # RD format parser for headings, paragraphs, lists, verbatim sections that
13
- # exist as blocks.
13
+ # exist as blocks.
14
14
 
15
15
  class BlockParser < Racc::Parser
16
16
 
@@ -632,7 +632,7 @@ class RDoc::RD
632
632
 
633
633
  ##
634
634
  # RD format parser for headings, paragraphs, lists, verbatim sections that
635
- # exist as blocks.
635
+ # exist as blocks.
636
636
 
637
637
  ---- footer
638
638
  end