rdoc 4.2.1 → 6.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.

Files changed (277) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +8 -7
  3. data/Gemfile +12 -0
  4. data/History.rdoc +48 -4
  5. data/LEGAL.rdoc +2 -2
  6. data/README.rdoc +5 -5
  7. data/Rakefile +73 -155
  8. data/bin/console +7 -0
  9. data/bin/setup +6 -0
  10. data/{bin → exe}/rdoc +0 -0
  11. data/{bin → exe}/ri +0 -0
  12. data/lib/rdoc/alias.rb +1 -0
  13. data/lib/rdoc/anon_class.rb +1 -0
  14. data/lib/rdoc/any_method.rb +59 -14
  15. data/lib/rdoc/attr.rb +1 -0
  16. data/lib/rdoc/class_module.rb +5 -2
  17. data/lib/rdoc/code_object.rb +3 -11
  18. data/lib/rdoc/code_objects.rb +1 -0
  19. data/lib/rdoc/comment.rb +32 -11
  20. data/lib/rdoc/constant.rb +3 -2
  21. data/lib/rdoc/context/section.rb +7 -13
  22. data/lib/rdoc/context.rb +78 -23
  23. data/lib/rdoc/cross_reference.rb +33 -14
  24. data/lib/rdoc/encoding.rb +92 -55
  25. data/lib/rdoc/erb_partial.rb +2 -1
  26. data/lib/rdoc/erbio.rb +8 -3
  27. data/lib/rdoc/extend.rb +1 -0
  28. data/lib/rdoc/generator/darkfish.rb +62 -32
  29. data/lib/rdoc/generator/json_index.rb +8 -5
  30. data/lib/rdoc/generator/markup.rb +3 -12
  31. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  32. data/lib/rdoc/generator/pot/po.rb +84 -0
  33. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  34. data/lib/rdoc/generator/pot.rb +4 -3
  35. data/lib/rdoc/generator/ri.rb +1 -0
  36. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -8
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  49. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  50. data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
  51. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  52. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  53. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +23 -100
  54. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  57. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +7 -6
  59. data/lib/rdoc/generator.rb +1 -1
  60. data/lib/rdoc/ghost_method.rb +1 -0
  61. data/lib/rdoc/i18n/locale.rb +2 -1
  62. data/lib/rdoc/i18n/text.rb +5 -4
  63. data/lib/rdoc/i18n.rb +3 -2
  64. data/lib/rdoc/include.rb +1 -0
  65. data/lib/rdoc/known_classes.rb +1 -0
  66. data/lib/rdoc/markdown/entities.rb +1 -0
  67. data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +1 -0
  68. data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
  69. data/lib/rdoc/markdown.kpeg +94 -51
  70. data/lib/rdoc/markdown.rb +1171 -619
  71. data/lib/rdoc/markup/attr_changer.rb +1 -0
  72. data/lib/rdoc/markup/attr_span.rb +9 -2
  73. data/lib/rdoc/markup/attribute_manager.rb +115 -49
  74. data/lib/rdoc/markup/attributes.rb +7 -6
  75. data/lib/rdoc/markup/blank_line.rb +1 -0
  76. data/lib/rdoc/markup/block_quote.rb +1 -0
  77. data/lib/rdoc/markup/document.rb +1 -0
  78. data/lib/rdoc/markup/formatter.rb +25 -23
  79. data/lib/rdoc/markup/hard_break.rb +1 -0
  80. data/lib/rdoc/markup/heading.rb +4 -3
  81. data/lib/rdoc/markup/include.rb +1 -0
  82. data/lib/rdoc/markup/indented_paragraph.rb +1 -0
  83. data/lib/rdoc/markup/list.rb +1 -0
  84. data/lib/rdoc/markup/list_item.rb +1 -0
  85. data/lib/rdoc/markup/paragraph.rb +1 -0
  86. data/lib/rdoc/markup/parser.rb +78 -61
  87. data/lib/rdoc/markup/pre_process.rb +12 -9
  88. data/lib/rdoc/markup/raw.rb +1 -0
  89. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  90. data/lib/rdoc/markup/rule.rb +1 -0
  91. data/lib/rdoc/markup/to_ansi.rb +1 -0
  92. data/lib/rdoc/markup/to_bs.rb +4 -5
  93. data/lib/rdoc/markup/to_html.rb +71 -25
  94. data/lib/rdoc/markup/to_html_crossref.rb +41 -25
  95. data/lib/rdoc/markup/to_html_snippet.rb +10 -9
  96. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -31
  97. data/lib/rdoc/markup/to_label.rb +10 -9
  98. data/lib/rdoc/markup/to_markdown.rb +9 -8
  99. data/lib/rdoc/markup/to_rdoc.rb +35 -6
  100. data/lib/rdoc/markup/to_table_of_contents.rb +2 -0
  101. data/lib/rdoc/markup/to_test.rb +1 -0
  102. data/lib/rdoc/markup/to_tt_only.rb +3 -2
  103. data/lib/rdoc/markup/verbatim.rb +1 -0
  104. data/lib/rdoc/markup.rb +14 -16
  105. data/lib/rdoc/meta_method.rb +1 -0
  106. data/lib/rdoc/method_attr.rb +2 -1
  107. data/lib/rdoc/mixin.rb +1 -0
  108. data/lib/rdoc/normal_class.rb +3 -2
  109. data/lib/rdoc/normal_module.rb +1 -0
  110. data/lib/rdoc/options.rb +92 -58
  111. data/lib/rdoc/parser/c.rb +219 -223
  112. data/lib/rdoc/parser/changelog.rb +155 -18
  113. data/lib/rdoc/parser/markdown.rb +1 -0
  114. data/lib/rdoc/parser/rd.rb +1 -0
  115. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  116. data/lib/rdoc/parser/ruby.rb +635 -468
  117. data/lib/rdoc/parser/ruby_tools.rb +33 -33
  118. data/lib/rdoc/parser/simple.rb +3 -3
  119. data/lib/rdoc/parser/text.rb +1 -0
  120. data/lib/rdoc/parser.rb +17 -50
  121. data/lib/rdoc/rd/block_parser.rb +66 -65
  122. data/lib/rdoc/rd/block_parser.ry +3 -3
  123. data/lib/rdoc/rd/inline.rb +5 -4
  124. data/lib/rdoc/rd/inline_parser.rb +52 -51
  125. data/lib/rdoc/rd/inline_parser.ry +1 -1
  126. data/lib/rdoc/rd.rb +1 -0
  127. data/lib/rdoc/rdoc.rb +68 -63
  128. data/lib/rdoc/require.rb +1 -0
  129. data/lib/rdoc/ri/driver.rb +133 -58
  130. data/lib/rdoc/ri/formatter.rb +1 -0
  131. data/lib/rdoc/ri/paths.rb +4 -20
  132. data/lib/rdoc/ri/store.rb +1 -0
  133. data/lib/rdoc/ri/task.rb +71 -0
  134. data/lib/rdoc/ri.rb +1 -0
  135. data/lib/rdoc/rubygems_hook.rb +5 -12
  136. data/lib/rdoc/servlet.rb +24 -14
  137. data/lib/rdoc/single_class.rb +1 -0
  138. data/lib/rdoc/stats/normal.rb +20 -21
  139. data/lib/rdoc/stats/quiet.rb +1 -0
  140. data/lib/rdoc/stats/verbose.rb +1 -0
  141. data/lib/rdoc/stats.rb +1 -0
  142. data/lib/rdoc/store.rb +41 -41
  143. data/lib/rdoc/task.rb +2 -3
  144. data/lib/rdoc/text.rb +19 -38
  145. data/lib/rdoc/token_stream.rb +56 -32
  146. data/lib/rdoc/tom_doc.rb +17 -11
  147. data/lib/rdoc/top_level.rb +9 -2
  148. data/lib/rdoc/version.rb +8 -0
  149. data/lib/rdoc.rb +24 -10
  150. data/man/ri.1 +247 -0
  151. data/rdoc.gemspec +248 -0
  152. metadata +43 -236
  153. data/.autotest +0 -24
  154. data/.document +0 -5
  155. data/Manifest.txt +0 -306
  156. data/lib/gauntlet_rdoc.rb +0 -84
  157. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  158. data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
  159. data/lib/rdoc/markdown/literals_1_8.rb +0 -416
  160. data/lib/rdoc/markup/formatter_test_case.rb +0 -767
  161. data/lib/rdoc/markup/inline.rb +0 -1
  162. data/lib/rdoc/markup/special.rb +0 -40
  163. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -114
  164. data/lib/rdoc/ruby_lex.rb +0 -1377
  165. data/lib/rdoc/ruby_token.rb +0 -460
  166. data/lib/rdoc/test_case.rb +0 -217
  167. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
  168. data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
  169. data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
  170. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
  171. data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
  172. data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
  173. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
  174. data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
  175. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
  176. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
  177. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
  178. data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
  179. data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
  180. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
  181. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
  182. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
  183. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
  184. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
  185. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
  186. data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
  187. data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
  188. data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
  189. data/test/README +0 -1
  190. data/test/binary.dat +0 -0
  191. data/test/hidden.zip.txt +0 -1
  192. data/test/test.ja.largedoc +0 -3
  193. data/test/test.ja.rdoc +0 -10
  194. data/test/test.ja.txt +0 -8
  195. data/test/test.txt +0 -1
  196. data/test/test_rdoc_alias.rb +0 -13
  197. data/test/test_rdoc_any_method.rb +0 -460
  198. data/test/test_rdoc_attr.rb +0 -190
  199. data/test/test_rdoc_class_module.rb +0 -1492
  200. data/test/test_rdoc_code_object.rb +0 -450
  201. data/test/test_rdoc_comment.rb +0 -504
  202. data/test/test_rdoc_constant.rb +0 -181
  203. data/test/test_rdoc_context.rb +0 -901
  204. data/test/test_rdoc_context_section.rb +0 -130
  205. data/test/test_rdoc_cross_reference.rb +0 -192
  206. data/test/test_rdoc_encoding.rb +0 -227
  207. data/test/test_rdoc_extend.rb +0 -94
  208. data/test/test_rdoc_generator_darkfish.rb +0 -229
  209. data/test/test_rdoc_generator_json_index.rb +0 -324
  210. data/test/test_rdoc_generator_markup.rb +0 -59
  211. data/test/test_rdoc_generator_pot.rb +0 -91
  212. data/test/test_rdoc_generator_pot_po.rb +0 -51
  213. data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
  214. data/test/test_rdoc_generator_ri.rb +0 -78
  215. data/test/test_rdoc_i18n_locale.rb +0 -73
  216. data/test/test_rdoc_i18n_text.rb +0 -123
  217. data/test/test_rdoc_include.rb +0 -108
  218. data/test/test_rdoc_markdown.rb +0 -980
  219. data/test/test_rdoc_markdown_test.rb +0 -1884
  220. data/test/test_rdoc_markup.rb +0 -95
  221. data/test/test_rdoc_markup_attribute_manager.rb +0 -364
  222. data/test/test_rdoc_markup_attributes.rb +0 -39
  223. data/test/test_rdoc_markup_document.rb +0 -207
  224. data/test/test_rdoc_markup_formatter.rb +0 -175
  225. data/test/test_rdoc_markup_hard_break.rb +0 -31
  226. data/test/test_rdoc_markup_heading.rb +0 -29
  227. data/test/test_rdoc_markup_include.rb +0 -19
  228. data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
  229. data/test/test_rdoc_markup_paragraph.rb +0 -32
  230. data/test/test_rdoc_markup_parser.rb +0 -1680
  231. data/test/test_rdoc_markup_pre_process.rb +0 -473
  232. data/test/test_rdoc_markup_raw.rb +0 -22
  233. data/test/test_rdoc_markup_to_ansi.rb +0 -369
  234. data/test/test_rdoc_markup_to_bs.rb +0 -366
  235. data/test/test_rdoc_markup_to_html.rb +0 -662
  236. data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
  237. data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
  238. data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
  239. data/test/test_rdoc_markup_to_label.rb +0 -112
  240. data/test/test_rdoc_markup_to_markdown.rb +0 -389
  241. data/test/test_rdoc_markup_to_rdoc.rb +0 -377
  242. data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
  243. data/test/test_rdoc_markup_to_tt_only.rb +0 -246
  244. data/test/test_rdoc_markup_verbatim.rb +0 -29
  245. data/test/test_rdoc_method_attr.rb +0 -193
  246. data/test/test_rdoc_normal_class.rb +0 -47
  247. data/test/test_rdoc_normal_module.rb +0 -42
  248. data/test/test_rdoc_options.rb +0 -766
  249. data/test/test_rdoc_parser.rb +0 -327
  250. data/test/test_rdoc_parser_c.rb +0 -1896
  251. data/test/test_rdoc_parser_changelog.rb +0 -315
  252. data/test/test_rdoc_parser_markdown.rb +0 -61
  253. data/test/test_rdoc_parser_rd.rb +0 -55
  254. data/test/test_rdoc_parser_ruby.rb +0 -3322
  255. data/test/test_rdoc_parser_simple.rb +0 -115
  256. data/test/test_rdoc_rd.rb +0 -30
  257. data/test/test_rdoc_rd_block_parser.rb +0 -535
  258. data/test/test_rdoc_rd_inline.rb +0 -63
  259. data/test/test_rdoc_rd_inline_parser.rb +0 -177
  260. data/test/test_rdoc_rdoc.rb +0 -455
  261. data/test/test_rdoc_require.rb +0 -25
  262. data/test/test_rdoc_ri_driver.rb +0 -1436
  263. data/test/test_rdoc_ri_paths.rb +0 -155
  264. data/test/test_rdoc_ruby_lex.rb +0 -421
  265. data/test/test_rdoc_ruby_token.rb +0 -19
  266. data/test/test_rdoc_rubygems_hook.rb +0 -251
  267. data/test/test_rdoc_servlet.rb +0 -534
  268. data/test/test_rdoc_single_class.rb +0 -20
  269. data/test/test_rdoc_stats.rb +0 -722
  270. data/test/test_rdoc_store.rb +0 -993
  271. data/test/test_rdoc_task.rb +0 -173
  272. data/test/test_rdoc_text.rb +0 -557
  273. data/test/test_rdoc_token_stream.rb +0 -42
  274. data/test/test_rdoc_tom_doc.rb +0 -520
  275. data/test/test_rdoc_top_level.rb +0 -287
  276. data/test/xref_data.rb +0 -76
  277. data/test/xref_test_case.rb +0 -67
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Subclass of the RDoc::Markup::ToHtml class that supports looking up method
3
4
  # names, classes, etc to create links. RDoc::CrossReference is used to
@@ -38,26 +39,37 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
38
39
  @hyperlink_all = @options.hyperlink_all
39
40
  @show_hash = @options.show_hash
40
41
 
41
- crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
42
- @markup.add_special crossref_re, :CROSSREF
43
-
44
42
  @cross_reference = RDoc::CrossReference.new @context
45
43
  end
46
44
 
45
+ def init_link_notation_regexp_handlings
46
+ add_regexp_handling_RDOCLINK
47
+
48
+ # The crossref must be linked before tidylink because Klass.method[:sym]
49
+ # will be processed as a tidylink first and will be broken.
50
+ crossref_re = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
51
+ @markup.add_regexp_handling crossref_re, :CROSSREF
52
+
53
+ add_regexp_handling_TIDYLINK
54
+ end
55
+
47
56
  ##
48
57
  # Creates a link to the reference +name+ if the name exists. If +text+ is
49
58
  # given it is used as the link text, otherwise +name+ is used.
50
59
 
51
- def cross_reference name, text = nil
60
+ def cross_reference name, text = nil, code = true
52
61
  lookup = name
53
62
 
54
63
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
55
64
 
56
- name = "#{CGI.unescape $'} at #{$1}" if name =~ /(.*[^#:])@/
57
-
58
- text = name unless text
65
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
66
+ text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
67
+ code = false
68
+ else
69
+ text ||= name
70
+ end
59
71
 
60
- link lookup, text
72
+ link lookup, text, code
61
73
  end
62
74
 
63
75
  ##
@@ -67,8 +79,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
67
79
  # example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
68
80
  # because we look for it in module Markup first.
69
81
 
70
- def handle_special_CROSSREF(special)
71
- name = special.text
82
+ def handle_regexp_CROSSREF(target)
83
+ name = target.text
72
84
 
73
85
  return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
74
86
 
@@ -86,22 +98,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
86
98
  # Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
87
99
  # handle other schemes.
88
100
 
89
- def handle_special_HYPERLINK special
90
- return cross_reference $' if special.text =~ /\Ardoc-ref:/
101
+ def handle_regexp_HYPERLINK target
102
+ return cross_reference $' if target.text =~ /\Ardoc-ref:/
91
103
 
92
104
  super
93
105
  end
94
106
 
95
107
  ##
96
- # +special+ is an rdoc-schemed link that will be converted into a hyperlink.
108
+ # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
97
109
  # For the rdoc-ref scheme the cross-reference will be looked up and the
98
110
  # given name will be used.
99
111
  #
100
112
  # All other contents are handled by
101
- # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_special_RDOCLINK]
113
+ # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
102
114
 
103
- def handle_special_RDOCLINK special
104
- url = special.text
115
+ def handle_regexp_RDOCLINK target
116
+ url = target.text
105
117
 
106
118
  case url
107
119
  when /\Ardoc-ref:/ then
@@ -118,38 +130,42 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
118
130
  def gen_url url, text
119
131
  return super unless url =~ /\Ardoc-ref:/
120
132
 
121
- cross_reference $', text
133
+ name = $'
134
+ cross_reference name, text, name == text
122
135
  end
123
136
 
124
137
  ##
125
138
  # Creates an HTML link to +name+ with the given +text+.
126
139
 
127
- def link name, text
128
- original_name = name
129
-
130
- if name =~ /(.*[^#:])@/ then
140
+ def link name, text, code = true
141
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
131
142
  name = $1
132
143
  label = $'
133
144
  end
134
145
 
135
146
  ref = @cross_reference.resolve name, text
136
147
 
137
- text = ref.output_name @context if
138
- RDoc::MethodAttr === ref and text == original_name
139
-
140
148
  case ref
141
149
  when String then
142
150
  ref
143
151
  else
144
152
  path = ref.as_href @from_path
145
153
 
154
+ if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
155
+ text = "<code>#{CGI.escapeHTML text}</code>"
156
+ end
157
+
146
158
  if path =~ /#/ then
147
159
  path << "-label-#{label}"
148
160
  elsif ref.sections and
149
161
  ref.sections.any? { |section| label == section.title } then
150
162
  path << "##{label}"
151
163
  else
152
- path << "#label-#{label}"
164
+ if ref.respond_to?(:aref)
165
+ path << "##{ref.aref}-label-#{label}"
166
+ else
167
+ path << "#label-#{label}"
168
+ end
153
169
  end if label
154
170
 
155
171
  "<a href=\"#{path}\">#{text}</a>"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Outputs RDoc markup as paragraphs with inline markup only.
3
4
 
@@ -43,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
43
44
  @mask = 0
44
45
  @paragraphs = 0
45
46
 
46
- @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
47
+ @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
47
48
  end
48
49
 
49
50
  ##
@@ -70,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
70
71
 
71
72
  text = paragraph.text @hard_break
72
73
 
73
- @res << "#{para}#{wrap to_html text}\n"
74
+ @res << "#{para}#{to_html text}\n"
74
75
 
75
76
  add_paragraph
76
77
  end
@@ -122,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
122
123
  end
123
124
 
124
125
  ##
125
- # Removes escaping from the cross-references in +special+
126
+ # Removes escaping from the cross-references in +target+
126
127
 
127
- def handle_special_CROSSREF special
128
- special.text.sub(/\A\\/, '')
128
+ def handle_regexp_CROSSREF target
129
+ target.text.sub(/\A\\/, '')
129
130
  end
130
131
 
131
132
  ##
132
- # +special+ is a <code><br></code>
133
+ # +target+ is a <code><br></code>
133
134
 
134
- def handle_special_HARD_BREAK special
135
+ def handle_regexp_HARD_BREAK target
135
136
  @characters -= 4
136
137
  '<br>'
137
138
  end
@@ -225,8 +226,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
225
226
  when String then
226
227
  text = convert_string item
227
228
  res << truncate(text)
228
- when RDoc::Markup::Special then
229
- text = convert_special item
229
+ when RDoc::Markup::RegexpHandling then
230
+ text = convert_regexp_handling item
230
231
  res << truncate(text)
231
232
  else
232
233
  raise "Unknown flow element: #{item.inspect}"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Joins the parts of an RDoc::Markup::Paragraph into a single String.
3
4
  #
@@ -22,37 +23,11 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
22
23
  # Converts the parts of +paragraph+ to a single entry.
23
24
 
24
25
  def accept_paragraph paragraph
25
- parts = []
26
- string = false
27
-
28
- paragraph.parts.each do |part|
29
- if String === part then
30
- if string then
31
- string << part
32
- else
33
- parts << part
34
- string = part
35
- end
36
- else
37
- parts << part
38
- string = false
39
- end
40
- end
41
-
42
- parts = parts.map do |part|
43
- if String === part then
44
- part.rstrip
45
- else
46
- part
47
- end
48
- end
49
-
50
- # TODO use Enumerable#chunk when Ruby 1.8 support is dropped
51
- #parts = paragraph.parts.chunk do |part|
52
- # String === part
53
- #end.map do |string, chunk|
54
- # string ? chunk.join.rstrip : chunk
55
- #end.flatten
26
+ parts = paragraph.parts.chunk do |part|
27
+ String === part
28
+ end.map do |string, chunk|
29
+ string ? chunk.join.rstrip : chunk
30
+ end.flatten
56
31
 
57
32
  paragraph.parts.replace parts
58
33
  end
@@ -66,6 +41,7 @@ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
66
41
  alias accept_raw ignore
67
42
  alias accept_rule ignore
68
43
  alias accept_verbatim ignore
44
+ alias accept_table ignore
69
45
 
70
46
  end
71
47
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cgi'
2
3
 
3
4
  ##
@@ -15,8 +16,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
15
16
  def initialize markup = nil
16
17
  super nil, markup
17
18
 
18
- @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
19
- @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
19
+ @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
20
+ @markup.add_regexp_handling(/(((\{.*?\})|\b\S+?)\[\S+?\])/, :TIDYLINK)
20
21
 
21
22
  add_tag :BOLD, '', ''
22
23
  add_tag :TT, '', ''
@@ -35,20 +36,20 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
35
36
  end
36
37
 
37
38
  ##
38
- # Converts the CROSSREF +special+ to plain text, removing the suppression
39
+ # Converts the CROSSREF +target+ to plain text, removing the suppression
39
40
  # marker, if any
40
41
 
41
- def handle_special_CROSSREF special
42
- text = special.text
42
+ def handle_regexp_CROSSREF target
43
+ text = target.text
43
44
 
44
45
  text.sub(/^\\/, '')
45
46
  end
46
47
 
47
48
  ##
48
- # Converts the TIDYLINK +special+ to just the text part
49
+ # Converts the TIDYLINK +target+ to just the text part
49
50
 
50
- def handle_special_TIDYLINK special
51
- text = special.text
51
+ def handle_regexp_TIDYLINK target
52
+ text = target.text
52
53
 
53
54
  return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
54
55
 
@@ -67,7 +68,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
67
68
  alias accept_rule ignore
68
69
  alias accept_verbatim ignore
69
70
  alias end_accepting ignore
70
- alias handle_special_HARD_BREAK ignore
71
+ alias handle_regexp_HARD_BREAK ignore
71
72
  alias start_accepting ignore
72
73
 
73
74
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # :markup: markdown
2
3
 
3
4
  ##
@@ -18,8 +19,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
18
19
  @headings[5] = ['##### ', '']
19
20
  @headings[6] = ['###### ', '']
20
21
 
21
- add_special_RDOCLINK
22
- add_special_TIDYLINK
22
+ add_regexp_handling_RDOCLINK
23
+ add_regexp_handling_TIDYLINK
23
24
 
24
25
  @hard_break = " \n"
25
26
  end
@@ -36,7 +37,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
36
37
  ##
37
38
  # Adds a newline to the output
38
39
 
39
- def handle_special_HARD_BREAK special
40
+ def handle_regexp_HARD_BREAK target
40
41
  " \n"
41
42
  end
42
43
 
@@ -130,7 +131,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
130
131
  @res << part
131
132
  end
132
133
 
133
- @res << "\n" unless @res =~ /\n\z/
134
+ @res << "\n"
134
135
  end
135
136
 
136
137
  ##
@@ -165,8 +166,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
165
166
  ##
166
167
  # Converts the RDoc markup tidylink into a Markdown.style link.
167
168
 
168
- def handle_special_TIDYLINK special
169
- text = special.text
169
+ def handle_regexp_TIDYLINK target
170
+ text = target.text
170
171
 
171
172
  return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
172
173
 
@@ -183,8 +184,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
183
184
  ##
184
185
  # Converts the rdoc-...: links into a Markdown.style links.
185
186
 
186
- def handle_special_RDOCLINK special
187
- handle_rdoc_link special.text
187
+ def handle_regexp_RDOCLINK target
188
+ handle_rdoc_link target.text
188
189
  end
189
190
 
190
191
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Outputs RDoc markup as RDoc markup! (mostly)
3
4
 
@@ -44,7 +45,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
44
45
  def initialize markup = nil
45
46
  super nil, markup
46
47
 
47
- @markup.add_special(/\\\S/, :SUPPRESSED_CROSSREF)
48
+ @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
48
49
  @width = 78
49
50
  init_tags
50
51
 
@@ -233,7 +234,35 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
233
234
  @res << part
234
235
  end
235
236
 
236
- @res << "\n" unless @res =~ /\n\z/
237
+ @res << "\n"
238
+ end
239
+
240
+ ##
241
+ # Adds +table+ to the output
242
+
243
+ def accept_table header, body, aligns
244
+ widths = header.zip(body) do |h, b|
245
+ [h.size, b.size].max
246
+ end
247
+ aligns = aligns.map do |a|
248
+ case a
249
+ when nil
250
+ :center
251
+ when :left
252
+ :ljust
253
+ when :right
254
+ :rjust
255
+ end
256
+ end
257
+ @res << header.zip(widths, aligns) do |h, w, a|
258
+ h.__send__(a, w)
259
+ end.join("|").rstrip << "\n"
260
+ @res << widths.map {|w| "-" * w }.join("|") << "\n"
261
+ body.each do |row|
262
+ @res << row.zip(widths, aligns) do |t, w, a|
263
+ t.__send__(a, w)
264
+ end.join("|").rstrip << "\n"
265
+ end
237
266
  end
238
267
 
239
268
  ##
@@ -252,10 +281,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
252
281
  end
253
282
 
254
283
  ##
255
- # Removes preceding \\ from the suppressed crossref +special+
284
+ # Removes preceding \\ from the suppressed crossref +target+
256
285
 
257
- def handle_special_SUPPRESSED_CROSSREF special
258
- text = special.text
286
+ def handle_regexp_SUPPRESSED_CROSSREF target
287
+ text = target.text
259
288
  text = text.sub('\\', '') unless in_tt?
260
289
  text
261
290
  end
@@ -263,7 +292,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
263
292
  ##
264
293
  # Adds a newline to the output
265
294
 
266
- def handle_special_HARD_BREAK special
295
+ def handle_regexp_HARD_BREAK target
267
296
  "\n"
268
297
  end
269
298
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Extracts just the RDoc::Markup::Heading elements from a
3
4
  # RDoc::Markup::Document to help build a table of contents
@@ -81,6 +82,7 @@ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
81
82
  alias accept_list_item_end ignore
82
83
  alias accept_list_end_bullet ignore
83
84
  alias accept_list_start ignore
85
+ alias accept_table ignore
84
86
  # :startdoc:
85
87
 
86
88
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # This Markup outputter is used for testing purposes.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Extracts sections of text enclosed in plus, tt or code. Used to discover
3
4
  # undocumented parameters.
@@ -90,8 +91,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
90
91
  when RDoc::Markup::AttrChanger then
91
92
  off_tags res, item
92
93
  on_tags res, item
93
- when RDoc::Markup::Special then
94
- @res << convert_special(item) if in_tt? # TODO can this happen?
94
+ when RDoc::Markup::RegexpHandling then
95
+ @res << convert_regexp_handling(item) if in_tt? # TODO can this happen?
95
96
  else
96
97
  raise "Unknown flow element: #{item.inspect}"
97
98
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # A section of verbatim text
3
4
 
data/lib/rdoc/markup.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # RDoc::Markup parses plain text documents and attempts to decompose them into
3
4
  # their constituent parts. Some of these parts are high-level: paragraphs,
@@ -64,17 +65,16 @@
64
65
  # puts h.convert(input_string)
65
66
  #
66
67
  # You can extend the RDoc::Markup parser to recognize new markup
67
- # sequences, and to add special processing for text that matches a
68
- # regular expression. Here we make WikiWords significant to the parser,
69
- # and also make the sequences {word} and \<no>text...</no> signify
68
+ # sequences, and to add regexp handling. Here we make WikiWords significant to
69
+ # the parser, and also make the sequences {word} and \<no>text...</no> signify
70
70
  # strike-through text. We then subclass the HTML output class to deal
71
71
  # with these:
72
72
  #
73
73
  # require 'rdoc'
74
74
  #
75
75
  # class WikiHtml < RDoc::Markup::ToHtml
76
- # def handle_special_WIKIWORD(special)
77
- # "<font color=red>" + special.text + "</font>"
76
+ # def handle_regexp_WIKIWORD(target)
77
+ # "<font color=red>" + target.text + "</font>"
78
78
  # end
79
79
  # end
80
80
  #
@@ -82,7 +82,7 @@
82
82
  # markup.add_word_pair("{", "}", :STRIKE)
83
83
  # markup.add_html("no", :STRIKE)
84
84
  #
85
- # markup.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
85
+ # markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
86
86
  #
87
87
  # wh = WikiHtml.new RDoc::Options.new, markup
88
88
  # wh.add_tag(:STRIKE, "<strike>", "</strike>")
@@ -376,7 +376,7 @@
376
376
  #
377
377
  # Example links:
378
378
  #
379
- # https://github.com/rdoc/rdoc
379
+ # https://github.com/ruby/rdoc
380
380
  # mailto:user@example.com
381
381
  # {RDoc Documentation}[http://rdoc.rubyforge.org]
382
382
  # {RDoc Markup}[rdoc-ref:RDoc::Markup]
@@ -763,7 +763,7 @@ Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE}
763
763
 
764
764
  Please file a bug report with the above information at:
765
765
 
766
- https://github.com/rdoc/rdoc/issues
766
+ https://github.com/ruby/rdoc/issues
767
767
 
768
768
  EOF
769
769
  raise
@@ -799,13 +799,12 @@ https://github.com/rdoc/rdoc/issues
799
799
  # Add to other inline sequences. For example, we could add WikiWords using
800
800
  # something like:
801
801
  #
802
- # parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
802
+ # parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
803
803
  #
804
- # Each wiki word will be presented to the output formatter via the
805
- # accept_special method.
804
+ # Each wiki word will be presented to the output formatter.
806
805
 
807
- def add_special(pattern, name)
808
- @attribute_manager.add_special(pattern, name)
806
+ def add_regexp_handling(pattern, name)
807
+ @attribute_manager.add_regexp_handling(pattern, name)
809
808
  end
810
809
 
811
810
  ##
@@ -831,7 +830,7 @@ https://github.com/rdoc/rdoc/issues
831
830
  autoload :AttrSpan, 'rdoc/markup/attr_span'
832
831
  autoload :Attributes, 'rdoc/markup/attributes'
833
832
  autoload :AttributeManager, 'rdoc/markup/attribute_manager'
834
- autoload :Special, 'rdoc/markup/special'
833
+ autoload :RegexpHandling, 'rdoc/markup/regexp_handling'
835
834
 
836
835
  # RDoc::Markup AST
837
836
  autoload :BlankLine, 'rdoc/markup/blank_line'
@@ -844,14 +843,13 @@ https://github.com/rdoc/rdoc/issues
844
843
  autoload :List, 'rdoc/markup/list'
845
844
  autoload :ListItem, 'rdoc/markup/list_item'
846
845
  autoload :Paragraph, 'rdoc/markup/paragraph'
846
+ autoload :Table, 'rdoc/markup/table'
847
847
  autoload :Raw, 'rdoc/markup/raw'
848
848
  autoload :Rule, 'rdoc/markup/rule'
849
849
  autoload :Verbatim, 'rdoc/markup/verbatim'
850
850
 
851
851
  # Formatters
852
852
  autoload :Formatter, 'rdoc/markup/formatter'
853
- autoload :FormatterTestCase, 'rdoc/markup/formatter_test_case'
854
- autoload :TextFormatterTestCase, 'rdoc/markup/text_formatter_test_case'
855
853
 
856
854
  autoload :ToAnsi, 'rdoc/markup/to_ansi'
857
855
  autoload :ToBs, 'rdoc/markup/to_bs'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # MetaMethod represents a meta-programmed method
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Abstract class representing either a method or an attribute.
3
4
 
@@ -187,7 +188,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
187
188
  next if String === ancestor
188
189
  next if parent == ancestor
189
190
 
190
- other = ancestor.find_method_named('#' << name) ||
191
+ other = ancestor.find_method_named('#' + name) ||
191
192
  ancestor.find_attribute_named(name)
192
193
 
193
194
  return other if other
data/lib/rdoc/mixin.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # A Mixin adds features from a module into another context. RDoc::Include and
3
4
  # RDoc::Extend are both mixins.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # A normal class, neither singleton nor anonymous
3
4
 
@@ -46,9 +47,9 @@ class RDoc::NormalClass < RDoc::ClassModule
46
47
  def to_s # :nodoc:
47
48
  display = "#{self.class.name} #{self.full_name}"
48
49
  if superclass
49
- display << ' < ' << (superclass.is_a?(String) ? superclass : superclass.full_name)
50
+ display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
50
51
  end
51
- display << ' -> ' << is_alias_for.to_s if is_alias_for
52
+ display += ' -> ' + is_alias_for.to_s if is_alias_for
52
53
  display
53
54
  end
54
55
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # A normal module, like NormalClass
3
4