rdoc 6.0.4 → 6.1.0.beta1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73cda21536da8aea204eec25054f346a21e97c1d16f7b8f43b7db552398e0a38
4
- data.tar.gz: 3cfb14465a6bee87b00f470fb632e5557d84f623d84c90b7fcf0e37021667887
3
+ metadata.gz: 89e2fd9301cffd5438098b0666fbce4b53a02769e9a442853ee1b0a055267f30
4
+ data.tar.gz: 8177c1c7f3e5cb944b8427a9f57147fc36aedb225342c3b3b08b723e44c53775
5
5
  SHA512:
6
- metadata.gz: ff1a36f399c5e3c3e3e833853c6ce27fe6886c6d09b0ba81e07b8d351cd339c7f120d0bd21691c792a2a7e63d323fece44ce8566b9d76e343b1aed3671fa7b3f
7
- data.tar.gz: 50da0ecbb101c3104ff5a0bf7644fdb2db7758a6ad6243075b4b5180ba3175b20fcb3848ad47861794b4ba5ec6168d956579e939ed94dd7b53c0afc51e06a685
6
+ metadata.gz: 92f7944e6864801b64ca4dd5ccf7e1b1f6fecc84c10c52a9fb682a859968f588ed5a2205570f43d402ce45c38a01107e23f88972449185b04e2e56f580758d73
7
+ data.tar.gz: c98e04a271ccc6354e5b7000f652fe289a887d2684dc57367a3eb0dfd8270fada871ee0167e1942843232b75bd06db7f084881fb29cc437cd761668ec8b4ffbe
@@ -4,16 +4,17 @@ before_install:
4
4
  - gem update bundler
5
5
  language: ruby
6
6
  rvm:
7
- - 2.2.9
8
- - 2.3.6
9
- - 2.4.3
10
- - 2.5.0
7
+ - 2.3.7
8
+ - 2.4.4
9
+ - 2.5.1
11
10
  - ruby-head
12
- - jruby-9.1.16.0
11
+ - jruby-9.1.17.0
12
+ - jruby-9.2.0.0
13
13
  env:
14
14
  global:
15
15
  NOBENCHMARK=1
16
16
  script: rake
17
17
  matrix:
18
18
  allow_failures:
19
- - rvm: jruby-9.1.16.0
19
+ - rvm: jruby-9.1.17.0
20
+ - rvm: jruby-9.2.0.0
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ $:.unshift File.expand_path 'lib'
2
2
  require 'rdoc/task'
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
+ require 'rubocop/rake_task'
5
6
 
6
7
  task :docs => :generate
7
8
  task :test => :generate
@@ -80,7 +81,11 @@ end
80
81
 
81
82
  task "#{path}.gem" => package_parser_files
82
83
 
84
+ RuboCop::RakeTask.new(:rubocop) do |t|
85
+ t.options = [*parsed_files]
86
+ end
87
+
83
88
  desc "Genrate all files used racc and kpeg"
84
89
  task :generate => parsed_files
85
90
 
86
- task :build => [:generate]
91
+ task :build => [:generate, "rubocop:auto_correct"]
@@ -62,10 +62,7 @@ module RDoc
62
62
 
63
63
  class Error < RuntimeError; end
64
64
 
65
- ##
66
- # RDoc version you are using
67
-
68
- VERSION = '6.0.4'
65
+ require 'rdoc/version'
69
66
 
70
67
  ##
71
68
  # Method visibilities
@@ -146,7 +143,6 @@ module RDoc
146
143
 
147
144
  autoload :KNOWN_CLASSES, 'rdoc/known_classes'
148
145
 
149
- autoload :RipperStateLex, 'rdoc/parser/ripper_state_lex'
150
146
  autoload :TokenStream, 'rdoc/token_stream'
151
147
 
152
148
  autoload :Comment, 'rdoc/comment'
@@ -19,12 +19,12 @@ class RDoc::CrossReference
19
19
  #
20
20
  # See CLASS_REGEXP_STR
21
21
 
22
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>)(?:\([\w.+*/=<>-]*\))?'
22
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
23
23
 
24
24
  ##
25
25
  # Regular expressions matching text that should potentially have
26
- # cross-reference links generated are passed to add_special. Note that
27
- # these expressions are meant to pick up text for which cross-references
26
+ # cross-reference links generated are passed to add_regexp_handling. Note
27
+ # that these expressions are meant to pick up text for which cross-references
28
28
  # have been suppressed, since the suppression characters are removed by the
29
29
  # code that is triggered.
30
30
 
@@ -127,23 +127,41 @@ class RDoc::CrossReference
127
127
 
128
128
  if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
129
129
  type = $2
130
- type = '' if type == '.' # will find either #method or ::method
131
- method = "#{type}#{$3}"
130
+ if '.' == type # will find either #method or ::method
131
+ method = $3
132
+ else
133
+ method = "#{type}#{$3}"
134
+ end
132
135
  container = @context.find_symbol_module($1)
133
136
  elsif /^([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
134
137
  type = $1
135
- type = '' if type == '.'
136
- method = "#{type}#{$2}"
138
+ if '.' == type
139
+ method = $2
140
+ else
141
+ method = "#{type}#{$2}"
142
+ end
137
143
  container = @context
138
144
  else
145
+ type = nil
139
146
  container = nil
140
147
  end
141
148
 
142
149
  if container then
143
- ref = container.find_local_symbol method
144
-
145
- unless ref || RDoc::TopLevel === container then
146
- ref = container.find_ancestor_local_symbol method
150
+ unless RDoc::TopLevel === container then
151
+ if '.' == type then
152
+ if 'new' == method then # AnyClassName.new will be class method
153
+ ref = container.find_local_symbol method
154
+ ref = container.find_ancestor_local_symbol method unless ref
155
+ else
156
+ ref = container.find_local_symbol "::#{method}"
157
+ ref = container.find_ancestor_local_symbol "::#{method}" unless ref
158
+ ref = container.find_local_symbol "##{method}" unless ref
159
+ ref = container.find_ancestor_local_symbol "##{method}" unless ref
160
+ end
161
+ else
162
+ ref = container.find_local_symbol method
163
+ ref = container.find_ancestor_local_symbol method unless ref
164
+ end
147
165
  end
148
166
  end
149
167
 
@@ -65,16 +65,6 @@ end
65
65
 
66
66
  class RDoc::MethodAttr
67
67
 
68
- @add_line_numbers = false
69
-
70
- class << self
71
- ##
72
- # Allows controlling whether <tt>#markup_code</tt> adds line numbers to
73
- # the source code.
74
-
75
- attr_accessor :add_line_numbers
76
- end
77
-
78
68
  ##
79
69
  # Prepend +src+ with line numbers. Relies on the first line of a source
80
70
  # code listing having:
@@ -106,7 +96,7 @@ class RDoc::MethodAttr
106
96
  ##
107
97
  # Turns the method's token stream into HTML.
108
98
  #
109
- # Prepends line numbers if +add_line_numbers+ is true.
99
+ # Prepends line numbers if +options.line_numbers+ is true.
110
100
 
111
101
  def markup_code
112
102
  return '' unless @token_stream
@@ -126,7 +116,7 @@ class RDoc::MethodAttr
126
116
  end
127
117
  src.gsub!(/^#{' ' * indent}/, '') if indent > 0
128
118
 
129
- add_line_numbers(src) if RDoc::MethodAttr.add_line_numbers
119
+ add_line_numbers(src) if options.line_numbers
130
120
 
131
121
  src
132
122
  end
@@ -59,9 +59,8 @@ Navigation = new function() {
59
59
  }
60
60
  break;
61
61
  case 13: //Event.KEY_RETURN:
62
- if (this.$current)
63
- e.preventDefault();
64
- this.select(this.$current);
62
+ if (this.$current) e.preventDefault();
63
+ this.select(this.$current);
65
64
  break;
66
65
  }
67
66
  if (e.ctrlKey && e.shiftKey) this.select(this.$current);
@@ -80,7 +79,7 @@ Navigation = new function() {
80
79
  var go = function() {
81
80
  if (!_this.moveTimeout) return;
82
81
  _this[isDown ? 'moveDown' : 'moveUp']();
83
- _this.moveTimout = setTimeout(go, 100);
82
+ _this.moveTimeout = setTimeout(go, 100);
84
83
  }
85
84
  this.moveTimeout = setTimeout(go, 200);
86
85
  }
@@ -65,17 +65,16 @@
65
65
  # puts h.convert(input_string)
66
66
  #
67
67
  # You can extend the RDoc::Markup parser to recognize new markup
68
- # sequences, and to add special processing for text that matches a
69
- # regular expression. Here we make WikiWords significant to the parser,
70
- # and also make the sequences {word} and \<no>text...</no> signify
68
+ # sequences, and to add regexp handling. Here we make WikiWords significant to
69
+ # the parser, and also make the sequences {word} and \<no>text...</no> signify
71
70
  # strike-through text. We then subclass the HTML output class to deal
72
71
  # with these:
73
72
  #
74
73
  # require 'rdoc'
75
74
  #
76
75
  # class WikiHtml < RDoc::Markup::ToHtml
77
- # def handle_special_WIKIWORD(special)
78
- # "<font color=red>" + special.text + "</font>"
76
+ # def handle_regexp_WIKIWORD(target)
77
+ # "<font color=red>" + target.text + "</font>"
79
78
  # end
80
79
  # end
81
80
  #
@@ -83,7 +82,7 @@
83
82
  # markup.add_word_pair("{", "}", :STRIKE)
84
83
  # markup.add_html("no", :STRIKE)
85
84
  #
86
- # markup.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
85
+ # markup.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
87
86
  #
88
87
  # wh = WikiHtml.new RDoc::Options.new, markup
89
88
  # wh.add_tag(:STRIKE, "<strike>", "</strike>")
@@ -800,13 +799,12 @@ https://github.com/ruby/rdoc/issues
800
799
  # Add to other inline sequences. For example, we could add WikiWords using
801
800
  # something like:
802
801
  #
803
- # parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
802
+ # parser.add_regexp_handling(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
804
803
  #
805
- # Each wiki word will be presented to the output formatter via the
806
- # accept_special method.
804
+ # Each wiki word will be presented to the output formatter.
807
805
 
808
- def add_special(pattern, name)
809
- @attribute_manager.add_special(pattern, name)
806
+ def add_regexp_handling(pattern, name)
807
+ @attribute_manager.add_regexp_handling(pattern, name)
810
808
  end
811
809
 
812
810
  ##
@@ -832,7 +830,7 @@ https://github.com/ruby/rdoc/issues
832
830
  autoload :AttrSpan, 'rdoc/markup/attr_span'
833
831
  autoload :Attributes, 'rdoc/markup/attributes'
834
832
  autoload :AttributeManager, 'rdoc/markup/attribute_manager'
835
- autoload :Special, 'rdoc/markup/special'
833
+ autoload :RegexpHandling, 'rdoc/markup/regexp_handling'
836
834
 
837
835
  # RDoc::Markup AST
838
836
  autoload :BlankLine, 'rdoc/markup/blank_line'
@@ -53,10 +53,10 @@ class RDoc::Markup::AttributeManager
53
53
  attr_reader :protectable
54
54
 
55
55
  ##
56
- # And this maps _special_ sequences to a name. A special sequence is
57
- # something like a WikiWord
56
+ # And this maps _regexp handling_ sequences to a name. A regexp handling
57
+ # sequence is something like a WikiWord
58
58
 
59
- attr_reader :special
59
+ attr_reader :regexp_handlings
60
60
 
61
61
  ##
62
62
  # Creates a new attribute manager that understands bold, emphasized and
@@ -66,7 +66,7 @@ class RDoc::Markup::AttributeManager
66
66
  @html_tags = {}
67
67
  @matching_word_pairs = {}
68
68
  @protectable = %w[<]
69
- @special = []
69
+ @regexp_handlings = []
70
70
  @word_pair_map = {}
71
71
  @attributes = RDoc::Markup::Attributes.new
72
72
 
@@ -166,22 +166,22 @@ class RDoc::Markup::AttributeManager
166
166
  end
167
167
 
168
168
  ##
169
- # Converts special sequences to RDoc attributes
169
+ # Converts regexp handling sequences to RDoc attributes
170
170
 
171
- def convert_specials str, attrs
172
- @special.each do |regexp, attribute|
171
+ def convert_regexp_handlings str, attrs
172
+ @regexp_handlings.each do |regexp, attribute|
173
173
  str.scan(regexp) do
174
174
  capture = $~.size == 1 ? 0 : 1
175
175
 
176
176
  s, e = $~.offset capture
177
177
 
178
- attrs.set_attrs s, e - s, attribute | @attributes.special
178
+ attrs.set_attrs s, e - s, attribute | @attributes.regexp_handling
179
179
  end
180
180
  end
181
181
  end
182
182
 
183
183
  ##
184
- # Escapes special sequences of text to prevent conversion to RDoc
184
+ # Escapes regexp handling sequences of text to prevent conversion to RDoc
185
185
 
186
186
  def mask_protected_sequences
187
187
  # protect __send__, __FILE__, etc.
@@ -193,7 +193,7 @@ class RDoc::Markup::AttributeManager
193
193
  end
194
194
 
195
195
  ##
196
- # Unescapes special sequences of text
196
+ # Unescapes regexp handling sequences of text
197
197
 
198
198
  def unmask_protected_sequences
199
199
  @str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
@@ -233,17 +233,17 @@ class RDoc::Markup::AttributeManager
233
233
  end
234
234
 
235
235
  ##
236
- # Adds a special handler for +pattern+ with +name+. A simple URL handler
236
+ # Adds a regexp handling for +pattern+ with +name+. A simple URL handler
237
237
  # would be:
238
238
  #
239
- # @am.add_special(/((https?:)\S+\w)/, :HYPERLINK)
239
+ # @am.add_regexp_handling(/((https?:)\S+\w)/, :HYPERLINK)
240
240
 
241
- def add_special pattern, name
242
- @special << [pattern, @attributes.bitmap_for(name)]
241
+ def add_regexp_handling pattern, name
242
+ @regexp_handlings << [pattern, @attributes.bitmap_for(name)]
243
243
  end
244
244
 
245
245
  ##
246
- # Processes +str+ converting attributes, HTML and specials
246
+ # Processes +str+ converting attributes, HTML and regexp handlings
247
247
 
248
248
  def flow str
249
249
  @str = str.dup
@@ -252,9 +252,9 @@ class RDoc::Markup::AttributeManager
252
252
 
253
253
  @attrs = RDoc::Markup::AttrSpan.new @str.length
254
254
 
255
- convert_attrs @str, @attrs
256
- convert_html @str, @attrs
257
- convert_specials @str, @attrs
255
+ convert_attrs @str, @attrs
256
+ convert_html @str, @attrs
257
+ convert_regexp_handlings @str, @attrs
258
258
 
259
259
  unmask_protected_sequences
260
260
 
@@ -312,12 +312,12 @@ class RDoc::Markup::AttributeManager
312
312
  res << change_attribute(current_attr, new_attr)
313
313
  current_attr = new_attr
314
314
 
315
- if (current_attr & @attributes.special) != 0 then
315
+ if (current_attr & @attributes.regexp_handling) != 0 then
316
316
  i += 1 while
317
- i < str_len and (@attrs[i] & @attributes.special) != 0
317
+ i < str_len and (@attrs[i] & @attributes.regexp_handling) != 0
318
318
 
319
- res << RDoc::Markup::Special.new(current_attr,
320
- copy_string(start_pos, i))
319
+ res << RDoc::Markup::RegexpHandling.new(current_attr,
320
+ copy_string(start_pos, i))
321
321
  start_pos = i
322
322
  next
323
323
  end
@@ -6,21 +6,21 @@
6
6
  class RDoc::Markup::Attributes
7
7
 
8
8
  ##
9
- # The special attribute type. See RDoc::Markup#add_special
9
+ # The regexp handling attribute type. See RDoc::Markup#add_regexp_handling
10
10
 
11
- attr_reader :special
11
+ attr_reader :regexp_handling
12
12
 
13
13
  ##
14
14
  # Creates a new attributes set.
15
15
 
16
16
  def initialize
17
- @special = 1
17
+ @regexp_handling = 1
18
18
 
19
19
  @name_to_bitmap = [
20
- [:_SPECIAL_, @special],
20
+ [:_REGEXP_HANDLING_, @regexp_handling],
21
21
  ]
22
22
 
23
- @next_bitmap = @special << 1
23
+ @next_bitmap = @regexp_handling << 1
24
24
  end
25
25
 
26
26
  ##
@@ -61,7 +61,7 @@ class RDoc::Markup::Attributes
61
61
  return enum_for __method__, bitmap unless block_given?
62
62
 
63
63
  @name_to_bitmap.each do |name, bit|
64
- next if bit == @special
64
+ next if bit == @regexp_handling
65
65
 
66
66
  yield name.to_s if (bitmap & bit) != 0
67
67
  end
@@ -50,7 +50,7 @@ class RDoc::Markup::Formatter
50
50
 
51
51
  @markup = markup || RDoc::Markup.new
52
52
  @am = @markup.attribute_manager
53
- @am.add_special(/<br>/, :HARD_BREAK)
53
+ @am.add_regexp_handling(/<br>/, :HARD_BREAK)
54
54
 
55
55
  @attributes = @am.attributes
56
56
 
@@ -78,23 +78,24 @@ class RDoc::Markup::Formatter
78
78
  end
79
79
 
80
80
  ##
81
- # Adds a special for links of the form rdoc-...:
81
+ # Adds a regexp handling for links of the form rdoc-...:
82
82
 
83
- def add_special_RDOCLINK
84
- @markup.add_special(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
83
+ def add_regexp_handling_RDOCLINK
84
+ @markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
85
85
  end
86
86
 
87
87
  ##
88
- # Adds a special for links of the form {<text>}[<url>] and <word>[<url>]
88
+ # Adds a regexp handling for links of the form {<text>}[<url>] and
89
+ # <word>[<url>]
89
90
 
90
- def add_special_TIDYLINK
91
- @markup.add_special(/(?:
92
- \{.*?\} | # multi-word label
93
- \b[^\s{}]+? # single-word label
94
- )
91
+ def add_regexp_handling_TIDYLINK
92
+ @markup.add_regexp_handling(/(?:
93
+ \{.*?\} | # multi-word label
94
+ \b[^\s{}]+? # single-word label
95
+ )
95
96
 
96
- \[\S+?\] # link target
97
- /x, :TIDYLINK)
97
+ \[\S+?\] # link target
98
+ /x, :TIDYLINK)
98
99
  end
99
100
 
100
101
  ##
@@ -133,8 +134,8 @@ class RDoc::Markup::Formatter
133
134
  when RDoc::Markup::AttrChanger then
134
135
  off_tags res, item
135
136
  on_tags res, item
136
- when RDoc::Markup::Special then
137
- res << convert_special(item)
137
+ when RDoc::Markup::RegexpHandling then
138
+ res << convert_regexp_handling(item)
138
139
  else
139
140
  raise "Unknown flow element: #{item.inspect}"
140
141
  end
@@ -144,29 +145,29 @@ class RDoc::Markup::Formatter
144
145
  end
145
146
 
146
147
  ##
147
- # Converts added specials. See RDoc::Markup#add_special
148
+ # Converts added regexp handlings. See RDoc::Markup#add_regexp_handling
148
149
 
149
- def convert_special special
150
- return special.text if in_tt?
150
+ def convert_regexp_handling target
151
+ return target.text if in_tt?
151
152
 
152
153
  handled = false
153
154
 
154
- @attributes.each_name_of special.type do |name|
155
- method_name = "handle_special_#{name}"
155
+ @attributes.each_name_of target.type do |name|
156
+ method_name = "handle_regexp_#{name}"
156
157
 
157
158
  if respond_to? method_name then
158
- special.text = send method_name, special
159
+ target.text = send method_name, target
159
160
  handled = true
160
161
  end
161
162
  end
162
163
 
163
164
  unless handled then
164
- special_name = @attributes.as_string special.type
165
+ target_name = @attributes.as_string target.type
165
166
 
166
- raise RDoc::Error, "Unhandled special #{special_name}: #{special}"
167
+ raise RDoc::Error, "Unhandled regexp handling #{target_name}: #{target}"
167
168
  end
168
169
 
169
- special.text
170
+ target.text
170
171
  end
171
172
 
172
173
  ##