rdoc 3.1 → 6.3.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 (247) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +129 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +84 -81
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/{bin → exe}/rdoc +11 -2
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +1 -2
  19. data/lib/rdoc/anon_class.rb +3 -2
  20. data/lib/rdoc/any_method.rb +234 -40
  21. data/lib/rdoc/attr.rb +79 -11
  22. data/lib/rdoc/class_module.rb +443 -71
  23. data/lib/rdoc/code_object.rb +216 -20
  24. data/lib/rdoc/code_objects.rb +4 -21
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +110 -9
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +392 -172
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +83 -28
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +8 -3
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +507 -84
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +27 -74
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +8 -62
  42. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  43. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  57. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  58. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  59. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  60. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
  72. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
  73. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  74. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  75. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  76. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  77. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  78. data/lib/rdoc/generator/template/json_index/.document +1 -0
  79. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  80. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  81. data/lib/rdoc/generator.rb +24 -13
  82. data/lib/rdoc/ghost_method.rb +1 -2
  83. data/lib/rdoc/i18n/locale.rb +102 -0
  84. data/lib/rdoc/i18n/text.rb +126 -0
  85. data/lib/rdoc/i18n.rb +10 -0
  86. data/lib/rdoc/include.rb +5 -95
  87. data/lib/rdoc/known_classes.rb +5 -2
  88. data/lib/rdoc/markdown/entities.rb +2132 -0
  89. data/lib/rdoc/markdown/literals.kpeg +23 -0
  90. data/lib/rdoc/markdown/literals.rb +416 -0
  91. data/lib/rdoc/markdown.kpeg +1237 -0
  92. data/lib/rdoc/markdown.rb +16684 -0
  93. data/lib/rdoc/markup/attr_changer.rb +23 -0
  94. data/lib/rdoc/markup/attr_span.rb +36 -0
  95. data/lib/rdoc/markup/attribute_manager.rb +135 -62
  96. data/lib/rdoc/markup/attributes.rb +71 -0
  97. data/lib/rdoc/markup/blank_line.rb +1 -0
  98. data/lib/rdoc/markup/block_quote.rb +15 -0
  99. data/lib/rdoc/markup/document.rb +96 -9
  100. data/lib/rdoc/markup/formatter.rb +138 -25
  101. data/lib/rdoc/markup/hard_break.rb +32 -0
  102. data/lib/rdoc/markup/heading.rb +61 -2
  103. data/lib/rdoc/markup/include.rb +43 -0
  104. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  105. data/lib/rdoc/markup/list.rb +25 -4
  106. data/lib/rdoc/markup/list_item.rb +18 -4
  107. data/lib/rdoc/markup/paragraph.rb +15 -0
  108. data/lib/rdoc/markup/parser.rb +180 -88
  109. data/lib/rdoc/markup/pre_process.rb +183 -38
  110. data/lib/rdoc/markup/raw.rb +6 -5
  111. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  112. data/lib/rdoc/markup/rule.rb +1 -0
  113. data/lib/rdoc/markup/table.rb +47 -0
  114. data/lib/rdoc/markup/to_ansi.rb +17 -7
  115. data/lib/rdoc/markup/to_bs.rb +5 -8
  116. data/lib/rdoc/markup/to_html.rb +238 -137
  117. data/lib/rdoc/markup/to_html_crossref.rb +125 -152
  118. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  119. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  120. data/lib/rdoc/markup/to_label.rb +75 -0
  121. data/lib/rdoc/markup/to_markdown.rb +192 -0
  122. data/lib/rdoc/markup/to_rdoc.rb +85 -15
  123. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  124. data/lib/rdoc/markup/to_test.rb +2 -4
  125. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  126. data/lib/rdoc/markup/verbatim.rb +39 -0
  127. data/lib/rdoc/markup.rb +388 -110
  128. data/lib/rdoc/meta_method.rb +1 -2
  129. data/lib/rdoc/method_attr.rb +87 -21
  130. data/lib/rdoc/mixin.rb +121 -0
  131. data/lib/rdoc/normal_class.rb +39 -10
  132. data/lib/rdoc/normal_module.rb +22 -7
  133. data/lib/rdoc/options.rb +613 -73
  134. data/lib/rdoc/parser/c.rb +621 -287
  135. data/lib/rdoc/parser/changelog.rb +335 -0
  136. data/lib/rdoc/parser/markdown.rb +24 -0
  137. data/lib/rdoc/parser/rd.rb +23 -0
  138. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  139. data/lib/rdoc/parser/ruby.rb +1368 -762
  140. data/lib/rdoc/parser/ruby_tools.rb +42 -35
  141. data/lib/rdoc/parser/simple.rb +23 -11
  142. data/lib/rdoc/parser/text.rb +12 -0
  143. data/lib/rdoc/parser.rb +162 -89
  144. data/lib/rdoc/rd/block_parser.rb +1056 -0
  145. data/lib/rdoc/rd/block_parser.ry +639 -0
  146. data/lib/rdoc/rd/inline.rb +72 -0
  147. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  148. data/lib/rdoc/rd/inline_parser.ry +593 -0
  149. data/lib/rdoc/rd.rb +100 -0
  150. data/lib/rdoc/rdoc.rb +208 -115
  151. data/lib/rdoc/require.rb +1 -2
  152. data/lib/rdoc/ri/driver.rb +734 -239
  153. data/lib/rdoc/ri/formatter.rb +1 -0
  154. data/lib/rdoc/ri/paths.rb +91 -48
  155. data/lib/rdoc/ri/store.rb +3 -261
  156. data/lib/rdoc/ri/task.rb +71 -0
  157. data/lib/rdoc/ri.rb +5 -2
  158. data/lib/rdoc/rubygems_hook.rb +246 -0
  159. data/lib/rdoc/servlet.rb +451 -0
  160. data/lib/rdoc/single_class.rb +14 -2
  161. data/lib/rdoc/stats/normal.rb +19 -12
  162. data/lib/rdoc/stats/quiet.rb +1 -0
  163. data/lib/rdoc/stats/verbose.rb +1 -0
  164. data/lib/rdoc/stats.rb +262 -104
  165. data/lib/rdoc/store.rb +979 -0
  166. data/lib/rdoc/task.rb +84 -44
  167. data/lib/rdoc/text.rb +117 -72
  168. data/lib/rdoc/token_stream.rb +73 -4
  169. data/lib/rdoc/tom_doc.rb +263 -0
  170. data/lib/rdoc/top_level.rb +111 -261
  171. data/lib/rdoc/version.rb +8 -0
  172. data/lib/rdoc.rb +127 -64
  173. data/man/ri.1 +247 -0
  174. data/rdoc.gemspec +249 -0
  175. metadata +171 -291
  176. data/.autotest +0 -16
  177. data/.document +0 -5
  178. data/History.txt +0 -594
  179. data/LICENSE.txt +0 -57
  180. data/Manifest.txt +0 -158
  181. data/README.txt +0 -45
  182. data/RI.txt +0 -58
  183. data/bin/ri +0 -5
  184. data/lib/rdoc/gauntlet.rb +0 -52
  185. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
  186. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  187. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
  188. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  189. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
  190. data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
  191. data/lib/rdoc/markup/formatter_test_case.rb +0 -689
  192. data/lib/rdoc/markup/inline.rb +0 -137
  193. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
  194. data/lib/rdoc/ruby_lex.rb +0 -1291
  195. data/lib/rdoc/ruby_token.rb +0 -416
  196. data/test/README +0 -1
  197. data/test/binary.dat +0 -0
  198. data/test/hidden.zip.txt +0 -1
  199. data/test/test.ja.rdoc +0 -10
  200. data/test/test.ja.txt +0 -8
  201. data/test/test.txt +0 -1
  202. data/test/test_attribute_manager.rb +0 -120
  203. data/test/test_rdoc_alias.rb +0 -13
  204. data/test/test_rdoc_any_method.rb +0 -126
  205. data/test/test_rdoc_attr.rb +0 -61
  206. data/test/test_rdoc_class_module.rb +0 -233
  207. data/test/test_rdoc_code_object.rb +0 -165
  208. data/test/test_rdoc_constant.rb +0 -15
  209. data/test/test_rdoc_context.rb +0 -370
  210. data/test/test_rdoc_encoding.rb +0 -166
  211. data/test/test_rdoc_generator_darkfish.rb +0 -119
  212. data/test/test_rdoc_generator_ri.rb +0 -76
  213. data/test/test_rdoc_include.rb +0 -96
  214. data/test/test_rdoc_markup.rb +0 -37
  215. data/test/test_rdoc_markup_attribute_manager.rb +0 -240
  216. data/test/test_rdoc_markup_document.rb +0 -51
  217. data/test/test_rdoc_markup_paragraph.rb +0 -9
  218. data/test/test_rdoc_markup_parser.rb +0 -1395
  219. data/test/test_rdoc_markup_pre_process.rb +0 -185
  220. data/test/test_rdoc_markup_raw.rb +0 -27
  221. data/test/test_rdoc_markup_to_ansi.rb +0 -328
  222. data/test/test_rdoc_markup_to_bs.rb +0 -341
  223. data/test/test_rdoc_markup_to_html.rb +0 -335
  224. data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
  225. data/test/test_rdoc_markup_to_rdoc.rb +0 -327
  226. data/test/test_rdoc_method_attr.rb +0 -122
  227. data/test/test_rdoc_normal_class.rb +0 -17
  228. data/test/test_rdoc_normal_module.rb +0 -31
  229. data/test/test_rdoc_options.rb +0 -342
  230. data/test/test_rdoc_parser.rb +0 -83
  231. data/test/test_rdoc_parser_c.rb +0 -912
  232. data/test/test_rdoc_parser_ruby.rb +0 -1754
  233. data/test/test_rdoc_parser_simple.rb +0 -99
  234. data/test/test_rdoc_rdoc.rb +0 -164
  235. data/test/test_rdoc_require.rb +0 -25
  236. data/test/test_rdoc_ri_driver.rb +0 -846
  237. data/test/test_rdoc_ri_paths.rb +0 -43
  238. data/test/test_rdoc_ri_store.rb +0 -352
  239. data/test/test_rdoc_ruby_lex.rb +0 -23
  240. data/test/test_rdoc_stats.rb +0 -38
  241. data/test/test_rdoc_task.rb +0 -92
  242. data/test/test_rdoc_text.rb +0 -251
  243. data/test/test_rdoc_top_level.rb +0 -120
  244. data/test/xref_data.rb +0 -62
  245. data/test/xref_test_case.rb +0 -61
  246. data.tar.gz.sig +0 -3
  247. metadata.gz.sig +0 -0
@@ -0,0 +1,593 @@
1
+ class InlineParser
2
+
3
+ preclow
4
+ nonassoc EX_LOW
5
+ left QUOTE
6
+ BAR
7
+ SLASH
8
+ BACK_SLASH
9
+ URL
10
+ OTHER
11
+ REF_OPEN
12
+ FOOTNOTE_OPEN
13
+ FOOTNOTE_CLOSE
14
+ nonassoc EX_HIGH
15
+ prechigh
16
+
17
+ token EM_OPEN
18
+ EM_CLOSE
19
+ CODE_OPEN
20
+ CODE_CLOSE
21
+ VAR_OPEN
22
+ VAR_CLOSE
23
+ KBD_OPEN
24
+ KBD_CLOSE
25
+ INDEX_OPEN
26
+ INDEX_CLOSE
27
+ REF_OPEN
28
+ REF_CLOSE
29
+ FOOTNOTE_OPEN
30
+ FOOTNOTE_CLOSE
31
+ VERB_OPEN
32
+ VERB_CLOSE
33
+ BAR
34
+ QUOTE
35
+ SLASH
36
+ BACK_SLASH
37
+ URL
38
+ OTHER
39
+ EX_LOW
40
+ EX_HIGH
41
+
42
+ rule
43
+ content : elements
44
+ ;
45
+
46
+ elements : elements element { result.append val[1] }
47
+ | element { result = val[0] }
48
+ ;
49
+
50
+ element : emphasis
51
+ | code
52
+ | var
53
+ | keyboard
54
+ | index
55
+ | reference
56
+ | footnote
57
+ | verb
58
+ | normal_str_ele
59
+ ;
60
+
61
+ emphasis : EM_OPEN content EM_CLOSE {
62
+ content = val[1]
63
+ result = inline "<em>#{content}</em>", content
64
+ }
65
+ ;
66
+
67
+ code : CODE_OPEN content CODE_CLOSE {
68
+ content = val[1]
69
+ result = inline "<code>#{content}</code>", content
70
+ }
71
+ ;
72
+
73
+ var : VAR_OPEN content VAR_CLOSE {
74
+ content = val[1]
75
+ result = inline "+#{content}+", content
76
+ }
77
+ ;
78
+
79
+ keyboard : KBD_OPEN content KBD_CLOSE {
80
+ content = val[1]
81
+ result = inline "<tt>#{content}</tt>", content
82
+ }
83
+ ;
84
+
85
+ index : INDEX_OPEN content INDEX_CLOSE {
86
+ label = val[1]
87
+ @block_parser.add_label label.reference
88
+ result = "<span id=\"label-#{label}\">#{label}</span>"
89
+ }
90
+ ;
91
+
92
+ # Reference
93
+ # ((<subst|filename/element_label>))
94
+
95
+ reference : REF_OPEN substitute ref_label REF_CLOSE {
96
+ result = "{#{val[1]}}[#{val[2].join}]"
97
+ } | REF_OPEN ref_label2 REF_CLOSE {
98
+ scheme, inline = val[1]
99
+
100
+ result = "{#{inline}}[#{scheme}#{inline.reference}]"
101
+ }
102
+ ;
103
+
104
+ # result is scheme and reference
105
+ ref_label : URL ref_url_strings {
106
+ result = [nil, inline(val[1])]
107
+ } | filename element_label {
108
+ result = [
109
+ 'rdoc-label:',
110
+ inline("#{val[0].reference}/#{val[1].reference}")
111
+ ]
112
+ } | element_label {
113
+ result = ['rdoc-label:', val[0].reference]
114
+ } | filename {
115
+ result = ['rdoc-label:', "#{val[0].reference}/"]
116
+ }
117
+ ;
118
+
119
+ # result is reference type and value
120
+ ref_label2 : URL ref_url_strings {
121
+ result = [nil, inline(val[1])]
122
+ } | filename element_label2 {
123
+ result = [
124
+ 'rdoc-label:',
125
+ inline("#{val[0].reference}/#{val[1].reference}")
126
+ ]
127
+ } | element_label2 {
128
+ result = ['rdoc-label:', val[0]]
129
+ } | filename {
130
+ ref = val[0].reference
131
+ result = ['rdoc-label:', inline(ref, "#{ref}/")]
132
+ }
133
+ ;
134
+
135
+ substitute : ref_subst_content BAR
136
+ | QUOTE ref_subst_content_q QUOTE BAR { result = val[1] }
137
+ | QUOTE ref_subst_strings_q QUOTE BAR { result = val[1] }
138
+ ;
139
+
140
+ filename : ref_subst_strings_first SLASH {
141
+ result = inline val[0]
142
+ } | QUOTE ref_subst_strings_q QUOTE SLASH {
143
+ result = inline "\"#{val[1]}\""
144
+ }
145
+ ;
146
+
147
+ # when substitute part exists
148
+ element_label : ref_subst_strings_first {
149
+ result = inline val[0]
150
+ } | QUOTE ref_subst_strings_q QUOTE {
151
+ result = inline "\"#{val[1]}\""
152
+ }
153
+ ;
154
+
155
+ # when substitute part doesn't exist
156
+ # in this case, element label can contain Inlines
157
+ element_label2 : ref_subst_content
158
+ | QUOTE ref_subst_content_q QUOTE { result = val[1] }
159
+ | QUOTE ref_subst_strings_q QUOTE { result = inline val[1] }
160
+ ;
161
+
162
+ ref_subst_content : ref_subst_ele2 ref_subst_eles {
163
+ result = val[0].append val[1]
164
+ } | ref_subst_str_ele_first ref_subst_eles {
165
+ result = val[0].append val[1]
166
+ } | ref_subst_str_ele_first {
167
+ result = val[0]
168
+ } | ref_subst_ele2 {
169
+ result = inline val[0]
170
+ }
171
+ ;
172
+
173
+ ref_subst_content_q : ref_subst_eles_q
174
+ ;
175
+
176
+ ref_subst_eles : ref_subst_eles ref_subst_ele {
177
+ result = val[0].append val[1]
178
+ } | ref_subst_ele {
179
+ result = inline val[0]
180
+ }
181
+ ;
182
+
183
+ ref_subst_eles_q : ref_subst_eles_q ref_subst_ele_q {
184
+ result = val[0].append val[1]
185
+ } | ref_subst_ele_q {
186
+ result = val[0]
187
+ }
188
+ ;
189
+
190
+ ref_subst_ele2 : emphasis
191
+ | code
192
+ | var
193
+ | keyboard
194
+ | index
195
+ | verb
196
+ ;
197
+
198
+ ref_subst_ele : ref_subst_ele2
199
+ | ref_subst_str_ele
200
+ ;
201
+
202
+ ref_subst_ele_q : ref_subst_ele2
203
+ | ref_subst_str_ele_q
204
+ ;
205
+
206
+ ref_subst_str_ele : ref_subst_strings = EX_LOW {
207
+ result = val[0]
208
+ }
209
+ ;
210
+
211
+ ref_subst_str_ele_first : ref_subst_strings_first {
212
+ result = inline val[0]
213
+ }
214
+ ;
215
+
216
+ ref_subst_str_ele_q : ref_subst_strings_q = EX_LOW {
217
+ result = inline val[0]
218
+ }
219
+ ;
220
+
221
+ ref_subst_strings : ref_subst_strings ref_subst_string3 { result << val[1] }
222
+ | ref_subst_string3
223
+ ;
224
+
225
+ # if it is first element of substitute, it can't contain URL on head.
226
+ ref_subst_strings_first : ref_subst_string ref_subst_strings = EX_HIGH {
227
+ result << val[1]
228
+ } | ref_subst_string = EX_LOW
229
+ ;
230
+
231
+ ref_subst_strings_q : ref_subst_strings_q ref_subst_string_q {
232
+ result << val[1]
233
+ } | ref_subst_string_q
234
+ ;
235
+
236
+ ref_subst_string : OTHER
237
+ | BACK_SLASH
238
+ | REF_OPEN
239
+ | FOOTNOTE_OPEN
240
+ | FOOTNOTE_CLOSE
241
+ ;
242
+
243
+ ref_subst_string2 : ref_subst_string
244
+ | URL
245
+ ;
246
+
247
+ ref_subst_string3 : ref_subst_string2
248
+ | QUOTE
249
+ ;
250
+
251
+ ref_subst_string_q : ref_subst_string2
252
+ | BAR
253
+ | SLASH
254
+ ;
255
+
256
+ # end subst
257
+
258
+ # string in url
259
+ ref_url_strings : ref_url_strings ref_url_string { result << val[1] }
260
+ | ref_url_string
261
+ ;
262
+
263
+ ref_url_string : OTHER
264
+ | BACK_SLASH BACK_SLASH
265
+ | URL
266
+ | SLASH
267
+ | BAR
268
+ | QUOTE
269
+ | EM_OPEN
270
+ | EM_CLOSE
271
+ | CODE_OPEN
272
+ | CODE_CLOSE
273
+ | VAR_OPEN
274
+ | VAR_CLOSE
275
+ | KBD_OPEN
276
+ | KBD_CLOSE
277
+ | INDEX_OPEN
278
+ | INDEX_CLOSE
279
+ | REF_OPEN
280
+ | FOOTNOTE_OPEN
281
+ | FOOTNOTE_CLOSE
282
+ | VERB_OPEN
283
+ | VERB_CLOSE
284
+ ;
285
+
286
+ # end url
287
+ # end Reference
288
+
289
+ footnote : FOOTNOTE_OPEN content FOOTNOTE_CLOSE {
290
+ index = @block_parser.add_footnote val[1].rdoc
291
+ result = "{*#{index}}[rdoc-label:foottext-#{index}:footmark-#{index}]"
292
+ }
293
+ ;
294
+
295
+ verb : VERB_OPEN verb_strings VERB_CLOSE {
296
+ result = inline "<tt>#{val[1]}</tt>", val[1]
297
+ }
298
+ ;
299
+
300
+ # normal string
301
+ # OTHER, QUOTE, BAR, SLASH, BACK_SLASH, URL
302
+ normal_string : OTHER
303
+ | QUOTE
304
+ | BAR
305
+ | SLASH
306
+ | BACK_SLASH
307
+ | URL
308
+ ;
309
+
310
+ normal_strings : normal_strings normal_string { result << val[1] }
311
+ | normal_string
312
+ ;
313
+
314
+ normal_str_ele : normal_strings = EX_LOW {
315
+ result = inline val[0]
316
+ }
317
+ ;
318
+
319
+ # in verb
320
+ verb_string : verb_normal_string
321
+ | BACK_SLASH verb_normal_string { result = val[1] }
322
+ | BACK_SLASH VERB_CLOSE { result = val[1] }
323
+ | BACK_SLASH BACK_SLASH { result = val[1] }
324
+ ;
325
+
326
+ verb_normal_string : OTHER
327
+ | QUOTE
328
+ | BAR
329
+ | SLASH
330
+ | EM_OPEN
331
+ | EM_CLOSE
332
+ | CODE_OPEN
333
+ | CODE_CLOSE
334
+ | VAR_OPEN
335
+ | VAR_CLOSE
336
+ | KBD_OPEN
337
+ | KBD_CLOSE
338
+ | INDEX_OPEN
339
+ | INDEX_CLOSE
340
+ | REF_OPEN
341
+ | REF_CLOSE
342
+ | FOOTNOTE_OPEN
343
+ | FOOTNOTE_CLOSE
344
+ | VERB_OPEN
345
+ | URL
346
+ ;
347
+
348
+ verb_strings : verb_strings verb_string { result << val[1] }
349
+ | verb_string
350
+ ;
351
+
352
+ /* verb_str_ele : verb_strings
353
+ * ;
354
+ */
355
+ end
356
+
357
+ ---- inner
358
+
359
+ # :stopdoc:
360
+
361
+ EM_OPEN = '((*'
362
+ EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
363
+ EM_CLOSE = '*))'
364
+ EM_CLOSE_RE = /\A#{Regexp.quote(EM_CLOSE)}/
365
+ CODE_OPEN = '(({'
366
+ CODE_OPEN_RE = /\A#{Regexp.quote(CODE_OPEN)}/
367
+ CODE_CLOSE = '}))'
368
+ CODE_CLOSE_RE = /\A#{Regexp.quote(CODE_CLOSE)}/
369
+ VAR_OPEN = '((|'
370
+ VAR_OPEN_RE = /\A#{Regexp.quote(VAR_OPEN)}/
371
+ VAR_CLOSE = '|))'
372
+ VAR_CLOSE_RE = /\A#{Regexp.quote(VAR_CLOSE)}/
373
+ KBD_OPEN = '((%'
374
+ KBD_OPEN_RE = /\A#{Regexp.quote(KBD_OPEN)}/
375
+ KBD_CLOSE = '%))'
376
+ KBD_CLOSE_RE = /\A#{Regexp.quote(KBD_CLOSE)}/
377
+ INDEX_OPEN = '((:'
378
+ INDEX_OPEN_RE = /\A#{Regexp.quote(INDEX_OPEN)}/
379
+ INDEX_CLOSE = ':))'
380
+ INDEX_CLOSE_RE = /\A#{Regexp.quote(INDEX_CLOSE)}/
381
+ REF_OPEN = '((<'
382
+ REF_OPEN_RE = /\A#{Regexp.quote(REF_OPEN)}/
383
+ REF_CLOSE = '>))'
384
+ REF_CLOSE_RE = /\A#{Regexp.quote(REF_CLOSE)}/
385
+ FOOTNOTE_OPEN = '((-'
386
+ FOOTNOTE_OPEN_RE = /\A#{Regexp.quote(FOOTNOTE_OPEN)}/
387
+ FOOTNOTE_CLOSE = '-))'
388
+ FOOTNOTE_CLOSE_RE = /\A#{Regexp.quote(FOOTNOTE_CLOSE)}/
389
+ VERB_OPEN = "(('"
390
+ VERB_OPEN_RE = /\A#{Regexp.quote(VERB_OPEN)}/
391
+ VERB_CLOSE = "'))"
392
+ VERB_CLOSE_RE = /\A#{Regexp.quote(VERB_CLOSE)}/
393
+
394
+ BAR = "|"
395
+ BAR_RE = /\A#{Regexp.quote(BAR)}/
396
+ QUOTE = '"'
397
+ QUOTE_RE = /\A#{Regexp.quote(QUOTE)}/
398
+ SLASH = "/"
399
+ SLASH_RE = /\A#{Regexp.quote(SLASH)}/
400
+ BACK_SLASH = "\\"
401
+ BACK_SLASH_RE = /\A#{Regexp.quote(BACK_SLASH)}/
402
+ URL = "URL:"
403
+ URL_RE = /\A#{Regexp.quote(URL)}/
404
+
405
+ other_re_mode = Regexp::EXTENDED
406
+ other_re_mode |= Regexp::MULTILINE
407
+
408
+ OTHER_RE = Regexp.new(
409
+ "\\A.+?(?=#{Regexp.quote(EM_OPEN)}|#{Regexp.quote(EM_CLOSE)}|
410
+ #{Regexp.quote(CODE_OPEN)}|#{Regexp.quote(CODE_CLOSE)}|
411
+ #{Regexp.quote(VAR_OPEN)}|#{Regexp.quote(VAR_CLOSE)}|
412
+ #{Regexp.quote(KBD_OPEN)}|#{Regexp.quote(KBD_CLOSE)}|
413
+ #{Regexp.quote(INDEX_OPEN)}|#{Regexp.quote(INDEX_CLOSE)}|
414
+ #{Regexp.quote(REF_OPEN)}|#{Regexp.quote(REF_CLOSE)}|
415
+ #{Regexp.quote(FOOTNOTE_OPEN)}|#{Regexp.quote(FOOTNOTE_CLOSE)}|
416
+ #{Regexp.quote(VERB_OPEN)}|#{Regexp.quote(VERB_CLOSE)}|
417
+ #{Regexp.quote(BAR)}|
418
+ #{Regexp.quote(QUOTE)}|
419
+ #{Regexp.quote(SLASH)}|
420
+ #{Regexp.quote(BACK_SLASH)}|
421
+ #{Regexp.quote(URL)})", other_re_mode)
422
+
423
+ # :startdoc:
424
+
425
+ ##
426
+ # Creates a new parser for inline markup in the rd format. The +block_parser+
427
+ # is used to for footnotes and labels in the inline text.
428
+
429
+ def initialize block_parser
430
+ @block_parser = block_parser
431
+ end
432
+
433
+ ##
434
+ # Parses the +inline+ text from RD format into RDoc format.
435
+
436
+ def parse inline
437
+ @inline = inline
438
+ @src = StringScanner.new inline
439
+ @pre = "".dup
440
+ @yydebug = true
441
+ do_parse.to_s
442
+ end
443
+
444
+ ##
445
+ # Returns the next token from the inline text
446
+
447
+ def next_token
448
+ return [false, false] if @src.eos?
449
+ # p @src.rest if @yydebug
450
+ if ret = @src.scan(EM_OPEN_RE)
451
+ @pre << ret
452
+ [:EM_OPEN, ret]
453
+ elsif ret = @src.scan(EM_CLOSE_RE)
454
+ @pre << ret
455
+ [:EM_CLOSE, ret]
456
+ elsif ret = @src.scan(CODE_OPEN_RE)
457
+ @pre << ret
458
+ [:CODE_OPEN, ret]
459
+ elsif ret = @src.scan(CODE_CLOSE_RE)
460
+ @pre << ret
461
+ [:CODE_CLOSE, ret]
462
+ elsif ret = @src.scan(VAR_OPEN_RE)
463
+ @pre << ret
464
+ [:VAR_OPEN, ret]
465
+ elsif ret = @src.scan(VAR_CLOSE_RE)
466
+ @pre << ret
467
+ [:VAR_CLOSE, ret]
468
+ elsif ret = @src.scan(KBD_OPEN_RE)
469
+ @pre << ret
470
+ [:KBD_OPEN, ret]
471
+ elsif ret = @src.scan(KBD_CLOSE_RE)
472
+ @pre << ret
473
+ [:KBD_CLOSE, ret]
474
+ elsif ret = @src.scan(INDEX_OPEN_RE)
475
+ @pre << ret
476
+ [:INDEX_OPEN, ret]
477
+ elsif ret = @src.scan(INDEX_CLOSE_RE)
478
+ @pre << ret
479
+ [:INDEX_CLOSE, ret]
480
+ elsif ret = @src.scan(REF_OPEN_RE)
481
+ @pre << ret
482
+ [:REF_OPEN, ret]
483
+ elsif ret = @src.scan(REF_CLOSE_RE)
484
+ @pre << ret
485
+ [:REF_CLOSE, ret]
486
+ elsif ret = @src.scan(FOOTNOTE_OPEN_RE)
487
+ @pre << ret
488
+ [:FOOTNOTE_OPEN, ret]
489
+ elsif ret = @src.scan(FOOTNOTE_CLOSE_RE)
490
+ @pre << ret
491
+ [:FOOTNOTE_CLOSE, ret]
492
+ elsif ret = @src.scan(VERB_OPEN_RE)
493
+ @pre << ret
494
+ [:VERB_OPEN, ret]
495
+ elsif ret = @src.scan(VERB_CLOSE_RE)
496
+ @pre << ret
497
+ [:VERB_CLOSE, ret]
498
+ elsif ret = @src.scan(BAR_RE)
499
+ @pre << ret
500
+ [:BAR, ret]
501
+ elsif ret = @src.scan(QUOTE_RE)
502
+ @pre << ret
503
+ [:QUOTE, ret]
504
+ elsif ret = @src.scan(SLASH_RE)
505
+ @pre << ret
506
+ [:SLASH, ret]
507
+ elsif ret = @src.scan(BACK_SLASH_RE)
508
+ @pre << ret
509
+ [:BACK_SLASH, ret]
510
+ elsif ret = @src.scan(URL_RE)
511
+ @pre << ret
512
+ [:URL, ret]
513
+ elsif ret = @src.scan(OTHER_RE)
514
+ @pre << ret
515
+ [:OTHER, ret]
516
+ else
517
+ ret = @src.rest
518
+ @pre << ret
519
+ @src.terminate
520
+ [:OTHER, ret]
521
+ end
522
+ end
523
+
524
+ ##
525
+ # Raises a ParseError when invalid formatting is found
526
+
527
+ def on_error(et, ev, values)
528
+ lines_of_rest = @src.rest.lines.to_a.length
529
+ prev_words = prev_words_on_error(ev)
530
+ at = 4 + prev_words.length
531
+
532
+ message = <<-MSG
533
+ RD syntax error: line #{@block_parser.line_index - lines_of_rest}:
534
+ ...#{prev_words} #{(ev||'')} #{next_words_on_error()} ...
535
+ MSG
536
+
537
+ message << " " * at + "^" * (ev ? ev.length : 0) + "\n"
538
+ raise ParseError, message
539
+ end
540
+
541
+ ##
542
+ # Returns words before the error
543
+
544
+ def prev_words_on_error(ev)
545
+ pre = @pre
546
+ if ev and /#{Regexp.quote(ev)}$/ =~ pre
547
+ pre = $`
548
+ end
549
+ last_line(pre)
550
+ end
551
+
552
+ ##
553
+ # Returns the last line of +src+
554
+
555
+ def last_line(src)
556
+ if n = src.rindex("\n")
557
+ src[(n+1) .. -1]
558
+ else
559
+ src
560
+ end
561
+ end
562
+ private :last_line
563
+
564
+ ##
565
+ # Returns words following an error
566
+
567
+ def next_words_on_error
568
+ if n = @src.rest.index("\n")
569
+ @src.rest[0 .. (n-1)]
570
+ else
571
+ @src.rest
572
+ end
573
+ end
574
+
575
+ ##
576
+ # Creates a new RDoc::RD::Inline for the +rdoc+ markup and the raw +reference+
577
+
578
+ def inline rdoc, reference = rdoc
579
+ RDoc::RD::Inline.new rdoc, reference
580
+ end
581
+
582
+ # :stopdoc:
583
+ ---- header
584
+ require 'strscan'
585
+
586
+ class RDoc::RD
587
+
588
+ ##
589
+ # RD format parser for inline markup such as emphasis, links, footnotes, etc.
590
+
591
+ ---- footer
592
+ end
593
+
data/lib/rdoc/rd.rb ADDED
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # RDoc::RD implements the RD format from the rdtool gem.
4
+ #
5
+ # To choose RD as your only default format see
6
+ # RDoc::Options@Saved+Options for instructions on setting up a
7
+ # <code>.doc_options</code> file to store your project default.
8
+ #
9
+ # == LICENSE
10
+ #
11
+ # The grammar that produces RDoc::RD::BlockParser and RDoc::RD::InlineParser
12
+ # is included in RDoc under the Ruby License.
13
+ #
14
+ # You can find the original source for rdtool at
15
+ # https://github.com/uwabami/rdtool/
16
+ #
17
+ # You can use, re-distribute or change these files under Ruby's License or GPL.
18
+ #
19
+ # 1. You may make and give away verbatim copies of the source form of the
20
+ # software without restriction, provided that you duplicate all of the
21
+ # original copyright notices and associated disclaimers.
22
+ #
23
+ # 2. You may modify your copy of the software in any way, provided that
24
+ # you do at least ONE of the following:
25
+ #
26
+ # a. place your modifications in the Public Domain or otherwise
27
+ # make them Freely Available, such as by posting said
28
+ # modifications to Usenet or an equivalent medium, or by allowing
29
+ # the author to include your modifications in the software.
30
+ #
31
+ # b. use the modified software only within your corporation or
32
+ # organization.
33
+ #
34
+ # c. give non-standard binaries non-standard names, with
35
+ # instructions on where to get the original software distribution.
36
+ #
37
+ # d. make other distribution arrangements with the author.
38
+ #
39
+ # 3. You may distribute the software in object code or binary form,
40
+ # provided that you do at least ONE of the following:
41
+ #
42
+ # a. distribute the binaries and library files of the software,
43
+ # together with instructions (in the manual page or equivalent)
44
+ # on where to get the original distribution.
45
+ #
46
+ # b. accompany the distribution with the machine-readable source of
47
+ # the software.
48
+ #
49
+ # c. give non-standard binaries non-standard names, with
50
+ # instructions on where to get the original software distribution.
51
+ #
52
+ # d. make other distribution arrangements with the author.
53
+ #
54
+ # 4. You may modify and include the part of the software into any other
55
+ # software (possibly commercial). But some files in the distribution
56
+ # are not written by the author, so that they are not under these terms.
57
+ #
58
+ # For the list of those files and their copying conditions, see the
59
+ # file LEGAL.
60
+ #
61
+ # 5. The scripts and library files supplied as input to or produced as
62
+ # output from the software do not automatically fall under the
63
+ # copyright of the software, but belong to whomever generated them,
64
+ # and may be sold commercially, and may be aggregated with this
65
+ # software.
66
+ #
67
+ # 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
68
+ # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
69
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
70
+ # PURPOSE.
71
+
72
+ class RDoc::RD
73
+
74
+ ##
75
+ # Parses +rd+ source and returns an RDoc::Markup::Document. If the
76
+ # <tt>=begin</tt> or <tt>=end</tt> lines are missing they will be added.
77
+
78
+ def self.parse rd
79
+ rd = rd.lines.to_a
80
+
81
+ if rd.find { |i| /\S/ === i } and !rd.find{|i| /^=begin\b/ === i } then
82
+ rd.unshift("=begin\n").push("=end\n")
83
+ end
84
+
85
+ parser = RDoc::RD::BlockParser.new
86
+ document = parser.parse rd
87
+
88
+ # isn't this always true?
89
+ document.parts.shift if RDoc::Markup::BlankLine === document.parts.first
90
+ document.parts.pop if RDoc::Markup::BlankLine === document.parts.last
91
+
92
+ document
93
+ end
94
+
95
+ autoload :BlockParser, 'rdoc/rd/block_parser'
96
+ autoload :InlineParser, 'rdoc/rd/inline_parser'
97
+ autoload :Inline, 'rdoc/rd/inline'
98
+
99
+ end
100
+