gitlab-rdoc 6.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) 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 +133 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +101 -0
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/exe/rdoc +44 -0
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +112 -0
  19. data/lib/rdoc/anon_class.rb +11 -0
  20. data/lib/rdoc/any_method.rb +361 -0
  21. data/lib/rdoc/attr.rb +176 -0
  22. data/lib/rdoc/class_module.rb +802 -0
  23. data/lib/rdoc/code_object.rb +421 -0
  24. data/lib/rdoc/code_objects.rb +6 -0
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +187 -0
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +1266 -0
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +136 -0
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +42 -0
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +790 -0
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +160 -0
  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 +31 -0
  42. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  44. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  58. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  59. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  72. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  73. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  74. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  75. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  76. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  77. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  78. data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  79. data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  80. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  81. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  82. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  83. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  84. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  85. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  86. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  87. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  88. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  89. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  90. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  91. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  92. data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
  93. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
  94. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  95. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  96. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  97. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  98. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  99. data/lib/rdoc/generator/template/json_index/.document +1 -0
  100. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  101. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  102. data/lib/rdoc/generator.rb +51 -0
  103. data/lib/rdoc/ghost_method.rb +7 -0
  104. data/lib/rdoc/i18n/locale.rb +102 -0
  105. data/lib/rdoc/i18n/text.rb +126 -0
  106. data/lib/rdoc/i18n.rb +10 -0
  107. data/lib/rdoc/include.rb +10 -0
  108. data/lib/rdoc/known_classes.rb +73 -0
  109. data/lib/rdoc/markdown/entities.rb +2132 -0
  110. data/lib/rdoc/markdown/literals.kpeg +23 -0
  111. data/lib/rdoc/markdown/literals.rb +417 -0
  112. data/lib/rdoc/markdown.kpeg +1237 -0
  113. data/lib/rdoc/markdown.rb +16685 -0
  114. data/lib/rdoc/markup/attr_changer.rb +23 -0
  115. data/lib/rdoc/markup/attr_span.rb +36 -0
  116. data/lib/rdoc/markup/attribute_manager.rb +409 -0
  117. data/lib/rdoc/markup/attributes.rb +71 -0
  118. data/lib/rdoc/markup/blank_line.rb +28 -0
  119. data/lib/rdoc/markup/block_quote.rb +15 -0
  120. data/lib/rdoc/markup/document.rb +165 -0
  121. data/lib/rdoc/markup/formatter.rb +266 -0
  122. data/lib/rdoc/markup/hard_break.rb +32 -0
  123. data/lib/rdoc/markup/heading.rb +79 -0
  124. data/lib/rdoc/markup/include.rb +43 -0
  125. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  126. data/lib/rdoc/markup/list.rb +102 -0
  127. data/lib/rdoc/markup/list_item.rb +100 -0
  128. data/lib/rdoc/markup/paragraph.rb +29 -0
  129. data/lib/rdoc/markup/parser.rb +575 -0
  130. data/lib/rdoc/markup/pre_process.rb +296 -0
  131. data/lib/rdoc/markup/raw.rb +70 -0
  132. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  133. data/lib/rdoc/markup/rule.rb +21 -0
  134. data/lib/rdoc/markup/table.rb +47 -0
  135. data/lib/rdoc/markup/to_ansi.rb +94 -0
  136. data/lib/rdoc/markup/to_bs.rb +77 -0
  137. data/lib/rdoc/markup/to_html.rb +444 -0
  138. data/lib/rdoc/markup/to_html_crossref.rb +176 -0
  139. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  140. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  141. data/lib/rdoc/markup/to_label.rb +75 -0
  142. data/lib/rdoc/markup/to_markdown.rb +192 -0
  143. data/lib/rdoc/markup/to_rdoc.rb +362 -0
  144. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  145. data/lib/rdoc/markup/to_test.rb +70 -0
  146. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  147. data/lib/rdoc/markup/verbatim.rb +84 -0
  148. data/lib/rdoc/markup.rb +867 -0
  149. data/lib/rdoc/meta_method.rb +7 -0
  150. data/lib/rdoc/method_attr.rb +419 -0
  151. data/lib/rdoc/mixin.rb +121 -0
  152. data/lib/rdoc/normal_class.rb +93 -0
  153. data/lib/rdoc/normal_module.rb +74 -0
  154. data/lib/rdoc/options.rb +1285 -0
  155. data/lib/rdoc/parser/c.rb +1225 -0
  156. data/lib/rdoc/parser/changelog.rb +335 -0
  157. data/lib/rdoc/parser/markdown.rb +24 -0
  158. data/lib/rdoc/parser/rd.rb +23 -0
  159. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  160. data/lib/rdoc/parser/ruby.rb +2327 -0
  161. data/lib/rdoc/parser/ruby_tools.rb +167 -0
  162. data/lib/rdoc/parser/simple.rb +61 -0
  163. data/lib/rdoc/parser/text.rb +12 -0
  164. data/lib/rdoc/parser.rb +277 -0
  165. data/lib/rdoc/rd/block_parser.rb +1056 -0
  166. data/lib/rdoc/rd/block_parser.ry +639 -0
  167. data/lib/rdoc/rd/inline.rb +72 -0
  168. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  169. data/lib/rdoc/rd/inline_parser.ry +593 -0
  170. data/lib/rdoc/rd.rb +100 -0
  171. data/lib/rdoc/rdoc.rb +579 -0
  172. data/lib/rdoc/require.rb +52 -0
  173. data/lib/rdoc/ri/driver.rb +1572 -0
  174. data/lib/rdoc/ri/formatter.rb +6 -0
  175. data/lib/rdoc/ri/paths.rb +171 -0
  176. data/lib/rdoc/ri/store.rb +7 -0
  177. data/lib/rdoc/ri/task.rb +71 -0
  178. data/lib/rdoc/ri.rb +21 -0
  179. data/lib/rdoc/rubygems_hook.rb +246 -0
  180. data/lib/rdoc/servlet.rb +451 -0
  181. data/lib/rdoc/single_class.rb +26 -0
  182. data/lib/rdoc/stats/normal.rb +58 -0
  183. data/lib/rdoc/stats/quiet.rb +60 -0
  184. data/lib/rdoc/stats/verbose.rb +46 -0
  185. data/lib/rdoc/stats.rb +462 -0
  186. data/lib/rdoc/store.rb +979 -0
  187. data/lib/rdoc/task.rb +329 -0
  188. data/lib/rdoc/text.rb +304 -0
  189. data/lib/rdoc/token_stream.rb +119 -0
  190. data/lib/rdoc/tom_doc.rb +263 -0
  191. data/lib/rdoc/top_level.rb +289 -0
  192. data/lib/rdoc/version.rb +8 -0
  193. data/lib/rdoc.rb +201 -0
  194. data/man/ri.1 +247 -0
  195. data/rdoc.gemspec +249 -0
  196. metadata +279 -0
@@ -0,0 +1,296 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Handle common directives that can occur in a block of text:
4
+ #
5
+ # \:include: filename
6
+ #
7
+ # Directives can be escaped by preceding them with a backslash.
8
+ #
9
+ # RDoc plugin authors can register additional directives to be handled by
10
+ # using RDoc::Markup::PreProcess::register.
11
+ #
12
+ # Any directive that is not built-in to RDoc (including those registered via
13
+ # plugins) will be stored in the metadata hash on the CodeObject the comment
14
+ # is attached to. See RDoc::Markup@Directives for the list of built-in
15
+ # directives.
16
+
17
+ class RDoc::Markup::PreProcess
18
+
19
+ ##
20
+ # An RDoc::Options instance that will be filled in with overrides from
21
+ # directives
22
+
23
+ attr_accessor :options
24
+
25
+ ##
26
+ # Adds a post-process handler for directives. The handler will be called
27
+ # with the result RDoc::Comment (or text String) and the code object for the
28
+ # comment (if any).
29
+
30
+ def self.post_process &block
31
+ @post_processors << block
32
+ end
33
+
34
+ ##
35
+ # Registered post-processors
36
+
37
+ def self.post_processors
38
+ @post_processors
39
+ end
40
+
41
+ ##
42
+ # Registers +directive+ as one handled by RDoc. If a block is given the
43
+ # directive will be replaced by the result of the block, otherwise the
44
+ # directive will be removed from the processed text.
45
+ #
46
+ # The block will be called with the directive name and the directive
47
+ # parameter:
48
+ #
49
+ # RDoc::Markup::PreProcess.register 'my-directive' do |directive, param|
50
+ # # replace text, etc.
51
+ # end
52
+
53
+ def self.register directive, &block
54
+ @registered[directive] = block
55
+ end
56
+
57
+ ##
58
+ # Registered directives
59
+
60
+ def self.registered
61
+ @registered
62
+ end
63
+
64
+ ##
65
+ # Clears all registered directives and post-processors
66
+
67
+ def self.reset
68
+ @post_processors = []
69
+ @registered = {}
70
+ end
71
+
72
+ reset
73
+
74
+ ##
75
+ # Creates a new pre-processor for +input_file_name+ that will look for
76
+ # included files in +include_path+
77
+
78
+ def initialize(input_file_name, include_path)
79
+ @input_file_name = input_file_name
80
+ @include_path = include_path
81
+ @options = nil
82
+ end
83
+
84
+ ##
85
+ # Look for directives in the given +text+.
86
+ #
87
+ # Options that we don't handle are yielded. If the block returns false the
88
+ # directive is restored to the text. If the block returns nil or no block
89
+ # was given the directive is handled according to the registered directives.
90
+ # If a String was returned the directive is replaced with the string.
91
+ #
92
+ # If no matching directive was registered the directive is restored to the
93
+ # text.
94
+ #
95
+ # If +code_object+ is given and the directive is unknown then the
96
+ # directive's parameter is set as metadata on the +code_object+. See
97
+ # RDoc::CodeObject#metadata for details.
98
+
99
+ def handle text, code_object = nil, &block
100
+ if RDoc::Comment === text then
101
+ comment = text
102
+ text = text.text
103
+ end
104
+
105
+ # regexp helper (square brackets for optional)
106
+ # $1 $2 $3 $4 $5
107
+ # [prefix][\]:directive:[spaces][param]newline
108
+ text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
109
+ # skip something like ':toto::'
110
+ next $& if $4.empty? and $5 and $5[0, 1] == ':'
111
+
112
+ # skip if escaped
113
+ next "#$1:#$3:#$4#$5\n" unless $2.empty?
114
+
115
+ # This is not in handle_directive because I didn't want to pass another
116
+ # argument into it
117
+ if comment and $3 == 'markup' then
118
+ next "#{$1.strip}\n" unless $5
119
+ comment.format = $5.downcase
120
+ next "#{$1.strip}\n"
121
+ end
122
+
123
+ handle_directive $1, $3, $5, code_object, text.encoding, &block
124
+ end
125
+
126
+ if comment then
127
+ comment.text = text
128
+ else
129
+ comment = text
130
+ end
131
+
132
+ self.class.post_processors.each do |handler|
133
+ handler.call comment, code_object
134
+ end
135
+
136
+ text
137
+ end
138
+
139
+ ##
140
+ # Performs the actions described by +directive+ and its parameter +param+.
141
+ #
142
+ # +code_object+ is used for directives that operate on a class or module.
143
+ # +prefix+ is used to ensure the replacement for handled directives is
144
+ # correct. +encoding+ is used for the <tt>include</tt> directive.
145
+ #
146
+ # For a list of directives in RDoc see RDoc::Markup.
147
+ #--
148
+ # When 1.8.7 support is ditched prefix can be defaulted to ''
149
+
150
+ def handle_directive prefix, directive, param, code_object = nil,
151
+ encoding = nil
152
+ blankline = "#{prefix.strip}\n"
153
+ directive = directive.downcase
154
+
155
+ case directive
156
+ when 'arg', 'args' then
157
+ return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc::AnyMethod)
158
+
159
+ code_object.params = param
160
+
161
+ blankline
162
+ when 'category' then
163
+ if RDoc::Context === code_object then
164
+ section = code_object.add_section param
165
+ code_object.temporary_section = section
166
+ end
167
+
168
+ blankline # ignore category if we're not on an RDoc::Context
169
+ when 'doc' then
170
+ return blankline unless code_object
171
+ code_object.document_self = true
172
+ code_object.force_documentation = true
173
+
174
+ blankline
175
+ when 'enddoc' then
176
+ return blankline unless code_object
177
+ code_object.done_documenting = true
178
+
179
+ blankline
180
+ when 'include' then
181
+ filename = param.split(' ', 2).first
182
+ include_file filename, prefix, encoding
183
+ when 'main' then
184
+ @options.main_page = param if @options.respond_to? :main_page
185
+
186
+ blankline
187
+ when 'nodoc' then
188
+ return blankline unless code_object
189
+ code_object.document_self = nil # notify nodoc
190
+ code_object.document_children = param !~ /all/i
191
+
192
+ blankline
193
+ when 'notnew', 'not_new', 'not-new' then
194
+ return blankline unless RDoc::AnyMethod === code_object
195
+
196
+ code_object.dont_rename_initialize = true
197
+
198
+ blankline
199
+ when 'startdoc' then
200
+ return blankline unless code_object
201
+
202
+ code_object.start_doc
203
+ code_object.force_documentation = true
204
+
205
+ blankline
206
+ when 'stopdoc' then
207
+ return blankline unless code_object
208
+
209
+ code_object.stop_doc
210
+
211
+ blankline
212
+ when 'title' then
213
+ @options.default_title = param if @options.respond_to? :default_title=
214
+
215
+ blankline
216
+ when 'yield', 'yields' then
217
+ return blankline unless code_object
218
+ # remove parameter &block
219
+ code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
220
+
221
+ code_object.block_params = param
222
+
223
+ blankline
224
+ else
225
+ result = yield directive, param if block_given?
226
+
227
+ case result
228
+ when nil then
229
+ code_object.metadata[directive] = param if code_object
230
+
231
+ if RDoc::Markup::PreProcess.registered.include? directive then
232
+ handler = RDoc::Markup::PreProcess.registered[directive]
233
+ result = handler.call directive, param if handler
234
+ else
235
+ result = "#{prefix}:#{directive}: #{param}\n"
236
+ end
237
+ when false then
238
+ result = "#{prefix}:#{directive}: #{param}\n"
239
+ end
240
+
241
+ result
242
+ end
243
+ end
244
+
245
+ ##
246
+ # Handles the <tt>:include: _filename_</tt> directive.
247
+ #
248
+ # If the first line of the included file starts with '#', and contains
249
+ # an encoding information in the form 'coding:' or 'coding=', it is
250
+ # removed.
251
+ #
252
+ # If all lines in the included file start with a '#', this leading '#'
253
+ # is removed before inclusion. The included content is indented like
254
+ # the <tt>:include:</tt> directive.
255
+ #--
256
+ # so all content will be verbatim because of the likely space after '#'?
257
+ # TODO shift left the whole file content in that case
258
+ # TODO comment stop/start #-- and #++ in included file must be processed here
259
+
260
+ def include_file name, indent, encoding
261
+ full_name = find_include_file name
262
+
263
+ unless full_name then
264
+ warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
265
+ return ''
266
+ end
267
+
268
+ content = RDoc::Encoding.read_file full_name, encoding, true
269
+ content = RDoc::Encoding.remove_magic_comment content
270
+
271
+ # strip magic comment
272
+ content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
273
+
274
+ # strip leading '#'s, but only if all lines start with them
275
+ if content =~ /^[^#]/ then
276
+ content.gsub(/^/, indent)
277
+ else
278
+ content.gsub(/^#?/, indent)
279
+ end
280
+ end
281
+
282
+ ##
283
+ # Look for the given file in the directory containing the current file,
284
+ # and then in each of the directories specified in the RDOC_INCLUDE path
285
+
286
+ def find_include_file(name)
287
+ to_search = [File.dirname(@input_file_name)].concat @include_path
288
+ to_search.each do |dir|
289
+ full_name = File.join(dir, name)
290
+ stat = File.stat(full_name) rescue next
291
+ return full_name if stat.readable?
292
+ end
293
+ nil
294
+ end
295
+
296
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A section of text that is added to the output document as-is
4
+
5
+ class RDoc::Markup::Raw
6
+
7
+ ##
8
+ # The component parts of the list
9
+
10
+ attr_reader :parts
11
+
12
+ ##
13
+ # Creates a new Raw containing +parts+
14
+
15
+ def initialize *parts
16
+ @parts = []
17
+ @parts.concat parts
18
+ end
19
+
20
+ ##
21
+ # Appends +text+
22
+
23
+ def << text
24
+ @parts << text
25
+ end
26
+
27
+ def == other # :nodoc:
28
+ self.class == other.class and @parts == other.parts
29
+ end
30
+
31
+ ##
32
+ # Calls #accept_raw+ on +visitor+
33
+
34
+ def accept visitor
35
+ visitor.accept_raw self
36
+ end
37
+
38
+ ##
39
+ # Appends +other+'s parts
40
+
41
+ def merge other
42
+ @parts.concat other.parts
43
+ end
44
+
45
+ def pretty_print q # :nodoc:
46
+ self.class.name =~ /.*::(\w{1,4})/i
47
+
48
+ q.group 2, "[#{$1.downcase}: ", ']' do
49
+ q.seplist @parts do |part|
50
+ q.pp part
51
+ end
52
+ end
53
+ end
54
+
55
+ ##
56
+ # Appends +texts+ onto this Paragraph
57
+
58
+ def push *texts
59
+ self.parts.concat texts
60
+ end
61
+
62
+ ##
63
+ # The raw text
64
+
65
+ def text
66
+ @parts.join ' '
67
+ end
68
+
69
+ end
70
+
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Hold details of a regexp handling sequence
4
+
5
+ class RDoc::Markup::RegexpHandling
6
+
7
+ ##
8
+ # Regexp handling type
9
+
10
+ attr_reader :type
11
+
12
+ ##
13
+ # Regexp handling text
14
+
15
+ attr_accessor :text
16
+
17
+ ##
18
+ # Creates a new regexp handling sequence of +type+ with +text+
19
+
20
+ def initialize(type, text)
21
+ @type, @text = type, text
22
+ end
23
+
24
+ ##
25
+ # Regexp handlings are equal when the have the same text and type
26
+
27
+ def ==(o)
28
+ self.text == o.text && self.type == o.type
29
+ end
30
+
31
+ def inspect # :nodoc:
32
+ "#<RDoc::Markup::RegexpHandling:0x%x @type=%p, @text=%p>" % [
33
+ object_id, @type, text.dump]
34
+ end
35
+
36
+ def to_s # :nodoc:
37
+ "RegexpHandling: type=#{type} text=#{text.dump}"
38
+ end
39
+
40
+ end
41
+
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A horizontal rule with a weight
4
+
5
+ class RDoc::Markup::Rule < Struct.new :weight
6
+
7
+ ##
8
+ # Calls #accept_rule on +visitor+
9
+
10
+ def accept visitor
11
+ visitor.accept_rule self
12
+ end
13
+
14
+ def pretty_print q # :nodoc:
15
+ q.group 2, '[rule:', ']' do
16
+ q.pp weight
17
+ end
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A section of table
4
+
5
+ class RDoc::Markup::Table
6
+ attr_accessor :header, :align, :body
7
+
8
+ def initialize header, align, body
9
+ @header, @align, @body = header, align, body
10
+ end
11
+
12
+ def == other
13
+ self.class == other.class and
14
+ @header == other.header and
15
+ @align == other.align and
16
+ @body == other.body
17
+ end
18
+
19
+ def accept visitor
20
+ visitor.accept_table @header, @body, @align
21
+ end
22
+
23
+ def pretty_print q # :nodoc:
24
+ q.group 2, '[Table: ', ']' do
25
+ q.group 2, '[Head: ', ']' do
26
+ q.seplist @header.zip(@align) do |text, align|
27
+ q.pp text
28
+ if align
29
+ q.text ":"
30
+ q.breakable
31
+ q.text align.to_s
32
+ end
33
+ end
34
+ end
35
+ q.breakable
36
+ q.group 2, '[Body: ', ']' do
37
+ q.seplist @body do |body|
38
+ q.group 2, '[', ']' do
39
+ q.seplist body do |text|
40
+ q.pp text
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end