rdoc 6.5.0 → 6.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -1
  3. data/README.rdoc +2 -2
  4. data/TODO.rdoc +1 -1
  5. data/lib/rdoc/alias.rb +0 -1
  6. data/lib/rdoc/anon_class.rb +0 -1
  7. data/lib/rdoc/any_method.rb +15 -0
  8. data/lib/rdoc/attr.rb +0 -1
  9. data/lib/rdoc/class_module.rb +0 -1
  10. data/lib/rdoc/comment.rb +20 -41
  11. data/lib/rdoc/constant.rb +0 -1
  12. data/lib/rdoc/context/section.rb +0 -1
  13. data/lib/rdoc/context.rb +1 -1
  14. data/lib/rdoc/cross_reference.rb +3 -1
  15. data/lib/rdoc/encoding.rb +1 -17
  16. data/lib/rdoc/erb_partial.rb +0 -1
  17. data/lib/rdoc/erbio.rb +2 -7
  18. data/lib/rdoc/extend.rb +0 -1
  19. data/lib/rdoc/generator/darkfish.rb +2 -6
  20. data/lib/rdoc/generator/json_index.rb +2 -2
  21. data/lib/rdoc/generator/markup.rb +0 -1
  22. data/lib/rdoc/generator/pot.rb +1 -0
  23. data/lib/rdoc/generator/ri.rb +0 -1
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  25. data/lib/rdoc/generator/template/darkfish/class.rhtml +6 -0
  26. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +38 -13
  27. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +13 -0
  28. data/lib/rdoc/generator/template/darkfish/js/search.js +3 -3
  29. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +5 -4
  30. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  31. data/lib/rdoc/ghost_method.rb +0 -1
  32. data/lib/rdoc/include.rb +0 -1
  33. data/lib/rdoc/markdown/entities.rb +0 -1
  34. data/lib/rdoc/markdown/literals.kpeg +0 -2
  35. data/lib/rdoc/markdown/literals.rb +66 -44
  36. data/lib/rdoc/markdown.kpeg +3 -3
  37. data/lib/rdoc/markdown.rb +7 -5
  38. data/lib/rdoc/markup/attr_changer.rb +0 -1
  39. data/lib/rdoc/markup/attr_span.rb +0 -1
  40. data/lib/rdoc/markup/attribute_manager.rb +14 -12
  41. data/lib/rdoc/markup/attributes.rb +0 -1
  42. data/lib/rdoc/markup/blank_line.rb +0 -1
  43. data/lib/rdoc/markup/block_quote.rb +0 -1
  44. data/lib/rdoc/markup/document.rb +0 -1
  45. data/lib/rdoc/markup/formatter.rb +1 -2
  46. data/lib/rdoc/markup/hard_break.rb +0 -1
  47. data/lib/rdoc/markup/heading.rb +0 -1
  48. data/lib/rdoc/markup/include.rb +0 -1
  49. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  50. data/lib/rdoc/markup/list.rb +0 -1
  51. data/lib/rdoc/markup/list_item.rb +0 -1
  52. data/lib/rdoc/markup/paragraph.rb +0 -1
  53. data/lib/rdoc/markup/parser.rb +5 -1
  54. data/lib/rdoc/markup/raw.rb +0 -1
  55. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  56. data/lib/rdoc/markup/rule.rb +0 -1
  57. data/lib/rdoc/markup/table.rb +11 -2
  58. data/lib/rdoc/markup/to_ansi.rb +0 -1
  59. data/lib/rdoc/markup/to_bs.rb +25 -0
  60. data/lib/rdoc/markup/to_html.rb +7 -3
  61. data/lib/rdoc/markup/to_html_crossref.rb +13 -14
  62. data/lib/rdoc/markup/to_html_snippet.rb +3 -1
  63. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  64. data/lib/rdoc/markup/to_label.rb +0 -1
  65. data/lib/rdoc/markup/to_markdown.rb +4 -5
  66. data/lib/rdoc/markup/to_rdoc.rb +11 -4
  67. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  68. data/lib/rdoc/markup/to_test.rb +0 -1
  69. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  70. data/lib/rdoc/markup/verbatim.rb +0 -1
  71. data/lib/rdoc/meta_method.rb +0 -1
  72. data/lib/rdoc/method_attr.rb +0 -1
  73. data/lib/rdoc/mixin.rb +0 -1
  74. data/lib/rdoc/normal_class.rb +0 -1
  75. data/lib/rdoc/normal_module.rb +0 -1
  76. data/lib/rdoc/options.rb +4 -2
  77. data/lib/rdoc/parser/c.rb +33 -22
  78. data/lib/rdoc/parser/changelog.rb +15 -1
  79. data/lib/rdoc/parser/markdown.rb +0 -2
  80. data/lib/rdoc/parser/rd.rb +0 -1
  81. data/lib/rdoc/parser/ripper_state_lex.rb +11 -1
  82. data/lib/rdoc/parser/ruby.rb +18 -6
  83. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  84. data/lib/rdoc/parser/text.rb +0 -1
  85. data/lib/rdoc/parser.rb +4 -2
  86. data/lib/rdoc/rd/block_parser.rb +650 -4
  87. data/lib/rdoc/rd/block_parser.ry +1 -1
  88. data/lib/rdoc/rd/inline.rb +0 -1
  89. data/lib/rdoc/rd/inline_parser.rb +649 -3
  90. data/lib/rdoc/rdoc.rb +2 -4
  91. data/lib/rdoc/require.rb +0 -1
  92. data/lib/rdoc/ri/driver.rb +10 -9
  93. data/lib/rdoc/ri/store.rb +0 -1
  94. data/lib/rdoc/single_class.rb +0 -1
  95. data/lib/rdoc/stats/quiet.rb +0 -1
  96. data/lib/rdoc/stats/verbose.rb +0 -2
  97. data/lib/rdoc/store.rb +29 -19
  98. data/lib/rdoc/task.rb +28 -2
  99. data/lib/rdoc/text.rb +10 -0
  100. data/lib/rdoc/token_stream.rb +1 -2
  101. data/lib/rdoc/top_level.rb +3 -1
  102. data/lib/rdoc/version.rb +1 -1
  103. data/lib/rdoc.rb +12 -0
  104. metadata +8 -8
@@ -3,7 +3,6 @@
3
3
  # :markup: markdown
4
4
 
5
5
  ##
6
- #--
7
6
  # This set of literals is for Ruby 1.9 regular expressions and gives full
8
7
  # unicode support.
9
8
  #
@@ -39,45 +38,75 @@ class RDoc::Markdown::Literals
39
38
  attr_accessor :result, :pos
40
39
 
41
40
  def current_column(target=pos)
42
- if c = string.rindex("\n", target-1)
43
- return target - c - 1
41
+ if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
42
+ return target - c
43
+ elsif c = string.rindex("\n", target)
44
+ return target - c
44
45
  end
45
46
 
46
47
  target + 1
47
48
  end
48
49
 
50
+ def position_line_offsets
51
+ unless @position_line_offsets
52
+ @position_line_offsets = []
53
+ total = 0
54
+ string.each_line do |line|
55
+ total += line.size
56
+ @position_line_offsets << total
57
+ end
58
+ end
59
+ @position_line_offsets
60
+ end
61
+
49
62
  if [].respond_to? :bsearch_index
50
63
  def current_line(target=pos)
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
64
+ if line = position_line_offsets.bsearch_index {|x| x > target }
65
+ return line + 1
58
66
  end
59
-
60
- @line_offsets.bsearch_index {|x| x >= target } + 1 || -1
67
+ raise "Target position #{target} is outside of string"
61
68
  end
62
69
  else
63
70
  def current_line(target=pos)
64
- cur_offset = 0
65
- cur_line = 0
66
-
67
- string.each_line do |line|
68
- cur_line += 1
69
- cur_offset += line.size
70
- return cur_line if cur_offset >= target
71
+ if line = position_line_offsets.index {|x| x > target }
72
+ return line + 1
71
73
  end
72
74
 
73
- -1
75
+ raise "Target position #{target} is outside of string"
76
+ end
77
+ end
78
+
79
+ def current_character(target=pos)
80
+ if target < 0 || target >= string.size
81
+ raise "Target position #{target} is outside of string"
74
82
  end
83
+ string[target, 1]
84
+ end
85
+
86
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
87
+
88
+ def current_pos_info(target=pos)
89
+ l = current_line target
90
+ c = current_column target
91
+ ln = get_line(l-1)
92
+ chr = string[target,1]
93
+ KpegPosInfo.new(target, l, c, ln, chr)
75
94
  end
76
95
 
77
96
  def lines
78
- lines = []
79
- string.each_line { |l| lines << l }
80
- lines
97
+ string.lines
98
+ end
99
+
100
+ def get_line(no)
101
+ loff = position_line_offsets
102
+ if no < 0
103
+ raise "Line No is out of range: #{no} < 0"
104
+ elsif no >= loff.size
105
+ raise "Line No is out of range: #{no} >= #{loff.size}"
106
+ end
107
+ lend = loff[no]-1
108
+ lstart = no > 0 ? loff[no-1] : 0
109
+ string[lstart..lend]
81
110
  end
82
111
 
83
112
 
@@ -91,6 +120,7 @@ class RDoc::Markdown::Literals
91
120
  @string = string
92
121
  @string_size = string ? string.size : 0
93
122
  @pos = pos
123
+ @position_line_offsets = nil
94
124
  end
95
125
 
96
126
  def show_pos
@@ -115,30 +145,22 @@ class RDoc::Markdown::Literals
115
145
  end
116
146
 
117
147
  def failure_caret
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)}^"
148
+ p = current_pos_info @failing_rule_offset
149
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
123
150
  end
124
151
 
125
152
  def failure_character
126
- l = current_line @failing_rule_offset
127
- c = current_column @failing_rule_offset
128
- lines[l-1][c-1, 1]
153
+ current_character @failing_rule_offset
129
154
  end
130
155
 
131
156
  def failure_oneline
132
- l = current_line @failing_rule_offset
133
- c = current_column @failing_rule_offset
134
-
135
- char = lines[l-1][c-1, 1]
157
+ p = current_pos_info @failing_rule_offset
136
158
 
137
159
  if @failed_rule.kind_of? Symbol
138
160
  info = self.class::Rules[@failed_rule]
139
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
161
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
140
162
  else
141
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
163
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
142
164
  end
143
165
  end
144
166
 
@@ -151,10 +173,9 @@ class RDoc::Markdown::Literals
151
173
 
152
174
  def show_error(io=STDOUT)
153
175
  error_pos = @failing_rule_offset
154
- line_no = current_line(error_pos)
155
- col_no = current_column(error_pos)
176
+ p = current_pos_info(error_pos)
156
177
 
157
- io.puts "On line #{line_no}, column #{col_no}:"
178
+ io.puts "On line #{p.lno}, column #{p.col}:"
158
179
 
159
180
  if @failed_rule.kind_of? Symbol
160
181
  info = self.class::Rules[@failed_rule]
@@ -163,10 +184,9 @@ class RDoc::Markdown::Literals
163
184
  io.puts "Failed to match rule '#{@failed_rule}'"
164
185
  end
165
186
 
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))
187
+ io.puts "Got: #{p.char.inspect}"
188
+ io.puts "=> #{p.line}"
189
+ io.print(" " * (p.col + 2))
170
190
  io.puts "^"
171
191
  end
172
192
 
@@ -275,6 +295,7 @@ class RDoc::Markdown::Literals
275
295
  end
276
296
 
277
297
  def apply_with_args(rule, *args)
298
+ @result = nil
278
299
  memo_key = [rule, args]
279
300
  if m = @memoizations[memo_key][@pos]
280
301
  @pos = m.pos
@@ -308,6 +329,7 @@ class RDoc::Markdown::Literals
308
329
  end
309
330
 
310
331
  def apply(rule)
332
+ @result = nil
311
333
  if m = @memoizations[rule][@pos]
312
334
  @pos = m.pos
313
335
  if !m.set
@@ -9,7 +9,7 @@
9
9
  # RDoc::Markdown as described by the [markdown syntax][syntax].
10
10
  #
11
11
  # To choose Markdown as your only default format see
12
- # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
12
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
13
13
  # file to store your project default.
14
14
  #
15
15
  # ## Usage
@@ -178,7 +178,7 @@
178
178
  # [dingus]: http://daringfireball.net/projects/markdown/dingus
179
179
  # [GFM]: https://github.github.com/gfm/
180
180
  # [pegmarkdown]: https://github.com/jgm/peg-markdown
181
- # [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
181
+ # [PHPE]: https://michelf.ca/projects/php-markdown/extra/#def-list
182
182
  # [syntax]: http://daringfireball.net/projects/markdown/syntax
183
183
  #--
184
184
  # Last updated to jgm/peg-markdown commit 8f8fc22ef0
@@ -1237,7 +1237,7 @@ DefinitionListItem = ( DefinitionListLabel+ ):label
1237
1237
  list_items
1238
1238
  }
1239
1239
 
1240
- DefinitionListLabel = StrChunk:label @Sp @Newline
1240
+ DefinitionListLabel = Inline:label @Sp @Newline
1241
1241
  { label }
1242
1242
 
1243
1243
  DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+
data/lib/rdoc/markdown.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # RDoc::Markdown as described by the [markdown syntax][syntax].
7
7
  #
8
8
  # To choose Markdown as your only default format see
9
- # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
9
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
10
10
  # file to store your project default.
11
11
  #
12
12
  # ## Usage
@@ -175,7 +175,7 @@
175
175
  # [dingus]: http://daringfireball.net/projects/markdown/dingus
176
176
  # [GFM]: https://github.github.com/gfm/
177
177
  # [pegmarkdown]: https://github.com/jgm/peg-markdown
178
- # [PHPE]: http://michelf.com/projects/php-markdown/extra/#def-list
178
+ # [PHPE]: https://michelf.ca/projects/php-markdown/extra/#def-list
179
179
  # [syntax]: http://daringfireball.net/projects/markdown/syntax
180
180
  #--
181
181
  # Last updated to jgm/peg-markdown commit 8f8fc22ef0
@@ -466,6 +466,7 @@ class RDoc::Markdown
466
466
  end
467
467
 
468
468
  def apply_with_args(rule, *args)
469
+ @result = nil
469
470
  memo_key = [rule, args]
470
471
  if m = @memoizations[memo_key][@pos]
471
472
  @pos = m.pos
@@ -499,6 +500,7 @@ class RDoc::Markdown
499
500
  end
500
501
 
501
502
  def apply(rule)
503
+ @result = nil
502
504
  if m = @memoizations[rule][@pos]
503
505
  @pos = m.pos
504
506
  if !m.set
@@ -16443,12 +16445,12 @@ class RDoc::Markdown
16443
16445
  return _tmp
16444
16446
  end
16445
16447
 
16446
- # DefinitionListLabel = StrChunk:label @Sp @Newline { label }
16448
+ # DefinitionListLabel = Inline:label @Sp @Newline { label }
16447
16449
  def _DefinitionListLabel
16448
16450
 
16449
16451
  _save = self.pos
16450
16452
  while true # sequence
16451
- _tmp = apply(:_StrChunk)
16453
+ _tmp = apply(:_Inline)
16452
16454
  label = @result
16453
16455
  unless _tmp
16454
16456
  self.pos = _save
@@ -16775,7 +16777,7 @@ class RDoc::Markdown
16775
16777
  Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > @Sp { text.start_with?(\":\") ? (text.end_with?(\":\") ? :center : :left) : (text.end_with?(\":\") ? :right : nil) }")
16776
16778
  Rules[:_DefinitionList] = rule_info("DefinitionList", "&{ definition_lists? } DefinitionListItem+:list { RDoc::Markup::List.new :NOTE, *list.flatten }")
16777
16779
  Rules[:_DefinitionListItem] = rule_info("DefinitionListItem", "DefinitionListLabel+:label DefinitionListDefinition+:defns { list_items = [] list_items << RDoc::Markup::ListItem.new(label, defns.shift) list_items.concat defns.map { |defn| RDoc::Markup::ListItem.new nil, defn } unless list_items.empty? list_items }")
16778
- Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "StrChunk:label @Sp @Newline { label }")
16780
+ Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "Inline:label @Sp @Newline { label }")
16779
16781
  Rules[:_DefinitionListDefinition] = rule_info("DefinitionListDefinition", "@NonindentSpace \":\" @Space Inlines:a @BlankLine+ { paragraph a }")
16780
16782
  # :startdoc:
16781
16783
  end
@@ -20,4 +20,3 @@ class RDoc::Markup::AttrChanger
20
20
  end
21
21
 
22
22
  end
23
-
@@ -33,4 +33,3 @@ class RDoc::Markup::AttrSpan
33
33
  end
34
34
 
35
35
  end
36
-
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  ##
3
4
  # Manages changes of attributes in a block of text
4
5
 
5
- unless MatchData.method_defined?(:match_length)
6
- using Module.new {
7
- refine(MatchData) {
8
- def match_length(nth)
9
- b, e = offset(nth)
10
- e - b if b
11
- end
12
- }
13
- }
14
- end
15
-
16
6
  class RDoc::Markup::AttributeManager
7
+ unless ::MatchData.method_defined?(:match_length)
8
+ using ::Module.new {
9
+ refine(::MatchData) {
10
+ def match_length(nth) # :nodoc:
11
+ b, e = offset(nth)
12
+ e - b if b
13
+ end
14
+ }
15
+ }
16
+ end
17
17
 
18
18
  ##
19
19
  # The NUL character
@@ -138,6 +138,7 @@ class RDoc::Markup::AttributeManager
138
138
  res
139
139
  end
140
140
 
141
+ # :nodoc:
141
142
  def exclusive?(attr)
142
143
  (attr & @exclusive_bitmap) != 0
143
144
  end
@@ -155,6 +156,7 @@ class RDoc::Markup::AttributeManager
155
156
  convert_attrs_word_pair_map(str, attrs, exclusive)
156
157
  end
157
158
 
159
+ # :nodoc:
158
160
  def convert_attrs_matching_word_pairs(str, attrs, exclusive)
159
161
  # first do matching ones
160
162
  tags = @matching_word_pairs.select { |start, bitmap|
@@ -179,6 +181,7 @@ class RDoc::Markup::AttributeManager
179
181
  str.delete!(NON_PRINTING_START + NON_PRINTING_END)
180
182
  end
181
183
 
184
+ # :nodoc:
182
185
  def convert_attrs_word_pair_map(str, attrs, exclusive)
183
186
  # then non-matching
184
187
  unless @word_pair_map.empty? then
@@ -400,4 +403,3 @@ class RDoc::Markup::AttributeManager
400
403
  end
401
404
 
402
405
  end
403
-
@@ -68,4 +68,3 @@ class RDoc::Markup::Attributes
68
68
  end
69
69
 
70
70
  end
71
-
@@ -25,4 +25,3 @@ class RDoc::Markup::BlankLine
25
25
  end
26
26
 
27
27
  end
28
-
@@ -12,4 +12,3 @@ class RDoc::Markup::BlockQuote < RDoc::Markup::Raw
12
12
  end
13
13
 
14
14
  end
15
-
@@ -162,4 +162,3 @@ class RDoc::Markup::Document
162
162
  end
163
163
 
164
164
  end
165
-
@@ -90,7 +90,7 @@ class RDoc::Markup::Formatter
90
90
 
91
91
  def add_regexp_handling_TIDYLINK
92
92
  @markup.add_regexp_handling(/(?:
93
- \{.*?\} | # multi-word label
93
+ \{[^{}]*\} | # multi-word label
94
94
  \b[^\s{}]+? # single-word label
95
95
  )
96
96
 
@@ -263,4 +263,3 @@ class RDoc::Markup::Formatter
263
263
  end
264
264
 
265
265
  end
266
-
@@ -29,4 +29,3 @@ class RDoc::Markup::HardBreak
29
29
  end
30
30
 
31
31
  end
32
-
@@ -76,4 +76,3 @@ RDoc::Markup::Heading =
76
76
  end
77
77
 
78
78
  end
79
-
@@ -40,4 +40,3 @@ class RDoc::Markup::Include
40
40
  end
41
41
 
42
42
  end
43
-
@@ -45,4 +45,3 @@ class RDoc::Markup::IndentedParagraph < RDoc::Markup::Raw
45
45
  end
46
46
 
47
47
  end
48
-
@@ -99,4 +99,3 @@ class RDoc::Markup::List
99
99
  end
100
100
 
101
101
  end
102
-
@@ -97,4 +97,3 @@ class RDoc::Markup::ListItem
97
97
  end
98
98
 
99
99
  end
100
-
@@ -26,4 +26,3 @@ class RDoc::Markup::Paragraph < RDoc::Markup::Raw
26
26
  end
27
27
 
28
28
  end
29
-
@@ -218,7 +218,7 @@ class RDoc::Markup::Parser
218
218
 
219
219
  break if peek_token.first == :BREAK
220
220
 
221
- data << ' ' if skip :NEWLINE
221
+ data << ' ' if skip :NEWLINE and /#{SPACE_SEPARATED_LETTER_CLASS}\z/o.match?(data)
222
222
  else
223
223
  unget
224
224
  break
@@ -420,6 +420,8 @@ class RDoc::Markup::Parser
420
420
  # A simple wrapper of StringScanner that is aware of the current column and lineno
421
421
 
422
422
  class MyStringScanner
423
+ # :stopdoc:
424
+
423
425
  def initialize(input)
424
426
  @line = @column = 0
425
427
  @s = StringScanner.new input
@@ -456,6 +458,8 @@ class RDoc::Markup::Parser
456
458
  def [](i)
457
459
  @s[i]
458
460
  end
461
+
462
+ #:startdoc:
459
463
  end
460
464
 
461
465
  ##
@@ -67,4 +67,3 @@ class RDoc::Markup::Raw
67
67
  end
68
68
 
69
69
  end
70
-
@@ -38,4 +38,3 @@ class RDoc::Markup::RegexpHandling
38
38
  end
39
39
 
40
40
  end
41
-
@@ -18,4 +18,3 @@ class RDoc::Markup::Rule < Struct.new :weight
18
18
  end
19
19
 
20
20
  end
21
-
@@ -3,12 +3,21 @@
3
3
  # A section of table
4
4
 
5
5
  class RDoc::Markup::Table
6
- attr_accessor :header, :align, :body
6
+ # headers of each column
7
+ attr_accessor :header
7
8
 
9
+ # alignments of each column
10
+ attr_accessor :align
11
+
12
+ # body texts of each column
13
+ attr_accessor :body
14
+
15
+ # Creates new instance
8
16
  def initialize header, align, body
9
17
  @header, @align, @body = header, align, body
10
18
  end
11
19
 
20
+ # :stopdoc:
12
21
  def == other
13
22
  self.class == other.class and
14
23
  @header == other.header and
@@ -20,7 +29,7 @@ class RDoc::Markup::Table
20
29
  visitor.accept_table @header, @body, @align
21
30
  end
22
31
 
23
- def pretty_print q # :nodoc:
32
+ def pretty_print q
24
33
  q.group 2, '[Table: ', ']' do
25
34
  q.group 2, '[Head: ', ']' do
26
35
  q.seplist @header.zip(@align) do |text, align|
@@ -91,4 +91,3 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
91
91
  end
92
92
 
93
93
  end
94
-
@@ -40,6 +40,31 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
40
40
  @res << "\n"
41
41
  end
42
42
 
43
+ ##
44
+ # Prepares the visitor for consuming +list_item+
45
+
46
+ def accept_list_item_start list_item
47
+ type = @list_type.last
48
+
49
+ case type
50
+ when :NOTE, :LABEL then
51
+ bullets = Array(list_item.label).map do |label|
52
+ attributes(label).strip
53
+ end.join "\n"
54
+
55
+ bullets << ":\n" unless bullets.empty?
56
+
57
+ @prefix = ' ' * @indent
58
+ @indent += 2
59
+ @prefix << bullets + (' ' * @indent)
60
+ else
61
+ bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
62
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
63
+ width = bullet.length + 1
64
+ @indent += width
65
+ end
66
+ end
67
+
43
68
  ##
44
69
  # Turns on or off regexp handling for +convert_string+
45
70
 
@@ -61,6 +61,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
61
61
  #
62
62
  # These methods are used by regexp handling markup added by RDoc::Markup#add_regexp_handling.
63
63
 
64
+ # :nodoc:
64
65
  URL_CHARACTERS_REGEXP_STR = /[A-Za-z0-9\-._~:\/\?#\[\]@!$&'\(\)*+,;%=]/.source
65
66
 
66
67
  ##
@@ -202,7 +203,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
202
203
  def accept_paragraph paragraph
203
204
  @res << "\n<p>"
204
205
  text = paragraph.text @hard_break
205
- text = text.gsub(/\r?\n/, ' ')
206
+ text = text.gsub(/(#{SPACE_SEPARATED_LETTER_CLASS})?\K\r?\n(?=(?(1)(#{SPACE_SEPARATED_LETTER_CLASS})?))/o) {
207
+ defined?($2) && ' '
208
+ }
206
209
  @res << to_html(text)
207
210
  @res << "</p>\n"
208
211
  end
@@ -430,7 +433,9 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
430
433
 
431
434
  def parseable? text
432
435
  verbose, $VERBOSE = $VERBOSE, nil
433
- eval("BEGIN {return true}\n#{text}")
436
+ catch(:valid) do
437
+ eval("BEGIN { throw :valid, true }\n#{text}")
438
+ end
434
439
  rescue SyntaxError
435
440
  false
436
441
  ensure
@@ -445,4 +450,3 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
445
450
  end
446
451
 
447
452
  end
448
-
@@ -42,6 +42,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
42
42
  @cross_reference = RDoc::CrossReference.new @context
43
43
  end
44
44
 
45
+ # :nodoc:
45
46
  def init_link_notation_regexp_handlings
46
47
  add_regexp_handling_RDOCLINK
47
48
 
@@ -62,8 +63,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
62
63
 
63
64
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
64
65
 
65
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
66
- text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
66
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
67
+ text ||= [CGI.unescape($'), (" at <code>#{$1}</code>" if $~.begin(1))].join("")
67
68
  code = false
68
69
  else
69
70
  text ||= name
@@ -138,39 +139,37 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
138
139
  # Creates an HTML link to +name+ with the given +text+.
139
140
 
140
141
  def link name, text, code = true
141
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
142
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
142
143
  name = $1
143
144
  label = $'
144
145
  end
145
146
 
146
- ref = @cross_reference.resolve name, text
147
+ ref = @cross_reference.resolve name, text if name
147
148
 
148
149
  case ref
149
150
  when String then
150
151
  ref
151
152
  else
152
- path = ref.as_href @from_path
153
+ path = ref ? ref.as_href(@from_path) : +""
153
154
 
154
155
  if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
155
156
  text = "<code>#{CGI.escapeHTML text}</code>"
156
157
  end
157
158
 
158
- if path =~ /#/ then
159
- path << "-label-#{label}"
160
- elsif ref.sections and
161
- ref.sections.any? { |section| label == section.title } then
162
- path << "##{label}"
163
- else
164
- if ref.respond_to?(:aref)
159
+ if label
160
+ if path =~ /#/
161
+ path << "-label-#{label}"
162
+ elsif ref&.sections&.any? { |section| label == section.title }
163
+ path << "##{label}"
164
+ elsif ref.respond_to?(:aref)
165
165
  path << "##{ref.aref}-label-#{label}"
166
166
  else
167
167
  path << "#label-#{label}"
168
168
  end
169
- end if label
169
+ end
170
170
 
171
171
  "<a href=\"#{path}\">#{text}</a>"
172
172
  end
173
173
  end
174
174
 
175
175
  end
176
-
@@ -66,6 +66,9 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
66
66
 
67
67
  alias accept_rule ignore
68
68
 
69
+ ##
70
+ # Adds +paragraph+ to the output
71
+
69
72
  def accept_paragraph paragraph
70
73
  para = @in_list_entry.last || "<p>"
71
74
 
@@ -282,4 +285,3 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
282
285
  end
283
286
 
284
287
  end
285
-