rdoc 6.1.2 → 6.3.2

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.rdoc +0 -1
  4. data/Rakefile +28 -18
  5. data/lib/rdoc.rb +21 -0
  6. data/lib/rdoc/any_method.rb +52 -7
  7. data/lib/rdoc/class_module.rb +1 -1
  8. data/lib/rdoc/comment.rb +12 -1
  9. data/lib/rdoc/context.rb +10 -2
  10. data/lib/rdoc/context/section.rb +0 -13
  11. data/lib/rdoc/cross_reference.rb +4 -4
  12. data/lib/rdoc/erb_partial.rb +1 -1
  13. data/lib/rdoc/erbio.rb +2 -2
  14. data/lib/rdoc/generator/darkfish.rb +9 -9
  15. data/lib/rdoc/generator/pot.rb +3 -3
  16. data/lib/rdoc/generator/template/darkfish/_head.rhtml +4 -5
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  22. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  23. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  28. data/lib/rdoc/generator/template/darkfish/class.rhtml +44 -44
  29. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +33 -5
  30. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  31. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -1
  32. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  33. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  34. data/lib/rdoc/i18n.rb +1 -1
  35. data/lib/rdoc/markdown.kpeg +20 -2
  36. data/lib/rdoc/markdown.rb +16685 -0
  37. data/lib/rdoc/markdown/literals.rb +417 -0
  38. data/lib/rdoc/markup.rb +1 -2
  39. data/lib/rdoc/markup/attr_span.rb +8 -2
  40. data/lib/rdoc/markup/attribute_manager.rb +93 -28
  41. data/lib/rdoc/markup/formatter.rb +1 -1
  42. data/lib/rdoc/markup/parser.rb +58 -42
  43. data/lib/rdoc/markup/pre_process.rb +1 -1
  44. data/lib/rdoc/markup/table.rb +47 -0
  45. data/lib/rdoc/markup/to_html.rb +46 -6
  46. data/lib/rdoc/markup/to_html_crossref.rb +18 -6
  47. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
  48. data/lib/rdoc/markup/to_rdoc.rb +28 -0
  49. data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
  50. data/lib/rdoc/options.rb +56 -6
  51. data/lib/rdoc/parser.rb +7 -7
  52. data/lib/rdoc/parser/c.rb +139 -183
  53. data/lib/rdoc/parser/changelog.rb +145 -14
  54. data/lib/rdoc/parser/ripper_state_lex.rb +2 -1
  55. data/lib/rdoc/parser/ruby.rb +18 -8
  56. data/lib/rdoc/rd/block_parser.rb +1056 -0
  57. data/lib/rdoc/rd/inline_parser.rb +1207 -0
  58. data/lib/rdoc/rdoc.rb +35 -22
  59. data/lib/rdoc/ri/driver.rb +9 -5
  60. data/lib/rdoc/ri/paths.rb +3 -17
  61. data/lib/rdoc/ri/task.rb +1 -1
  62. data/lib/rdoc/rubygems_hook.rb +2 -2
  63. data/lib/rdoc/servlet.rb +16 -8
  64. data/lib/rdoc/store.rb +6 -14
  65. data/lib/rdoc/task.rb +1 -1
  66. data/lib/rdoc/text.rb +8 -2
  67. data/lib/rdoc/token_stream.rb +8 -3
  68. data/lib/rdoc/tom_doc.rb +6 -7
  69. data/lib/rdoc/version.rb +1 -1
  70. data/man/ri.1 +247 -0
  71. data/rdoc.gemspec +196 -9
  72. metadata +10 -70
  73. data/.document +0 -5
  74. data/.gitignore +0 -14
  75. data/.travis.yml +0 -21
  76. data/appveyor.yml +0 -36
  77. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  78. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
@@ -0,0 +1,417 @@
1
+ # coding: UTF-8
2
+ # frozen_string_literal: true
3
+ # :markup: markdown
4
+
5
+ ##
6
+ #--
7
+ # This set of literals is for Ruby 1.9 regular expressions and gives full
8
+ # unicode support.
9
+ #
10
+ # Unlike peg-markdown, this set of literals recognizes Unicode alphanumeric
11
+ # characters, newlines and spaces.
12
+ class RDoc::Markdown::Literals
13
+ # :stopdoc:
14
+
15
+ # This is distinct from setup_parser so that a standalone parser
16
+ # can redefine #initialize and still have access to the proper
17
+ # parser setup code.
18
+ def initialize(str, debug=false)
19
+ setup_parser(str, debug)
20
+ end
21
+
22
+
23
+
24
+ # Prepares for parsing +str+. If you define a custom initialize you must
25
+ # call this method before #parse
26
+ def setup_parser(str, debug=false)
27
+ set_string str, 0
28
+ @memoizations = Hash.new { |h,k| h[k] = {} }
29
+ @result = nil
30
+ @failed_rule = nil
31
+ @failing_rule_offset = -1
32
+
33
+ setup_foreign_grammar
34
+ end
35
+
36
+ attr_reader :string
37
+ attr_reader :failing_rule_offset
38
+ attr_accessor :result, :pos
39
+
40
+ def current_column(target=pos)
41
+ if c = string.rindex("\n", target-1)
42
+ return target - c - 1
43
+ end
44
+
45
+ target + 1
46
+ end
47
+
48
+ def current_line(target=pos)
49
+ cur_offset = 0
50
+ cur_line = 0
51
+
52
+ string.each_line do |line|
53
+ cur_line += 1
54
+ cur_offset += line.size
55
+ return cur_line if cur_offset >= target
56
+ end
57
+
58
+ -1
59
+ end
60
+
61
+ def lines
62
+ lines = []
63
+ string.each_line { |l| lines << l }
64
+ lines
65
+ end
66
+
67
+
68
+
69
+ def get_text(start)
70
+ @string[start..@pos-1]
71
+ end
72
+
73
+ # Sets the string and current parsing position for the parser.
74
+ def set_string string, pos
75
+ @string = string
76
+ @string_size = string ? string.size : 0
77
+ @pos = pos
78
+ end
79
+
80
+ def show_pos
81
+ width = 10
82
+ if @pos < width
83
+ "#{@pos} (\"#{@string[0,@pos]}\" @ \"#{@string[@pos,width]}\")"
84
+ else
85
+ "#{@pos} (\"... #{@string[@pos - width, width]}\" @ \"#{@string[@pos,width]}\")"
86
+ end
87
+ end
88
+
89
+ def failure_info
90
+ l = current_line @failing_rule_offset
91
+ c = current_column @failing_rule_offset
92
+
93
+ if @failed_rule.kind_of? Symbol
94
+ info = self.class::Rules[@failed_rule]
95
+ "line #{l}, column #{c}: failed rule '#{info.name}' = '#{info.rendered}'"
96
+ else
97
+ "line #{l}, column #{c}: failed rule '#{@failed_rule}'"
98
+ end
99
+ end
100
+
101
+ def failure_caret
102
+ l = current_line @failing_rule_offset
103
+ c = current_column @failing_rule_offset
104
+
105
+ line = lines[l-1]
106
+ "#{line}\n#{' ' * (c - 1)}^"
107
+ end
108
+
109
+ def failure_character
110
+ l = current_line @failing_rule_offset
111
+ c = current_column @failing_rule_offset
112
+ lines[l-1][c-1, 1]
113
+ end
114
+
115
+ def failure_oneline
116
+ l = current_line @failing_rule_offset
117
+ c = current_column @failing_rule_offset
118
+
119
+ char = lines[l-1][c-1, 1]
120
+
121
+ if @failed_rule.kind_of? Symbol
122
+ info = self.class::Rules[@failed_rule]
123
+ "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
124
+ else
125
+ "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
126
+ end
127
+ end
128
+
129
+ class ParseError < RuntimeError
130
+ end
131
+
132
+ def raise_error
133
+ raise ParseError, failure_oneline
134
+ end
135
+
136
+ def show_error(io=STDOUT)
137
+ error_pos = @failing_rule_offset
138
+ line_no = current_line(error_pos)
139
+ col_no = current_column(error_pos)
140
+
141
+ io.puts "On line #{line_no}, column #{col_no}:"
142
+
143
+ if @failed_rule.kind_of? Symbol
144
+ info = self.class::Rules[@failed_rule]
145
+ io.puts "Failed to match '#{info.rendered}' (rule '#{info.name}')"
146
+ else
147
+ io.puts "Failed to match rule '#{@failed_rule}'"
148
+ end
149
+
150
+ io.puts "Got: #{string[error_pos,1].inspect}"
151
+ line = lines[line_no-1]
152
+ io.puts "=> #{line}"
153
+ io.print(" " * (col_no + 3))
154
+ io.puts "^"
155
+ end
156
+
157
+ def set_failed_rule(name)
158
+ if @pos > @failing_rule_offset
159
+ @failed_rule = name
160
+ @failing_rule_offset = @pos
161
+ end
162
+ end
163
+
164
+ attr_reader :failed_rule
165
+
166
+ def match_string(str)
167
+ len = str.size
168
+ if @string[pos,len] == str
169
+ @pos += len
170
+ return str
171
+ end
172
+
173
+ return nil
174
+ end
175
+
176
+ def scan(reg)
177
+ if m = reg.match(@string[@pos..-1])
178
+ width = m.end(0)
179
+ @pos += width
180
+ return true
181
+ end
182
+
183
+ return nil
184
+ end
185
+
186
+ if "".respond_to? :ord
187
+ def get_byte
188
+ if @pos >= @string_size
189
+ return nil
190
+ end
191
+
192
+ s = @string[@pos].ord
193
+ @pos += 1
194
+ s
195
+ end
196
+ else
197
+ def get_byte
198
+ if @pos >= @string_size
199
+ return nil
200
+ end
201
+
202
+ s = @string[@pos]
203
+ @pos += 1
204
+ s
205
+ end
206
+ end
207
+
208
+ def parse(rule=nil)
209
+ # We invoke the rules indirectly via apply
210
+ # instead of by just calling them as methods because
211
+ # if the rules use left recursion, apply needs to
212
+ # manage that.
213
+
214
+ if !rule
215
+ apply(:_root)
216
+ else
217
+ method = rule.gsub("-","_hyphen_")
218
+ apply :"_#{method}"
219
+ end
220
+ end
221
+
222
+ class MemoEntry
223
+ def initialize(ans, pos)
224
+ @ans = ans
225
+ @pos = pos
226
+ @result = nil
227
+ @set = false
228
+ @left_rec = false
229
+ end
230
+
231
+ attr_reader :ans, :pos, :result, :set
232
+ attr_accessor :left_rec
233
+
234
+ def move!(ans, pos, result)
235
+ @ans = ans
236
+ @pos = pos
237
+ @result = result
238
+ @set = true
239
+ @left_rec = false
240
+ end
241
+ end
242
+
243
+ def external_invoke(other, rule, *args)
244
+ old_pos = @pos
245
+ old_string = @string
246
+
247
+ set_string other.string, other.pos
248
+
249
+ begin
250
+ if val = __send__(rule, *args)
251
+ other.pos = @pos
252
+ other.result = @result
253
+ else
254
+ other.set_failed_rule "#{self.class}##{rule}"
255
+ end
256
+ val
257
+ ensure
258
+ set_string old_string, old_pos
259
+ end
260
+ end
261
+
262
+ def apply_with_args(rule, *args)
263
+ memo_key = [rule, args]
264
+ if m = @memoizations[memo_key][@pos]
265
+ @pos = m.pos
266
+ if !m.set
267
+ m.left_rec = true
268
+ return nil
269
+ end
270
+
271
+ @result = m.result
272
+
273
+ return m.ans
274
+ else
275
+ m = MemoEntry.new(nil, @pos)
276
+ @memoizations[memo_key][@pos] = m
277
+ start_pos = @pos
278
+
279
+ ans = __send__ rule, *args
280
+
281
+ lr = m.left_rec
282
+
283
+ m.move! ans, @pos, @result
284
+
285
+ # Don't bother trying to grow the left recursion
286
+ # if it's failing straight away (thus there is no seed)
287
+ if ans and lr
288
+ return grow_lr(rule, args, start_pos, m)
289
+ else
290
+ return ans
291
+ end
292
+ end
293
+ end
294
+
295
+ def apply(rule)
296
+ if m = @memoizations[rule][@pos]
297
+ @pos = m.pos
298
+ if !m.set
299
+ m.left_rec = true
300
+ return nil
301
+ end
302
+
303
+ @result = m.result
304
+
305
+ return m.ans
306
+ else
307
+ m = MemoEntry.new(nil, @pos)
308
+ @memoizations[rule][@pos] = m
309
+ start_pos = @pos
310
+
311
+ ans = __send__ rule
312
+
313
+ lr = m.left_rec
314
+
315
+ m.move! ans, @pos, @result
316
+
317
+ # Don't bother trying to grow the left recursion
318
+ # if it's failing straight away (thus there is no seed)
319
+ if ans and lr
320
+ return grow_lr(rule, nil, start_pos, m)
321
+ else
322
+ return ans
323
+ end
324
+ end
325
+ end
326
+
327
+ def grow_lr(rule, args, start_pos, m)
328
+ while true
329
+ @pos = start_pos
330
+ @result = m.result
331
+
332
+ if args
333
+ ans = __send__ rule, *args
334
+ else
335
+ ans = __send__ rule
336
+ end
337
+ return nil unless ans
338
+
339
+ break if @pos <= m.pos
340
+
341
+ m.move! ans, @pos, @result
342
+ end
343
+
344
+ @result = m.result
345
+ @pos = m.pos
346
+ return m.ans
347
+ end
348
+
349
+ class RuleInfo
350
+ def initialize(name, rendered)
351
+ @name = name
352
+ @rendered = rendered
353
+ end
354
+
355
+ attr_reader :name, :rendered
356
+ end
357
+
358
+ def self.rule_info(name, rendered)
359
+ RuleInfo.new(name, rendered)
360
+ end
361
+
362
+
363
+ # :startdoc:
364
+ # :stopdoc:
365
+ def setup_foreign_grammar; end
366
+
367
+ # Alphanumeric = /\p{Word}/
368
+ def _Alphanumeric
369
+ _tmp = scan(/\A(?-mix:\p{Word})/)
370
+ set_failed_rule :_Alphanumeric unless _tmp
371
+ return _tmp
372
+ end
373
+
374
+ # AlphanumericAscii = /[A-Za-z0-9]/
375
+ def _AlphanumericAscii
376
+ _tmp = scan(/\A(?-mix:[A-Za-z0-9])/)
377
+ set_failed_rule :_AlphanumericAscii unless _tmp
378
+ return _tmp
379
+ end
380
+
381
+ # BOM = "uFEFF"
382
+ def _BOM
383
+ _tmp = match_string("uFEFF")
384
+ set_failed_rule :_BOM unless _tmp
385
+ return _tmp
386
+ end
387
+
388
+ # Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
389
+ def _Newline
390
+ _tmp = scan(/\A(?-mix:\n|\r\n?|\p{Zl}|\p{Zp})/)
391
+ set_failed_rule :_Newline unless _tmp
392
+ return _tmp
393
+ end
394
+
395
+ # NonAlphanumeric = /\p{^Word}/
396
+ def _NonAlphanumeric
397
+ _tmp = scan(/\A(?-mix:\p{^Word})/)
398
+ set_failed_rule :_NonAlphanumeric unless _tmp
399
+ return _tmp
400
+ end
401
+
402
+ # Spacechar = /\t|\p{Zs}/
403
+ def _Spacechar
404
+ _tmp = scan(/\A(?-mix:\t|\p{Zs})/)
405
+ set_failed_rule :_Spacechar unless _tmp
406
+ return _tmp
407
+ end
408
+
409
+ Rules = {}
410
+ Rules[:_Alphanumeric] = rule_info("Alphanumeric", "/\\p{Word}/")
411
+ Rules[:_AlphanumericAscii] = rule_info("AlphanumericAscii", "/[A-Za-z0-9]/")
412
+ Rules[:_BOM] = rule_info("BOM", "\"uFEFF\"")
413
+ Rules[:_Newline] = rule_info("Newline", "/\\n|\\r\\n?|\\p{Zl}|\\p{Zp}/")
414
+ Rules[:_NonAlphanumeric] = rule_info("NonAlphanumeric", "/\\p{^Word}/")
415
+ Rules[:_Spacechar] = rule_info("Spacechar", "/\\t|\\p{Zs}/")
416
+ # :startdoc:
417
+ end
data/lib/rdoc/markup.rb CHANGED
@@ -843,14 +843,13 @@ https://github.com/ruby/rdoc/issues
843
843
  autoload :List, 'rdoc/markup/list'
844
844
  autoload :ListItem, 'rdoc/markup/list_item'
845
845
  autoload :Paragraph, 'rdoc/markup/paragraph'
846
+ autoload :Table, 'rdoc/markup/table'
846
847
  autoload :Raw, 'rdoc/markup/raw'
847
848
  autoload :Rule, 'rdoc/markup/rule'
848
849
  autoload :Verbatim, 'rdoc/markup/verbatim'
849
850
 
850
851
  # Formatters
851
852
  autoload :Formatter, 'rdoc/markup/formatter'
852
- autoload :FormatterTestCase, 'rdoc/markup/formatter_test_case'
853
- autoload :TextFormatterTestCase, 'rdoc/markup/text_formatter_test_case'
854
853
 
855
854
  autoload :ToAnsi, 'rdoc/markup/to_ansi'
856
855
  autoload :ToBs, 'rdoc/markup/to_bs'
@@ -7,16 +7,22 @@ class RDoc::Markup::AttrSpan
7
7
  ##
8
8
  # Creates a new AttrSpan for +length+ characters
9
9
 
10
- def initialize(length)
10
+ def initialize(length, exclusive)
11
11
  @attrs = Array.new(length, 0)
12
+ @exclusive = exclusive
12
13
  end
13
14
 
14
15
  ##
15
16
  # Toggles +bits+ from +start+ to +length+
16
17
  def set_attrs(start, length, bits)
18
+ updated = false
17
19
  for i in start ... (start+length)
18
- @attrs[i] |= bits
20
+ if (@exclusive & @attrs[i]) == 0 || (@exclusive & bits) != 0
21
+ @attrs[i] |= bits
22
+ updated = true
23
+ end
19
24
  end
25
+ updated
20
26
  end
21
27
 
22
28
  ##