rdoc 6.0.0.beta3 → 6.0.0.beta4

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/Rakefile +5 -2
  5. data/lib/rdoc.rb +2 -3
  6. data/lib/rdoc/alias.rb +1 -1
  7. data/lib/rdoc/anon_class.rb +1 -1
  8. data/lib/rdoc/any_method.rb +7 -7
  9. data/lib/rdoc/attr.rb +1 -1
  10. data/lib/rdoc/class_module.rb +4 -2
  11. data/lib/rdoc/code_object.rb +2 -2
  12. data/lib/rdoc/code_objects.rb +1 -1
  13. data/lib/rdoc/comment.rb +20 -10
  14. data/lib/rdoc/constant.rb +1 -1
  15. data/lib/rdoc/context.rb +3 -3
  16. data/lib/rdoc/context/section.rb +2 -2
  17. data/lib/rdoc/cross_reference.rb +1 -1
  18. data/lib/rdoc/encoding.rb +40 -18
  19. data/lib/rdoc/erb_partial.rb +1 -1
  20. data/lib/rdoc/erbio.rb +1 -1
  21. data/lib/rdoc/extend.rb +1 -1
  22. data/lib/rdoc/generator.rb +1 -1
  23. data/lib/rdoc/generator/darkfish.rb +48 -21
  24. data/lib/rdoc/generator/json_index.rb +2 -2
  25. data/lib/rdoc/generator/markup.rb +1 -1
  26. data/lib/rdoc/generator/pot.rb +1 -1
  27. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  28. data/lib/rdoc/generator/pot/po.rb +3 -3
  29. data/lib/rdoc/generator/pot/po_entry.rb +11 -11
  30. data/lib/rdoc/generator/ri.rb +1 -1
  31. data/lib/rdoc/ghost_method.rb +1 -1
  32. data/lib/rdoc/i18n.rb +1 -1
  33. data/lib/rdoc/i18n/locale.rb +1 -1
  34. data/lib/rdoc/i18n/text.rb +5 -5
  35. data/lib/rdoc/include.rb +1 -1
  36. data/lib/rdoc/known_classes.rb +1 -1
  37. data/lib/rdoc/markdown.kpeg +71 -41
  38. data/lib/rdoc/markdown/entities.rb +1 -1
  39. data/lib/rdoc/markdown/literals.kpeg +1 -0
  40. data/lib/rdoc/markdown/literals.rb +18 -7
  41. data/lib/rdoc/markup.rb +1 -1
  42. data/lib/rdoc/markup/attr_changer.rb +1 -1
  43. data/lib/rdoc/markup/attr_span.rb +1 -1
  44. data/lib/rdoc/markup/attribute_manager.rb +2 -2
  45. data/lib/rdoc/markup/attributes.rb +1 -1
  46. data/lib/rdoc/markup/blank_line.rb +1 -1
  47. data/lib/rdoc/markup/block_quote.rb +1 -1
  48. data/lib/rdoc/markup/document.rb +1 -1
  49. data/lib/rdoc/markup/formatter.rb +1 -1
  50. data/lib/rdoc/markup/formatter_test_case.rb +1 -1
  51. data/lib/rdoc/markup/hard_break.rb +1 -1
  52. data/lib/rdoc/markup/heading.rb +1 -1
  53. data/lib/rdoc/markup/include.rb +1 -1
  54. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  55. data/lib/rdoc/markup/inline.rb +1 -1
  56. data/lib/rdoc/markup/list.rb +1 -1
  57. data/lib/rdoc/markup/list_item.rb +1 -1
  58. data/lib/rdoc/markup/paragraph.rb +1 -1
  59. data/lib/rdoc/markup/parser.rb +3 -3
  60. data/lib/rdoc/markup/pre_process.rb +9 -5
  61. data/lib/rdoc/markup/raw.rb +1 -1
  62. data/lib/rdoc/markup/rule.rb +1 -1
  63. data/lib/rdoc/markup/special.rb +1 -1
  64. data/lib/rdoc/markup/text_formatter_test_case.rb +1 -1
  65. data/lib/rdoc/markup/to_ansi.rb +1 -1
  66. data/lib/rdoc/markup/to_bs.rb +1 -1
  67. data/lib/rdoc/markup/to_html.rb +1 -1
  68. data/lib/rdoc/markup/to_html_crossref.rb +1 -1
  69. data/lib/rdoc/markup/to_html_snippet.rb +1 -1
  70. data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
  71. data/lib/rdoc/markup/to_label.rb +1 -1
  72. data/lib/rdoc/markup/to_markdown.rb +1 -1
  73. data/lib/rdoc/markup/to_rdoc.rb +1 -1
  74. data/lib/rdoc/markup/to_table_of_contents.rb +1 -1
  75. data/lib/rdoc/markup/to_test.rb +1 -1
  76. data/lib/rdoc/markup/to_tt_only.rb +1 -1
  77. data/lib/rdoc/markup/verbatim.rb +1 -1
  78. data/lib/rdoc/meta_method.rb +1 -1
  79. data/lib/rdoc/method_attr.rb +2 -2
  80. data/lib/rdoc/mixin.rb +1 -1
  81. data/lib/rdoc/normal_class.rb +3 -3
  82. data/lib/rdoc/normal_module.rb +1 -1
  83. data/lib/rdoc/options.rb +6 -6
  84. data/lib/rdoc/parser.rb +1 -1
  85. data/lib/rdoc/parser/c.rb +6 -6
  86. data/lib/rdoc/parser/changelog.rb +5 -5
  87. data/lib/rdoc/parser/markdown.rb +1 -1
  88. data/lib/rdoc/parser/rd.rb +1 -1
  89. data/lib/rdoc/parser/ripper_state_lex.rb +26 -8
  90. data/lib/rdoc/parser/ruby.rb +36 -42
  91. data/lib/rdoc/parser/ruby_tools.rb +2 -3
  92. data/lib/rdoc/parser/simple.rb +3 -3
  93. data/lib/rdoc/parser/text.rb +1 -1
  94. data/lib/rdoc/rd.rb +1 -1
  95. data/lib/rdoc/rd/block_parser.ry +2 -2
  96. data/lib/rdoc/rd/inline.rb +5 -5
  97. data/lib/rdoc/rd/inline_parser.ry +1 -1
  98. data/lib/rdoc/rdoc.rb +12 -7
  99. data/lib/rdoc/require.rb +1 -1
  100. data/lib/rdoc/ri.rb +1 -1
  101. data/lib/rdoc/ri/driver.rb +1 -1
  102. data/lib/rdoc/ri/formatter.rb +1 -1
  103. data/lib/rdoc/ri/paths.rb +1 -1
  104. data/lib/rdoc/ri/store.rb +1 -1
  105. data/lib/rdoc/ri/task.rb +1 -1
  106. data/lib/rdoc/rubygems_hook.rb +1 -1
  107. data/lib/rdoc/servlet.rb +2 -2
  108. data/lib/rdoc/single_class.rb +1 -1
  109. data/lib/rdoc/stats.rb +1 -1
  110. data/lib/rdoc/stats/normal.rb +2 -2
  111. data/lib/rdoc/stats/quiet.rb +1 -1
  112. data/lib/rdoc/stats/verbose.rb +1 -1
  113. data/lib/rdoc/store.rb +1 -1
  114. data/lib/rdoc/task.rb +1 -1
  115. data/lib/rdoc/test_case.rb +3 -4
  116. data/lib/rdoc/text.rb +7 -7
  117. data/lib/rdoc/token_stream.rb +15 -7
  118. data/lib/rdoc/tom_doc.rb +2 -2
  119. data/lib/rdoc/top_level.rb +1 -1
  120. data/rdoc.gemspec +3 -3
  121. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f0664803866527a745f0bd9497407b3fb2efecff918b205368ad1c429a63954
4
- data.tar.gz: 98336bc89aab5c3b779b518a8a51b5dd4d48fbc9c592cf5b57b41d8876c725e1
3
+ metadata.gz: 342dd946b79ae94f39a4d57825de50df2faa0115c34ce84bf2db00b6afa03429
4
+ data.tar.gz: e6ca1cfa9be24f43cf9df81b206d5e035e817e36a6841158ef583ac93175047b
5
5
  SHA512:
6
- metadata.gz: a4602b0b46be7eec1d5efbdbdb9dc029b6e0bdd074c3a513dae02c9fb227bf9faadc7cbfefb6423531f3b9939116534d3f24ec63c4d48964c96a16607814aa2a
7
- data.tar.gz: 67e6b12048e14cacf0f96b6480b63acf90348990fc28f1bc34ed7c2df42375c56c3ee44a9ad30ae5f6b7d462ea35b7f1e5ead35b64e80bc077c6ec1dee2bcc66
6
+ metadata.gz: 8ffbc7917d2f6d11e3a3f8c6d5a98e5ff774afdc499caa0ca98c2ecb62e2008eda64b8478dcbf67e8fa5de5e8bf51ba766354455db7f8fef1e4e5d42822a63dd
7
+ data.tar.gz: 39552e0dd1cad025fbcce9cf1cf7220e74f29dd8f74e67f84a6f468ed8f9121e97169e4047e72b03639fc9937ace4b6e2d5652dcfe9ec1bfd9a1c299d60c34a5
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /lib/rdoc/rd/block_parser.rb
9
9
  /lib/rdoc/rd/inline_parser.rb
10
10
  /lib/rdoc/markdown.rb
11
+ /lib/rdoc/markdown/literals.rb
11
12
  /pkg
12
13
  /tmp
13
14
  Gemfile.lock
@@ -7,7 +7,7 @@ rvm:
7
7
  - 2.3.5
8
8
  - 2.4.2
9
9
  - ruby-head
10
- - jruby-9.1.13.0
10
+ - jruby-9.1.14.0
11
11
  env:
12
12
  global:
13
13
  NOBENCHMARK=1
data/Rakefile CHANGED
@@ -63,6 +63,11 @@ parsed_files = PARSER_FILES.map do |parser_file|
63
63
  racc = Gem.bin_path 'racc', 'racc'
64
64
  rb_file = parser_file.gsub(/\.ry\z/, ".rb")
65
65
  ruby "#{racc} -l -o #{rb_file} #{parser_file}"
66
+ open(rb_file, 'r+') do |f|
67
+ newtext = "# frozen_string_literal: true\n#{f.read}"
68
+ f.rewind
69
+ f.write newtext
70
+ end
66
71
  elsif parser_file =~ /\.kpeg\z/ # need kpeg
67
72
  kpeg = Gem.bin_path 'kpeg', 'kpeg'
68
73
  rb_file = parser_file.gsub(/\.kpeg\z/, ".rb")
@@ -104,8 +109,6 @@ end
104
109
 
105
110
  desc "Diffs Ruby HEAD with the currently checked-out copy of RDoc."
106
111
  task :diff_ruby do
107
- options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
108
-
109
112
  sh "diff #{diff_options} bin/rdoc #{ruby_dir}/bin/rdoc; true"
110
113
  sh "diff #{diff_options} bin/ri #{ruby_dir}/bin/ri; true"
111
114
  sh "diff #{diff_options} lib/rdoc.rb #{ruby_dir}/lib/rdoc.rb; true"
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  $DEBUG_RDOC = nil
3
3
 
4
4
  # :main: README.rdoc
@@ -65,7 +65,7 @@ module RDoc
65
65
  ##
66
66
  # RDoc version you are using
67
67
 
68
- VERSION = '6.0.0.beta3'
68
+ VERSION = '6.0.0.beta4'
69
69
 
70
70
  ##
71
71
  # Method visibilities
@@ -149,7 +149,6 @@ module RDoc
149
149
  autoload :KNOWN_CLASSES, 'rdoc/known_classes'
150
150
 
151
151
  autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
152
- autoload :RubyToken, 'rdoc/ruby_token'
153
152
  autoload :TokenStream, 'rdoc/token_stream'
154
153
 
155
154
  autoload :Comment, 'rdoc/comment'
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # Represent an alias, which is an old_name/new_name pair associated with a
4
4
  # particular context
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # An anonymous class like:
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # AnyMethod is the base class for objects representing methods
4
4
 
@@ -244,9 +244,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
244
244
  if @block_params then
245
245
  # If this method has explicit block parameters, remove any explicit
246
246
  # &block
247
- params.sub!(/,?\s*&\w+/, '')
247
+ params = params.sub(/,?\s*&\w+/, '')
248
248
  else
249
- params.sub!(/\&(\w+)/, '\1')
249
+ params = params.sub(/\&(\w+)/, '\1')
250
250
  end
251
251
 
252
252
  params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
@@ -265,7 +265,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
265
265
  params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
266
266
  elsif @params then
267
267
  params = @params.gsub(/\s*\#.*/, '')
268
- params = params.tr("\n", " ").squeeze(" ")
268
+ params = params.tr_s("\n ", " ")
269
269
  params = "(#{params})" unless params[0] == ?(
270
270
  else
271
271
  params = ''
@@ -274,11 +274,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
274
274
  if @block_params then
275
275
  # If this method has explicit block parameters, remove any explicit
276
276
  # &block
277
- params.sub!(/,?\s*&\w+/, '')
277
+ params = params.sub(/,?\s*&\w+/, '')
278
278
 
279
- block = @block_params.tr("\n", " ").squeeze(" ")
279
+ block = @block_params.tr_s("\n ", " ")
280
280
  if block[0] == ?(
281
- block.sub!(/^\(/, '').sub!(/\)/, '')
281
+ block = block.sub(/^\(/, '').sub(/\)/, '')
282
282
  end
283
283
  params << " { |#{block}| ... }"
284
284
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # An attribute created by \#attr, \#attr_reader, \#attr_writer or
4
4
  # \#attr_accessor
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # ClassModule is the base class for objects representing either a class or a
4
4
  # module.
@@ -136,7 +136,9 @@ class RDoc::ClassModule < RDoc::Context
136
136
  normalize_comment comment
137
137
  end
138
138
 
139
- @comment_location.delete_if { |(_, l)| l == location }
139
+ if location.parser == RDoc::Parser::C
140
+ @comment_location.delete_if { |(_, l)| l == location }
141
+ end
140
142
 
141
143
  @comment_location << [comment, location]
142
144
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # Base class for the RDoc code tree.
4
4
  #
@@ -144,7 +144,7 @@ class RDoc::CodeObject
144
144
  # HACK correct fix is to have #initialize create @comment
145
145
  # with the correct encoding
146
146
  if String === @comment and @comment.empty? then
147
- @comment.force_encoding comment.encoding
147
+ @comment = RDoc::Encoding.change_encoding @comment, comment.encoding
148
148
  end
149
149
  @comment
150
150
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  # This file was used to load all the RDoc::CodeObject subclasses at once. Now
3
3
  # autoload handles this.
4
4
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A comment holds the text comment for a RDoc::CodeObject and provides a
4
4
  # unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
@@ -45,7 +45,7 @@ class RDoc::Comment
45
45
 
46
46
  def initialize text = nil, location = nil
47
47
  @location = location
48
- @text = text
48
+ @text = text.nil? ? nil : text.dup
49
49
 
50
50
  @document = nil
51
51
  @format = 'rdoc'
@@ -114,10 +114,14 @@ class RDoc::Comment
114
114
 
115
115
  method.call_seq = seq.chomp
116
116
 
117
- elsif @text.sub!(/^\s*:?call-seq:(.*?)(^\s*$|\z)/m, '') then
118
- seq = $1
119
- seq.gsub!(/^\s*/, '')
120
- method.call_seq = seq
117
+ else
118
+ regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
119
+ if regexp =~ @text then
120
+ @text = @text.sub(regexp, '')
121
+ seq = $1
122
+ seq.gsub!(/^\s*/, '')
123
+ method.call_seq = seq
124
+ end
121
125
  end
122
126
 
123
127
  method
@@ -133,8 +137,14 @@ class RDoc::Comment
133
137
  ##
134
138
  # HACK dubious
135
139
 
136
- def force_encoding encoding
137
- @text.force_encoding encoding
140
+ def encode! encoding
141
+ # TODO: Remove this condition after Ruby 2.2 EOL
142
+ if RUBY_VERSION < '2.3.0'
143
+ @text = @text.force_encoding encoding
144
+ else
145
+ @text = String.new @text, encoding: encoding
146
+ end
147
+ self
138
148
  end
139
149
 
140
150
  ##
@@ -200,7 +210,7 @@ class RDoc::Comment
200
210
  def remove_private
201
211
  # Workaround for gsub encoding for Ruby 1.9.2 and earlier
202
212
  empty = ''
203
- empty.force_encoding @text.encoding
213
+ empty = RDoc::Encoding.change_encoding empty, @text.encoding
204
214
 
205
215
  @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
206
216
  @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
@@ -216,7 +226,7 @@ class RDoc::Comment
216
226
  @text.nil? and @document
217
227
 
218
228
  @document = nil
219
- @text = text
229
+ @text = text.nil? ? nil : text.dup
220
230
  end
221
231
 
222
232
  ##
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A constant
4
4
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  require 'cgi'
3
3
 
4
4
  ##
@@ -239,7 +239,7 @@ class RDoc::Context < RDoc::CodeObject
239
239
 
240
240
  if known then
241
241
  known.comment = attribute.comment if known.comment.empty?
242
- elsif registered = @methods_hash[attribute.pretty_name << '='] and
242
+ elsif registered = @methods_hash[attribute.pretty_name + '='] and
243
243
  RDoc::Attr === registered then
244
244
  registered.rw = 'RW'
245
245
  else
@@ -249,7 +249,7 @@ class RDoc::Context < RDoc::CodeObject
249
249
  end
250
250
 
251
251
  if attribute.rw.index 'W' then
252
- key = attribute.pretty_name << '='
252
+ key = attribute.pretty_name + '='
253
253
  known = @methods_hash[key]
254
254
 
255
255
  if known then
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A section of documentation like:
4
4
  #
@@ -43,7 +43,7 @@ class RDoc::Context::Section
43
43
  @parent = parent
44
44
  @title = title ? title.strip : title
45
45
 
46
- @@sequence.succ!
46
+ @@sequence = @@sequence.succ
47
47
  @sequence = @@sequence.dup
48
48
 
49
49
  @comments = []
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # RDoc::CrossReference is a reusable way to create cross references for names.
4
4
 
@@ -1,5 +1,5 @@
1
1
  # coding: US-ASCII
2
- # frozen_string_literal: false
2
+ # frozen_string_literal: true
3
3
 
4
4
  ##
5
5
  # This class is a wrapper around File IO and Encoding that helps RDoc load
@@ -23,26 +23,26 @@ module RDoc::Encoding
23
23
 
24
24
  utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
25
25
 
26
- RDoc::Encoding.set_encoding content
26
+ content = RDoc::Encoding.set_encoding content
27
27
 
28
28
  begin
29
29
  encoding ||= Encoding.default_external
30
30
  orig_encoding = content.encoding
31
31
 
32
32
  if not orig_encoding.ascii_compatible? then
33
- content.encode! encoding
33
+ content = content.encode encoding
34
34
  elsif utf8 then
35
- content.force_encoding Encoding::UTF_8
36
- content.encode! encoding
35
+ content = RDoc::Encoding.change_encoding content, Encoding::UTF_8
36
+ content = content.encode encoding
37
37
  else
38
38
  # assume the content is in our output encoding
39
- content.force_encoding encoding
39
+ content = RDoc::Encoding.change_encoding content, encoding
40
40
  end
41
41
 
42
42
  unless content.valid_encoding? then
43
43
  # revert and try to transcode
44
- content.force_encoding orig_encoding
45
- content.encode! encoding
44
+ content = RDoc::Encoding.change_encoding content, orig_encoding
45
+ content = content.encode encoding
46
46
  end
47
47
 
48
48
  unless content.valid_encoding? then
@@ -52,10 +52,11 @@ module RDoc::Encoding
52
52
  rescue Encoding::InvalidByteSequenceError,
53
53
  Encoding::UndefinedConversionError => e
54
54
  if force_transcode then
55
- content.force_encoding orig_encoding
56
- content.encode!(encoding,
57
- :invalid => :replace, :undef => :replace,
58
- :replace => '?')
55
+ content = RDoc::Encoding.change_encoding content, orig_encoding
56
+ content = content.encode(encoding,
57
+ :invalid => :replace,
58
+ :undef => :replace,
59
+ :replace => '?')
59
60
  return content
60
61
  else
61
62
  warn "unable to convert #{e.message} for #{filename}, skipping"
@@ -77,15 +78,17 @@ module RDoc::Encoding
77
78
  first_line = $1
78
79
 
79
80
  if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
80
- string.sub! first_line, ''
81
+ string = string.sub first_line, ''
81
82
  end
83
+
84
+ string
82
85
  end
83
86
 
84
87
  ##
85
88
  # Sets the encoding of +string+ based on the magic comment
86
89
 
87
90
  def self.set_encoding string
88
- remove_frozen_string_literal string
91
+ string = remove_frozen_string_literal string
89
92
 
90
93
  string =~ /\A(?:#!.*\n)?(.*\n)/
91
94
 
@@ -94,15 +97,34 @@ module RDoc::Encoding
94
97
  name = case first_line
95
98
  when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2
96
99
  when /\b(?:en)?coding[=:]\s*([^\s;]+)/i then $1
97
- else return
100
+ else return string
98
101
  end
99
102
 
100
- string.sub! first_line, ''
103
+ string = string.sub first_line, ''
101
104
 
102
- remove_frozen_string_literal string
105
+ string = remove_frozen_string_literal string
103
106
 
104
107
  enc = Encoding.find name
105
- string.force_encoding enc if enc
108
+ string = RDoc::Encoding.change_encoding string, enc if enc
109
+
110
+ string
111
+ end
112
+
113
+ ##
114
+ # Changes encoding based on +encoding+ without converting and returns new
115
+ # string
116
+
117
+ def self.change_encoding text, encoding
118
+ if text.kind_of? RDoc::Comment
119
+ text.encode! encoding
120
+ else
121
+ # TODO: Remove this condition after Ruby 2.2 EOL
122
+ if RUBY_VERSION < '2.3.0'
123
+ text.force_encoding encoding
124
+ else
125
+ String.new text, encoding: encoding
126
+ end
127
+ end
106
128
  end
107
129
 
108
130
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # Allows an ERB template to be rendered in the context (binding) of an
4
4
  # existing ERB template evaluation.
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  require 'erb'
3
3
 
4
4
  ##
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A Module extension to a class with \#extend
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # RDoc uses generators to turn parsed source code in the form of an
4
4
  # RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  # -*- mode: ruby; ruby-indent-level: 2; tab-width: 2 -*-
3
3
 
4
4
  require 'erb'
@@ -313,12 +313,16 @@ class RDoc::Generator::Darkfish
313
313
  search_index_rel_prefix = rel_prefix
314
314
  search_index_rel_prefix += @asset_rel_path if @file_output
315
315
 
316
- # suppress 1.9.3 warning
317
- asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
316
+ asset_rel_prefix = rel_prefix + @asset_rel_path
318
317
 
319
318
  @title = @options.title
320
319
 
321
- render_template template_file, out_file do |io| binding end
320
+ render_template template_file, out_file do |io|
321
+ here = binding
322
+ # suppress 1.9.3 warning
323
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
324
+ here
325
+ end
322
326
  rescue => e
323
327
  error = RDoc::Error.new \
324
328
  "error generating index.html: #{e.message} (#{e.class})"
@@ -343,14 +347,19 @@ class RDoc::Generator::Darkfish
343
347
  search_index_rel_prefix = rel_prefix
344
348
  search_index_rel_prefix += @asset_rel_path if @file_output
345
349
 
346
- # suppress 1.9.3 warning
347
- asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
348
- svninfo = svninfo = get_svninfo(current)
350
+ asset_rel_prefix = rel_prefix + @asset_rel_path
351
+ svninfo = get_svninfo(current)
349
352
 
350
353
  @title = "#{klass.type} #{klass.full_name} - #{@options.title}"
351
354
 
352
355
  debug_msg " rendering #{out_file}"
353
- render_template template_file, out_file do |io| binding end
356
+ render_template template_file, out_file do |io|
357
+ here = binding
358
+ # suppress 1.9.3 warning
359
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
360
+ here.local_variable_set(:svninfo, svninfo)
361
+ here
362
+ end
354
363
  end
355
364
 
356
365
  ##
@@ -416,8 +425,7 @@ class RDoc::Generator::Darkfish
416
425
  search_index_rel_prefix = rel_prefix
417
426
  search_index_rel_prefix += @asset_rel_path if @file_output
418
427
 
419
- # suppress 1.9.3 warning
420
- asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
428
+ asset_rel_prefix = rel_prefix + @asset_rel_path
421
429
 
422
430
  unless filepage_file then
423
431
  if file.text? then
@@ -434,7 +442,13 @@ class RDoc::Generator::Darkfish
434
442
  @title += " - #{@options.title}"
435
443
  template_file ||= filepage_file
436
444
 
437
- render_template template_file, out_file do |io| binding end
445
+ render_template template_file, out_file do |io|
446
+ here = binding
447
+ # suppress 1.9.3 warning
448
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
449
+ here.local_variable_set(:current, current)
450
+ here
451
+ end
438
452
  end
439
453
  rescue => e
440
454
  error =
@@ -458,14 +472,19 @@ class RDoc::Generator::Darkfish
458
472
  search_index_rel_prefix = rel_prefix
459
473
  search_index_rel_prefix += @asset_rel_path if @file_output
460
474
 
461
- # suppress 1.9.3 warning
462
- current = current = file
463
- asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
475
+ current = file
476
+ asset_rel_prefix = rel_prefix + @asset_rel_path
464
477
 
465
478
  @title = "#{file.page_name} - #{@options.title}"
466
479
 
467
480
  debug_msg " rendering #{out_file}"
468
- render_template template_file, out_file do |io| binding end
481
+ render_template template_file, out_file do |io|
482
+ here = binding
483
+ # suppress 1.9.3 warning
484
+ here.local_variable_set(:current, current)
485
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
486
+ here
487
+ end
469
488
  end
470
489
 
471
490
  ##
@@ -483,12 +502,16 @@ class RDoc::Generator::Darkfish
483
502
  search_index_rel_prefix = rel_prefix
484
503
  search_index_rel_prefix += @asset_rel_path if @file_output
485
504
 
486
- # suppress 1.9.3 warning
487
- asset_rel_prefix = asset_rel_prefix = ''
505
+ asset_rel_prefix = ''
488
506
 
489
507
  @title = 'Not Found'
490
508
 
491
- render_template template_file do |io| binding end
509
+ render_template template_file do |io|
510
+ here = binding
511
+ # suppress 1.9.3 warning
512
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
513
+ here
514
+ end
492
515
  rescue => e
493
516
  error = RDoc::Error.new \
494
517
  "error generating servlet_not_found: #{e.message} (#{e.class})"
@@ -540,12 +563,16 @@ class RDoc::Generator::Darkfish
540
563
  search_index_rel_prefix = rel_prefix
541
564
  search_index_rel_prefix += @asset_rel_path if @file_output
542
565
 
543
- # suppress 1.9.3 warning
544
- asset_rel_prefix = asset_rel_prefix = rel_prefix + @asset_rel_path
566
+ asset_rel_prefix = rel_prefix + @asset_rel_path
545
567
 
546
568
  @title = "Table of Contents - #{@options.title}"
547
569
 
548
- render_template template_file, out_file do |io| binding end
570
+ render_template template_file, out_file do |io|
571
+ here = binding
572
+ # suppress 1.9.3 warning
573
+ here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
574
+ here
575
+ end
549
576
  rescue => e
550
577
  error = RDoc::Error.new \
551
578
  "error generating table_of_contents.html: #{e.message} (#{e.class})"