rdoc 6.4.1.1 → 6.5.0

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/exe/rdoc +0 -1
  5. data/lib/rdoc/any_method.rb +2 -2
  6. data/lib/rdoc/code_objects.rb +1 -2
  7. data/lib/rdoc/context/section.rb +2 -0
  8. data/lib/rdoc/context.rb +1 -3
  9. data/lib/rdoc/cross_reference.rb +17 -1
  10. data/lib/rdoc/generator/markup.rb +1 -1
  11. data/lib/rdoc/generator/template/darkfish/_head.rhtml +10 -10
  12. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  13. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  14. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  15. data/lib/rdoc/generator/template/darkfish/class.rhtml +22 -20
  16. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +24 -1
  17. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  18. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +1 -1
  19. data/lib/rdoc/generator/template/darkfish/js/search.js +1 -1
  20. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +2 -2
  21. data/lib/rdoc/generator.rb +5 -5
  22. data/lib/rdoc/i18n.rb +1 -1
  23. data/lib/rdoc/known_classes.rb +5 -4
  24. data/lib/rdoc/markdown/literals.rb +43 -66
  25. data/lib/rdoc/markdown.kpeg +25 -18
  26. data/lib/rdoc/markdown.rb +252 -194
  27. data/lib/rdoc/markup/attribute_manager.rb +29 -35
  28. data/lib/rdoc/markup/parser.rb +12 -6
  29. data/lib/rdoc/markup/to_html.rb +18 -14
  30. data/lib/rdoc/markup/to_label.rb +1 -1
  31. data/lib/rdoc/markup/to_rdoc.rb +3 -20
  32. data/lib/rdoc/markup.rb +35 -667
  33. data/lib/rdoc/method_attr.rb +1 -1
  34. data/lib/rdoc/normal_class.rb +1 -1
  35. data/lib/rdoc/normal_module.rb +1 -1
  36. data/lib/rdoc/options.rb +33 -18
  37. data/lib/rdoc/parser/c.rb +89 -101
  38. data/lib/rdoc/parser/ruby.rb +25 -10
  39. data/lib/rdoc/parser.rb +19 -2
  40. data/lib/rdoc/rd/block_parser.rb +14 -12
  41. data/lib/rdoc/rd/block_parser.ry +12 -8
  42. data/lib/rdoc/rd/inline_parser.rb +2 -4
  43. data/lib/rdoc/rd.rb +3 -4
  44. data/lib/rdoc/rdoc.rb +17 -3
  45. data/lib/rdoc/ri/driver.rb +11 -78
  46. data/lib/rdoc/ri.rb +4 -5
  47. data/lib/rdoc/rubygems_hook.rb +1 -1
  48. data/lib/rdoc/servlet.rb +1 -1
  49. data/lib/rdoc/single_class.rb +5 -0
  50. data/lib/rdoc/stats.rb +3 -4
  51. data/lib/rdoc/store.rb +19 -26
  52. data/lib/rdoc/task.rb +3 -3
  53. data/lib/rdoc/version.rb +3 -1
  54. data/lib/rdoc.rb +46 -46
  55. metadata +7 -9
  56. data/Gemfile +0 -12
  57. data/Rakefile +0 -107
  58. data/bin/console +0 -7
  59. data/bin/setup +0 -6
  60. data/rdoc.gemspec +0 -249
@@ -39,75 +39,45 @@ class RDoc::Markdown::Literals
39
39
  attr_accessor :result, :pos
40
40
 
41
41
  def current_column(target=pos)
42
- if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
43
- return target - c
44
- elsif c = string.rindex("\n", target)
45
- return target - c
42
+ if c = string.rindex("\n", target-1)
43
+ return target - c - 1
46
44
  end
47
45
 
48
46
  target + 1
49
47
  end
50
48
 
51
- def position_line_offsets
52
- unless @position_line_offsets
53
- @position_line_offsets = []
54
- total = 0
55
- string.each_line do |line|
56
- total += line.size
57
- @position_line_offsets << total
58
- end
59
- end
60
- @position_line_offsets
61
- end
62
-
63
49
  if [].respond_to? :bsearch_index
64
50
  def current_line(target=pos)
65
- if line = position_line_offsets.bsearch_index {|x| x > target }
66
- return line + 1
51
+ unless @line_offsets
52
+ @line_offsets = []
53
+ total = 0
54
+ string.each_line do |line|
55
+ total += line.size
56
+ @line_offsets << total
57
+ end
67
58
  end
68
- raise "Target position #{target} is outside of string"
59
+
60
+ @line_offsets.bsearch_index {|x| x >= target } + 1 || -1
69
61
  end
70
62
  else
71
63
  def current_line(target=pos)
72
- if line = position_line_offsets.index {|x| x > target }
73
- return line + 1
74
- end
64
+ cur_offset = 0
65
+ cur_line = 0
75
66
 
76
- raise "Target position #{target} is outside of string"
77
- end
78
- end
67
+ string.each_line do |line|
68
+ cur_line += 1
69
+ cur_offset += line.size
70
+ return cur_line if cur_offset >= target
71
+ end
79
72
 
80
- def current_character(target=pos)
81
- if target < 0 || target >= string.size
82
- raise "Target position #{target} is outside of string"
73
+ -1
83
74
  end
84
- string[target, 1]
85
- end
86
-
87
- KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
88
-
89
- def current_pos_info(target=pos)
90
- l = current_line target
91
- c = current_column target
92
- ln = get_line(l-1)
93
- chr = string[target,1]
94
- KpegPosInfo.new(target, l, c, ln, chr)
95
75
  end
96
76
 
97
77
  def lines
98
- string.lines
99
- end
100
-
101
- def get_line(no)
102
- loff = position_line_offsets
103
- if no < 0
104
- raise "Line No is out of range: #{no} < 0"
105
- elsif no >= loff.size
106
- raise "Line No is out of range: #{no} >= #{loff.size}"
107
- end
108
- lend = loff[no]-1
109
- lstart = no > 0 ? loff[no-1] : 0
110
- string[lstart..lend]
78
+ lines = []
79
+ string.each_line { |l| lines << l }
80
+ lines
111
81
  end
112
82
 
113
83
 
@@ -121,7 +91,6 @@ class RDoc::Markdown::Literals
121
91
  @string = string
122
92
  @string_size = string ? string.size : 0
123
93
  @pos = pos
124
- @position_line_offsets = nil
125
94
  end
126
95
 
127
96
  def show_pos
@@ -146,22 +115,30 @@ class RDoc::Markdown::Literals
146
115
  end
147
116
 
148
117
  def failure_caret
149
- p = current_pos_info @failing_rule_offset
150
- "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
118
+ l = current_line @failing_rule_offset
119
+ c = current_column @failing_rule_offset
120
+
121
+ line = lines[l-1]
122
+ "#{line}\n#{' ' * (c - 1)}^"
151
123
  end
152
124
 
153
125
  def failure_character
154
- current_character @failing_rule_offset
126
+ l = current_line @failing_rule_offset
127
+ c = current_column @failing_rule_offset
128
+ lines[l-1][c-1, 1]
155
129
  end
156
130
 
157
131
  def failure_oneline
158
- p = current_pos_info @failing_rule_offset
132
+ l = current_line @failing_rule_offset
133
+ c = current_column @failing_rule_offset
134
+
135
+ char = lines[l-1][c-1, 1]
159
136
 
160
137
  if @failed_rule.kind_of? Symbol
161
138
  info = self.class::Rules[@failed_rule]
162
- "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
139
+ "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
163
140
  else
164
- "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
141
+ "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
165
142
  end
166
143
  end
167
144
 
@@ -174,9 +151,10 @@ class RDoc::Markdown::Literals
174
151
 
175
152
  def show_error(io=STDOUT)
176
153
  error_pos = @failing_rule_offset
177
- p = current_pos_info(error_pos)
154
+ line_no = current_line(error_pos)
155
+ col_no = current_column(error_pos)
178
156
 
179
- io.puts "On line #{p.lno}, column #{p.col}:"
157
+ io.puts "On line #{line_no}, column #{col_no}:"
180
158
 
181
159
  if @failed_rule.kind_of? Symbol
182
160
  info = self.class::Rules[@failed_rule]
@@ -185,9 +163,10 @@ class RDoc::Markdown::Literals
185
163
  io.puts "Failed to match rule '#{@failed_rule}'"
186
164
  end
187
165
 
188
- io.puts "Got: #{p.char.inspect}"
189
- io.puts "=> #{p.line}"
190
- io.print(" " * (p.col + 2))
166
+ io.puts "Got: #{string[error_pos,1].inspect}"
167
+ line = lines[line_no-1]
168
+ io.puts "=> #{line}"
169
+ io.print(" " * (col_no + 3))
191
170
  io.puts "^"
192
171
  end
193
172
 
@@ -296,7 +275,6 @@ class RDoc::Markdown::Literals
296
275
  end
297
276
 
298
277
  def apply_with_args(rule, *args)
299
- @result = nil
300
278
  memo_key = [rule, args]
301
279
  if m = @memoizations[memo_key][@pos]
302
280
  @pos = m.pos
@@ -330,7 +308,6 @@ class RDoc::Markdown::Literals
330
308
  end
331
309
 
332
310
  def apply(rule)
333
- @result = nil
334
311
  if m = @memoizations[rule][@pos]
335
312
  @pos = m.pos
336
313
  if !m.set
@@ -187,11 +187,11 @@
187
187
 
188
188
  %% {
189
189
 
190
- require 'rdoc'
191
- require 'rdoc/markup/to_joined_paragraph'
192
- require 'rdoc/markdown/entities'
190
+ require_relative '../rdoc'
191
+ require_relative 'markup/to_joined_paragraph'
192
+ require_relative 'markdown/entities'
193
193
 
194
- require 'rdoc/markdown/literals'
194
+ require_relative 'markdown/literals'
195
195
 
196
196
  ##
197
197
  # Supported extensions
@@ -449,7 +449,7 @@
449
449
 
450
450
  @note_order.each_with_index do |ref, index|
451
451
  label = index + 1
452
- note = @footnotes[ref]
452
+ note = @footnotes[ref] or raise ParseError, "footnote [^#{ref}] not found"
453
453
 
454
454
  link = "{^#{label}}[rdoc-label:footmark-#{label}:foottext-#{label}] "
455
455
  note.parts.unshift link
@@ -1135,7 +1135,7 @@ StartList = &.
1135
1135
  { [] }
1136
1136
 
1137
1137
  Line = @RawLine:a { a }
1138
- RawLine = ( < (!"\r" !"\n" .)* @Newline >
1138
+ RawLine = ( < /[^\r\n]*/ @Newline >
1139
1139
  | < .+ > @Eof ) { text }
1140
1140
 
1141
1141
  SkipBlock = HtmlBlock
@@ -1179,7 +1179,7 @@ InlineNote = &{ notes? }
1179
1179
  Notes = ( Note | SkipBlock )*
1180
1180
 
1181
1181
  RawNoteBlock = @StartList:a
1182
- ( !@BlankLine OptionallyIndentedLine:l { a << l } )+
1182
+ ( !@BlankLine !RawNoteReference OptionallyIndentedLine:l { a << l } )+
1183
1183
  ( < @BlankLine* > { a << text } )
1184
1184
  { a }
1185
1185
 
@@ -1198,19 +1198,26 @@ CodeFence = &{ github? }
1198
1198
  }
1199
1199
 
1200
1200
  Table = &{ github? }
1201
- TableRow:header TableLine:line TableRow+:body
1201
+ TableHead:header TableLine:line TableRow+:body
1202
1202
  { table = RDoc::Markup::Table.new(header, line, body) }
1203
1203
 
1204
- TableRow = TableItem+:row "|" @Newline
1205
- { row }
1206
- TableItem = "|" < (!"|" !@Newline .)+ >
1207
- { text.strip }
1208
-
1209
- TableLine = TableColumn+:line "|" @Newline
1210
- { line }
1211
- TableColumn = "|" < ( "-"+ ":"? | ":" "-"* ) >
1212
- { text.start_with?(":") ? :left :
1213
- text.end_with?(":") ? :right : nil
1204
+ TableHead = TableItem2+:items "|"? @Newline
1205
+ { items }
1206
+
1207
+ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1208
+ { row }
1209
+ TableItem2 = "|" TableItem
1210
+ TableItem = < /(?:\\.|[^|\n])+/ >
1211
+ { text.strip.gsub(/\\(.)/, '\1') }
1212
+
1213
+ TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1214
+ { line }
1215
+ TableAlign2 = "|" @Sp TableAlign
1216
+ TableAlign = < /:?-+:?/ > @Sp
1217
+ {
1218
+ text.start_with?(":") ?
1219
+ (text.end_with?(":") ? :center : :left) :
1220
+ (text.end_with?(":") ? :right : nil)
1214
1221
  }
1215
1222
 
1216
1223
  DefinitionList = &{ definition_lists? }