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,42 +0,0 @@
1
- require 'rdoc/test_case'
2
-
3
- class TestRDocTokenStream < RDoc::TestCase
4
-
5
- def test_class_to_html
6
- tokens = [
7
- RDoc::RubyToken::TkCONSTANT. new(0, 0, 0, 'CONSTANT'),
8
- RDoc::RubyToken::TkDEF. new(0, 0, 0, 'KW'),
9
- RDoc::RubyToken::TkIVAR. new(0, 0, 0, 'IVAR'),
10
- RDoc::RubyToken::TkOp. new(0, 0, 0, 'Op'),
11
- RDoc::RubyToken::TkId. new(0, 0, 0, 'Id'),
12
- RDoc::RubyToken::TkNode. new(0, 0, 0, 'Node'),
13
- RDoc::RubyToken::TkCOMMENT. new(0, 0, 0, 'COMMENT'),
14
- RDoc::RubyToken::TkREGEXP. new(0, 0, 0, 'REGEXP'),
15
- RDoc::RubyToken::TkSTRING. new(0, 0, 0, 'STRING'),
16
- RDoc::RubyToken::TkVal. new(0, 0, 0, 'Val'),
17
- RDoc::RubyToken::TkBACKSLASH.new(0, 0, 0, '\\'),
18
- ]
19
-
20
- expected = [
21
- '<span class="ruby-constant">CONSTANT</span>',
22
- '<span class="ruby-keyword">KW</span>',
23
- '<span class="ruby-ivar">IVAR</span>',
24
- '<span class="ruby-operator">Op</span>',
25
- '<span class="ruby-identifier">Id</span>',
26
- '<span class="ruby-node">Node</span>',
27
- '<span class="ruby-comment">COMMENT</span>',
28
- '<span class="ruby-regexp">REGEXP</span>',
29
- '<span class="ruby-string">STRING</span>',
30
- '<span class="ruby-value">Val</span>',
31
- '\\'
32
- ].join
33
-
34
- assert_equal expected, RDoc::TokenStream.to_html(tokens)
35
- end
36
-
37
- def test_class_to_html_empty
38
- assert_equal '', RDoc::TokenStream.to_html([])
39
- end
40
-
41
- end
42
-
@@ -1,520 +0,0 @@
1
- require 'rdoc/test_case'
2
-
3
- class TestRDocTomDoc < RDoc::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @top_level = @store.add_file 'file.rb'
9
-
10
- @TD = RDoc::TomDoc
11
- @td = @TD.new
12
- end
13
-
14
- def test_class_add_post_processor
15
- RDoc::TomDoc.add_post_processor
16
-
17
- pp = RDoc::Markup::PreProcess.new __FILE__, []
18
-
19
- text = "# Public: Do some stuff\n"
20
-
21
- comment = RDoc::Comment.new text, nil
22
- comment.format = 'tomdoc'
23
-
24
- parent = RDoc::Context.new
25
-
26
- pp.handle comment, parent
27
-
28
- method = parent.add_method RDoc::AnyMethod.new(nil, 'm')
29
-
30
- assert_equal 'Public', method.section.title
31
- assert_equal "# Do some stuff\n", comment.text
32
- end
33
-
34
- def test_class_signature
35
- c = comment <<-COMMENT
36
- Signature
37
-
38
- method_<here>(args)
39
-
40
- here - something
41
- COMMENT
42
- c.format = 'tomdoc'
43
-
44
- signature = @TD.signature c
45
-
46
- assert_equal "method_<here>(args)\n", signature
47
- end
48
-
49
- def test_class_signature_no_space
50
- c = comment <<-COMMENT
51
- Signature
52
- method_<here>(args)
53
-
54
- here - something
55
- COMMENT
56
- c.format = 'tomdoc'
57
-
58
- signature = @TD.signature c
59
-
60
- assert_equal "method_<here>(args)\n", signature
61
-
62
- expected =
63
- doc(
64
- head(3, 'Signature'),
65
- list(:NOTE,
66
- item(%w[here],
67
- para('something'))))
68
- expected.file = @top_level
69
-
70
- assert_equal expected, c.parse
71
- end
72
-
73
- def test_class_signature_none
74
- c = comment ''
75
- c.format = 'tomdoc'
76
-
77
- assert_nil @TD.signature c
78
- end
79
-
80
- def test_class_rdoc
81
- c = comment <<-COMMENT
82
- === Signature
83
-
84
- method_<here>(args)
85
-
86
- here - something
87
- COMMENT
88
- c.format = 'rdoc'
89
-
90
- signature = @TD.signature c
91
-
92
- assert_nil signature
93
- end
94
-
95
- def test_class_signature_two_space
96
- c = comment <<-COMMENT
97
- Signature
98
-
99
-
100
- method_<here>(args)
101
-
102
- here - something
103
- COMMENT
104
- c.format = 'tomdoc'
105
-
106
- signature = @TD.signature c
107
-
108
- assert_equal "method_<here>(args)\n", signature
109
-
110
- expected =
111
- doc(
112
- head(3, 'Signature'),
113
- list(:NOTE,
114
- item(%w[here],
115
- para('something'))))
116
- expected.file = @top_level
117
-
118
- assert_equal expected, c.parse
119
- end
120
-
121
- def test_parse_paragraph
122
- text = "Public: Do some stuff\n"
123
-
124
- expected =
125
- @RM::Document.new(
126
- @RM::Paragraph.new('Do some stuff'))
127
-
128
- assert_equal expected, @TD.parse(text)
129
- end
130
-
131
- def test_parse_multiline_paragraph
132
- text = "Public: Do some stuff\n"
133
- text << "On a new line\n"
134
-
135
- expected =
136
- doc(
137
- para('Do some stuff', ' ', 'On a new line'))
138
-
139
- assert_equal expected, @TD.parse(text)
140
- end
141
-
142
- def test_parse_arguments
143
- text = <<-TEXT
144
- Create new Arg object.
145
-
146
- name - name of argument
147
- description - arguments description
148
- TEXT
149
-
150
- expected =
151
- doc(
152
- para('Create new Arg object.'),
153
- blank_line,
154
- list(:NOTE,
155
- item(%w[name],
156
- para('name of argument')),
157
- item(%w[description],
158
- para('arguments description'))))
159
-
160
- assert_equal expected, @TD.parse(text)
161
- end
162
-
163
- def test_parse_arguments_array
164
- text = <<-TEXT
165
- Create new Arg object.
166
-
167
- names[] - names of arguments
168
- TEXT
169
-
170
- expected =
171
- doc(
172
- para('Create new Arg object.'),
173
- blank_line,
174
- list(:NOTE,
175
- item(%w[names[]],
176
- para('names of arguments'))))
177
-
178
- assert_equal expected, @TD.parse(text)
179
- end
180
-
181
- def test_parse_arguments_multiline
182
- text = <<-TEXT
183
- Do some stuff
184
-
185
- foo - A comment goes here
186
- and is more than one line
187
- TEXT
188
-
189
- expected =
190
- doc(
191
- para('Do some stuff'),
192
- blank_line,
193
- list(:NOTE,
194
- item(%w[foo],
195
- para('A comment goes here', ' ', 'and is more than one line'))))
196
-
197
- assert_equal expected, @TD.parse(text)
198
- end
199
-
200
- def test_parse_arguments_nested
201
- text = <<-TEXT
202
- Do some stuff
203
-
204
- foo - A comment goes here
205
- :bar - bar documentation
206
- TEXT
207
-
208
- expected =
209
- doc(
210
- para('Do some stuff'),
211
- blank_line,
212
- list(:NOTE,
213
- item(%w[foo],
214
- para('A comment goes here'),
215
- list(:NOTE,
216
- item(%w[:bar],
217
- para('bar documentation'))))))
218
-
219
- assert_equal expected, @TD.parse(text)
220
- end
221
-
222
- def test_parse_examples
223
- text = <<-TEXT
224
- Do some stuff
225
-
226
- Examples
227
-
228
- 1 + 1
229
- TEXT
230
-
231
- code = verb("1 + 1\n")
232
- code.format = :ruby
233
-
234
- expected =
235
- doc(
236
- para('Do some stuff'),
237
- blank_line,
238
- head(3, 'Examples'),
239
- blank_line,
240
- code)
241
-
242
- document = @TD.parse(text)
243
- assert_equal expected, document
244
- assert document.parts.last.ruby?
245
- end
246
-
247
- def test_parse_examples_signature
248
- text = <<-TEXT
249
- Do some stuff
250
-
251
- Examples
252
-
253
- 1 + 1
254
-
255
- Signature
256
-
257
- foo(args)
258
- TEXT
259
-
260
- code1 = verb("1 + 1\n")
261
- code1.format = :ruby
262
-
263
- code2 = verb("foo(args)\n")
264
-
265
- expected =
266
- doc(
267
- para('Do some stuff'),
268
- blank_line,
269
- head(3, 'Examples'),
270
- blank_line,
271
- code1,
272
- head(3, 'Signature'),
273
- blank_line,
274
- code2)
275
-
276
- document = @TD.parse text
277
-
278
- assert_equal expected, document
279
- end
280
-
281
- def test_parse_returns
282
- text = <<-TEXT
283
- Do some stuff
284
-
285
- Returns a thing
286
-
287
- Returns another thing
288
- TEXT
289
-
290
- expected =
291
- doc(
292
- para('Do some stuff'),
293
- blank_line,
294
- head(3, 'Returns'),
295
- blank_line,
296
- para('Returns a thing'),
297
- blank_line,
298
- para('Returns another thing'))
299
-
300
- assert_equal expected, @TD.parse(text)
301
- end
302
-
303
- def test_parse_returns_multiline
304
- text = <<-TEXT
305
- Do some stuff
306
-
307
- Returns a thing
308
- that is multiline
309
- TEXT
310
-
311
- expected =
312
- doc(
313
- para('Do some stuff'),
314
- blank_line,
315
- head(3, 'Returns'),
316
- blank_line,
317
- para('Returns a thing', ' ', 'that is multiline'))
318
-
319
- assert_equal expected, @TD.parse(text)
320
- end
321
-
322
- def test_parse_signature
323
- text = <<-TEXT
324
- Do some stuff
325
-
326
- Signature
327
-
328
- some_method(args)
329
- TEXT
330
-
331
- expected =
332
- @RM::Document.new(
333
- @RM::Paragraph.new('Do some stuff'),
334
- @RM::BlankLine.new,
335
- @RM::Heading.new(3, 'Signature'),
336
- @RM::BlankLine.new,
337
- @RM::Verbatim.new("some_method(args)\n"))
338
-
339
- assert_equal expected, @TD.parse(text)
340
- end
341
-
342
- def test_tokenize_paragraph
343
- @td.tokenize "Public: Do some stuff\n"
344
-
345
- expected = [
346
- [:TEXT, "Do some stuff", 0, 0],
347
- [:NEWLINE, "\n", 13, 0],
348
- ]
349
-
350
- assert_equal expected, @td.tokens
351
- end
352
-
353
- def test_tokenize_multiline_paragraph
354
- text = "Public: Do some stuff\n"
355
- text << "On a new line\n"
356
-
357
- @td.tokenize text
358
-
359
- expected = [
360
- [:TEXT, "Do some stuff", 0, 0],
361
- [:NEWLINE, "\n", 13, 0],
362
- [:TEXT, "On a new line", 0, 1],
363
- [:NEWLINE, "\n", 13, 1]
364
- ]
365
-
366
- assert_equal expected, @td.tokens
367
- end
368
-
369
- def test_tokenize_arguments
370
- @td.tokenize <<-TEXT
371
- Create new Arg object.
372
-
373
- name - name of argument
374
- description - arguments description
375
- TEXT
376
-
377
- expected = [
378
- [:TEXT, "Create new Arg object.", 0, 0],
379
- [:NEWLINE, "\n", 22, 0],
380
- [:NEWLINE, "\n", 0, 1],
381
- [:NOTE, "name", 0, 2],
382
- [:TEXT, "name of argument", 14, 2],
383
- [:NEWLINE, "\n", 30, 2],
384
- [:NOTE, "description", 0, 3],
385
- [:TEXT, "arguments description", 14, 3],
386
- [:NEWLINE, "\n", 35, 3],
387
- ]
388
-
389
- assert_equal expected, @td.tokens
390
- end
391
-
392
- def test_tokenize_arguments_array
393
- @td.tokenize <<-TEXT
394
- Create new Arg object.
395
-
396
- names[stuff] - names of arguments
397
- TEXT
398
-
399
- expected = [
400
- [:TEXT, "Create new Arg object.", 0, 0],
401
- [:NEWLINE, "\n", 22, 0],
402
- [:NEWLINE, "\n", 0, 1],
403
- [:NOTE, "names[stuff]", 0, 2],
404
- [:TEXT, "names of arguments", 15, 2],
405
- [:NEWLINE, "\n", 33, 2],
406
- ]
407
-
408
- assert_equal expected, @td.tokens
409
- end
410
-
411
- def test_tokenize_arguments_multiline
412
- @td.tokenize <<-TEXT
413
- Do some stuff
414
-
415
- foo - A comment goes here
416
- and is more than one line
417
- TEXT
418
-
419
- expected = [
420
- [:TEXT, "Do some stuff", 0, 0],
421
- [:NEWLINE, "\n", 13, 0],
422
- [:NEWLINE, "\n", 0, 1],
423
- [:NOTE, "foo", 0, 2],
424
- [:TEXT, "A comment goes here", 6, 2],
425
- [:NEWLINE, "\n", 25, 2],
426
- [:TEXT, "and is more than one line", 2, 3],
427
- [:NEWLINE, "\n", 27, 3],
428
- ]
429
-
430
- assert_equal expected, @td.tokens
431
- end
432
-
433
- def test_tokenize_arguments_nested
434
- @td.tokenize <<-TEXT
435
- Do some stuff
436
-
437
- foo - A comment goes here
438
- :bar - bar documentation
439
- TEXT
440
-
441
- expected = [
442
- [:TEXT, "Do some stuff", 0, 0],
443
- [:NEWLINE, "\n", 13, 0],
444
- [:NEWLINE, "\n", 0, 1],
445
- [:NOTE, "foo", 0, 2],
446
- [:TEXT, "A comment goes here", 6, 2],
447
- [:NEWLINE, "\n", 25, 2],
448
- [:NOTE, ":bar", 6, 3],
449
- [:TEXT, "bar documentation", 13, 3],
450
- [:NEWLINE, "\n", 30, 3],
451
- ]
452
-
453
- assert_equal expected, @td.tokens
454
- end
455
-
456
- def test_tokenize_examples
457
- @td.tokenize <<-TEXT
458
- Do some stuff
459
-
460
- Examples
461
-
462
- 1 + 1
463
- TEXT
464
-
465
- expected = [
466
- [:TEXT, "Do some stuff", 0, 0],
467
- [:NEWLINE, "\n", 13, 0],
468
- [:NEWLINE, "\n", 0, 1],
469
- [:HEADER, 3, 0, 2],
470
- [:TEXT, "Examples", 0, 2],
471
- [:NEWLINE, "\n", 8, 2],
472
- [:NEWLINE, "\n", 0, 3],
473
- [:TEXT, "1 + 1", 2, 4],
474
- [:NEWLINE, "\n", 7, 4],
475
- ]
476
-
477
- assert_equal expected, @td.tokens
478
- end
479
-
480
- def test_tokenize_returns
481
- @td.tokenize <<-TEXT
482
- Do some stuff
483
-
484
- Returns a thing
485
- TEXT
486
-
487
- expected = [
488
- [:TEXT, "Do some stuff", 0, 0],
489
- [:NEWLINE, "\n", 13, 0],
490
- [:NEWLINE, "\n", 0, 1],
491
- [:TEXT, "Returns a thing", 0, 2],
492
- [:NEWLINE, "\n", 15, 2],
493
- ]
494
-
495
- assert_equal expected, @td.tokens
496
- end
497
-
498
- def test_tokenize_returns_multiline
499
- @td.tokenize <<-TEXT
500
- Do some stuff
501
-
502
- Returns a thing
503
- that is multiline
504
- TEXT
505
-
506
- expected = [
507
- [:TEXT, "Do some stuff", 0, 0],
508
- [:NEWLINE, "\n", 13, 0],
509
- [:NEWLINE, "\n", 0, 1],
510
- [:TEXT, "Returns a thing", 0, 2],
511
- [:NEWLINE, "\n", 15, 2],
512
- [:TEXT, "that is multiline", 2, 3],
513
- [:NEWLINE, "\n", 19, 3],
514
- ]
515
-
516
- assert_equal expected, @td.tokens
517
- end
518
-
519
- end
520
-