danger-packwerk 0.14.0 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/lib/danger-packwerk/danger_package_todo_yml_changes.rb +21 -118
  3. data/lib/danger-packwerk/danger_packwerk.rb +12 -7
  4. data/lib/danger-packwerk/private/git.rb +65 -0
  5. data/lib/danger-packwerk/private/todo_yml_changes.rb +135 -0
  6. data/lib/danger-packwerk/private.rb +1 -0
  7. data/lib/danger-packwerk/version.rb +1 -1
  8. metadata +4 -88
  9. data/sorbet/config +0 -4
  10. data/sorbet/rbi/gems/actionview@7.0.4.rbi +0 -11543
  11. data/sorbet/rbi/gems/activesupport@7.0.4.rbi +0 -12959
  12. data/sorbet/rbi/gems/addressable@2.8.1.rbi +0 -1505
  13. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -522
  14. data/sorbet/rbi/gems/better_html@2.0.1.rbi +0 -286
  15. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -8
  16. data/sorbet/rbi/gems/claide-plugins@0.9.2.rbi +0 -791
  17. data/sorbet/rbi/gems/claide@1.1.0.rbi +0 -1132
  18. data/sorbet/rbi/gems/code_ownership@1.29.2.rbi +0 -525
  19. data/sorbet/rbi/gems/code_teams@1.0.0.rbi +0 -120
  20. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -2256
  21. data/sorbet/rbi/gems/colored2@3.1.2.rbi +0 -130
  22. data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +0 -8695
  23. data/sorbet/rbi/gems/constant_resolver@0.2.0.rbi +0 -30
  24. data/sorbet/rbi/gems/cork@0.3.0.rbi +0 -248
  25. data/sorbet/rbi/gems/crass@1.0.6.rbi +0 -436
  26. data/sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi +0 -8
  27. data/sorbet/rbi/gems/danger@9.0.0.rbi +0 -4722
  28. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -862
  29. data/sorbet/rbi/gems/erubi@1.11.0.rbi +0 -102
  30. data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +0 -266
  31. data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +0 -209
  32. data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +0 -212
  33. data/sorbet/rbi/gems/faraday-http-cache@2.4.1.rbi +0 -805
  34. data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +0 -221
  35. data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +0 -266
  36. data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +0 -216
  37. data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +0 -206
  38. data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +0 -212
  39. data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +0 -225
  40. data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +0 -222
  41. data/sorbet/rbi/gems/faraday@1.10.2.rbi +0 -1862
  42. data/sorbet/rbi/gems/git@1.12.0.rbi +0 -1936
  43. data/sorbet/rbi/gems/i18n@1.12.0.rbi +0 -1643
  44. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +0 -8
  45. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +0 -2168
  46. data/sorbet/rbi/gems/loofah@2.19.0.rbi +0 -646
  47. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -199
  48. data/sorbet/rbi/gems/minitest@5.16.3.rbi +0 -997
  49. data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +0 -165
  50. data/sorbet/rbi/gems/nap@1.1.0.rbi +0 -351
  51. data/sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi +0 -8
  52. data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +0 -4916
  53. data/sorbet/rbi/gems/octokit@5.6.1.rbi +0 -8939
  54. data/sorbet/rbi/gems/open4@1.3.4.rbi +0 -8
  55. data/sorbet/rbi/gems/packs@0.0.5.rbi +0 -111
  56. data/sorbet/rbi/gems/packwerk@2.2.1-e998ef65194de398f0baaf03a0ba33390b30351e.rbi +0 -2161
  57. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -163
  58. data/sorbet/rbi/gems/parse_packwerk@0.18.0.rbi +0 -225
  59. data/sorbet/rbi/gems/parser@3.1.2.1.rbi +0 -5988
  60. data/sorbet/rbi/gems/pry@0.14.1.rbi +0 -6969
  61. data/sorbet/rbi/gems/public_suffix@5.0.0.rbi +0 -779
  62. data/sorbet/rbi/gems/racc@1.6.0.rbi +0 -92
  63. data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +0 -8
  64. data/sorbet/rbi/gems/rails-html-sanitizer@1.4.3.rbi +0 -493
  65. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -227
  66. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -1865
  67. data/sorbet/rbi/gems/rbi@0.0.14.rbi +0 -2337
  68. data/sorbet/rbi/gems/rchardet@1.8.0.rbi +0 -587
  69. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -1851
  70. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -3852
  71. data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +0 -7725
  72. data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +0 -6201
  73. data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +0 -3625
  74. data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +0 -1176
  75. data/sorbet/rbi/gems/rspec@3.11.0.rbi +0 -40
  76. data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +0 -4193
  77. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +0 -677
  78. data/sorbet/rbi/gems/rubocop@1.36.0.rbi +0 -37914
  79. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -732
  80. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +0 -8
  81. data/sorbet/rbi/gems/sawyer@0.9.2.rbi +0 -513
  82. data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +0 -326
  83. data/sorbet/rbi/gems/spoom@1.1.11.rbi +0 -1600
  84. data/sorbet/rbi/gems/tapioca@0.8.0.rbi +0 -1959
  85. data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +0 -438
  86. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -2921
  87. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +0 -4879
  88. data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +0 -27
  89. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -2789
  90. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -1802
  91. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +0 -288
  92. data/sorbet/rbi/gems/yard@0.9.27.rbi +0 -12668
  93. data/sorbet/rbi/todo.rbi +0 -125
  94. data/sorbet/tapioca/require.rb +0 -4
@@ -1,2256 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `coderay` gem.
5
- # Please instead update this file by running `bin/tapioca gem coderay`.
6
-
7
- # = CodeRay Library
8
- #
9
- # CodeRay is a Ruby library for syntax highlighting.
10
- #
11
- # I try to make CodeRay easy to use and intuitive, but at the same time fully
12
- # featured, complete, fast and efficient.
13
- #
14
- # See README.
15
- #
16
- # It consists mainly of
17
- # * the main engine: CodeRay (Scanners::Scanner, Tokens, Encoders::Encoder)
18
- # * the plugin system: PluginHost, Plugin
19
- # * the scanners in CodeRay::Scanners
20
- # * the encoders in CodeRay::Encoders
21
- # * the styles in CodeRay::Styles
22
- #
23
- # Here's a fancy graphic to light up this gray docu:
24
- #
25
- # http://cycnus.de/raindark/coderay/scheme.png
26
- #
27
- # == Documentation
28
- #
29
- # See CodeRay, Encoders, Scanners, Tokens.
30
- #
31
- # == Usage
32
- #
33
- # Remember you need RubyGems to use CodeRay, unless you have it in your load
34
- # path. Run Ruby with -rubygems option if required.
35
- #
36
- # === Highlight Ruby code in a string as html
37
- #
38
- # require 'coderay'
39
- # print CodeRay.scan('puts "Hello, world!"', :ruby).html
40
- #
41
- # # prints something like this:
42
- # puts <span class="s">&quot;Hello, world!&quot;</span>
43
- #
44
- #
45
- # === Highlight C code from a file in a html div
46
- #
47
- # require 'coderay'
48
- # print CodeRay.scan(File.read('ruby.h'), :c).div
49
- # print CodeRay.scan_file('ruby.h').html.div
50
- #
51
- # You can include this div in your page. The used CSS styles can be printed with
52
- #
53
- # % coderay_stylesheet
54
- #
55
- # === Highlight without typing too much
56
- #
57
- # If you are one of the hasty (or lazy, or extremely curious) people, just run this file:
58
- #
59
- # % ruby -rubygems /path/to/coderay/coderay.rb > example.html
60
- #
61
- # and look at the file it created in your browser.
62
- #
63
- # = CodeRay Module
64
- #
65
- # The CodeRay module provides convenience methods for the engine.
66
- #
67
- # * The +lang+ and +format+ arguments select Scanner and Encoder to use. These are
68
- # simply lower-case symbols, like <tt>:python</tt> or <tt>:html</tt>.
69
- # * All methods take an optional hash as last parameter, +options+, that is send to
70
- # the Encoder / Scanner.
71
- # * Input and language are always sorted in this order: +code+, +lang+.
72
- # (This is in alphabetical order, if you need a mnemonic ;)
73
- #
74
- # You should be able to highlight everything you want just using these methods;
75
- # so there is no need to dive into CodeRay's deep class hierarchy.
76
- #
77
- # The examples in the demo directory demonstrate common cases using this interface.
78
- #
79
- # = Basic Access Ways
80
- #
81
- # Read this to get a general view what CodeRay provides.
82
- #
83
- # == Scanning
84
- #
85
- # Scanning means analysing an input string, splitting it up into Tokens.
86
- # Each Token knows about what type it is: string, comment, class name, etc.
87
- #
88
- # Each +lang+ (language) has its own Scanner; for example, <tt>:ruby</tt> code is
89
- # handled by CodeRay::Scanners::Ruby.
90
- #
91
- # CodeRay.scan:: Scan a string in a given language into Tokens.
92
- # This is the most common method to use.
93
- # CodeRay.scan_file:: Scan a file and guess the language using FileType.
94
- #
95
- # The Tokens object you get from these methods can encode itself; see Tokens.
96
- #
97
- # == Encoding
98
- #
99
- # Encoding means compiling Tokens into an output. This can be colored HTML or
100
- # LaTeX, a textual statistic or just the number of non-whitespace tokens.
101
- #
102
- # Each Encoder provides output in a specific +format+, so you select Encoders via
103
- # formats like <tt>:html</tt> or <tt>:statistic</tt>.
104
- #
105
- # CodeRay.encode:: Scan and encode a string in a given language.
106
- # CodeRay.encode_tokens:: Encode the given tokens.
107
- # CodeRay.encode_file:: Scan a file, guess the language using FileType and encode it.
108
- #
109
- # == All-in-One Encoding
110
- #
111
- # CodeRay.encode:: Highlight a string with a given input and output format.
112
- #
113
- # == Instanciating
114
- #
115
- # You can use an Encoder instance to highlight multiple inputs. This way, the setup
116
- # for this Encoder must only be done once.
117
- #
118
- # CodeRay.encoder:: Create an Encoder instance with format and options.
119
- # CodeRay.scanner:: Create an Scanner instance for lang, with '' as default code.
120
- #
121
- # To make use of CodeRay.scanner, use CodeRay::Scanner::code=.
122
- #
123
- # The scanning methods provide more flexibility; we recommend to use these.
124
- #
125
- # == Reusing Scanners and Encoders
126
- #
127
- # If you want to re-use scanners and encoders (because that is faster), see
128
- # CodeRay::Duo for the most convenient (and recommended) interface.
129
- module CodeRay
130
- class << self
131
- # Assuming the path is a subpath of lib/coderay/
132
- def coderay_path(*path); end
133
-
134
- # Encode a string.
135
- #
136
- # This scans +code+ with the the Scanner for +lang+ and then
137
- # encodes it with the Encoder for +format+.
138
- # +options+ will be passed to the Encoder.
139
- #
140
- # See CodeRay::Encoder.encode.
141
- def encode(code, lang, format, options = T.unsafe(nil)); end
142
-
143
- # Encodes +filename+ (a path to a code file) with the Scanner for +lang+.
144
- #
145
- # See CodeRay.scan_file.
146
- # Notice that the second argument is the output +format+, not the input language.
147
- #
148
- # Example:
149
- # require 'coderay'
150
- # page = CodeRay.encode_file 'some_c_code.c', :html
151
- def encode_file(filename, format, options = T.unsafe(nil)); end
152
-
153
- # Encode pre-scanned Tokens.
154
- # Use this together with CodeRay.scan:
155
- #
156
- # require 'coderay'
157
- #
158
- # # Highlight a short Ruby code example in a HTML span
159
- # tokens = CodeRay.scan '1 + 2', :ruby
160
- # puts CodeRay.encode_tokens(tokens, :span)
161
- def encode_tokens(tokens, format, options = T.unsafe(nil)); end
162
-
163
- # Finds the Encoder class for +format+ and creates an instance, passing
164
- # +options+ to it.
165
- #
166
- # Example:
167
- # require 'coderay'
168
- #
169
- # stats = CodeRay.encoder(:statistic)
170
- # stats.encode("puts 17 + 4\n", :ruby)
171
- #
172
- # puts '%d out of %d tokens have the kind :integer.' % [
173
- # stats.type_stats[:integer].count,
174
- # stats.real_token_count
175
- # ]
176
- # #-> 2 out of 4 tokens have the kind :integer.
177
- def encoder(format, options = T.unsafe(nil)); end
178
-
179
- # Extract the options for the scanner from the +options+ hash.
180
- #
181
- # Returns an empty Hash if <tt>:scanner_options</tt> is not set.
182
- #
183
- # This is used if a method like CodeRay.encode has to provide options
184
- # for Encoder _and_ scanner.
185
- def get_scanner_options(options); end
186
-
187
- # Highlight a string into a HTML <div>.
188
- #
189
- # CSS styles use classes, so you have to include a stylesheet
190
- # in your output.
191
- #
192
- # See encode.
193
- def highlight(code, lang, options = T.unsafe(nil), format = T.unsafe(nil)); end
194
-
195
- # Highlight a file into a HTML <div>.
196
- #
197
- # CSS styles use classes, so you have to include a stylesheet
198
- # in your output.
199
- #
200
- # See encode.
201
- def highlight_file(filename, options = T.unsafe(nil), format = T.unsafe(nil)); end
202
-
203
- # Scans the given +code+ (a String) with the Scanner for +lang+.
204
- #
205
- # This is a simple way to use CodeRay. Example:
206
- # require 'coderay'
207
- # page = CodeRay.scan("puts 'Hello, world!'", :ruby).html
208
- #
209
- # See also demo/demo_simple.
210
- def scan(code, lang, options = T.unsafe(nil), &block); end
211
-
212
- # Scans +filename+ (a path to a code file) with the Scanner for +lang+.
213
- #
214
- # If +lang+ is :auto or omitted, the CodeRay::FileType module is used to
215
- # determine it. If it cannot find out what type it is, it uses
216
- # CodeRay::Scanners::Text.
217
- #
218
- # Calls CodeRay.scan.
219
- #
220
- # Example:
221
- # require 'coderay'
222
- # page = CodeRay.scan_file('some_c_code.c').html
223
- def scan_file(filename, lang = T.unsafe(nil), options = T.unsafe(nil), &block); end
224
-
225
- # Finds the Scanner class for +lang+ and creates an instance, passing
226
- # +options+ to it.
227
- #
228
- # See Scanner.new.
229
- def scanner(lang, options = T.unsafe(nil), &block); end
230
- end
231
- end
232
-
233
- CodeRay::CODERAY_PATH = T.let(T.unsafe(nil), String)
234
-
235
- # = Duo
236
- #
237
- # A Duo is a convenient way to use CodeRay. You just create a Duo,
238
- # giving it a lang (language of the input code) and a format (desired
239
- # output format), and call Duo#highlight with the code.
240
- #
241
- # Duo makes it easy to re-use both scanner and encoder for a repetitive
242
- # task. It also provides a very easy interface syntax:
243
- #
244
- # require 'coderay'
245
- # CodeRay::Duo[:python, :div].highlight 'import this'
246
- #
247
- # Until you want to do uncommon things with CodeRay, I recommend to use
248
- # this method, since it takes care of everything.
249
- class CodeRay::Duo
250
- # Create a new Duo, holding a lang and a format to highlight code.
251
- #
252
- # simple:
253
- # CodeRay::Duo[:ruby, :html].highlight 'bla 42'
254
- #
255
- # with options:
256
- # CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??'
257
- #
258
- # alternative syntax without options:
259
- # CodeRay::Duo[:ruby => :statistic].encode 'class << self; end'
260
- #
261
- # alternative syntax with options:
262
- # CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc'
263
- #
264
- # The options are forwarded to scanner and encoder
265
- # (see CodeRay.get_scanner_options).
266
- #
267
- # @return [Duo] a new instance of Duo
268
- def initialize(lang = T.unsafe(nil), format = T.unsafe(nil), options = T.unsafe(nil)); end
269
-
270
- # Tokenize and highlight the code using +scanner+ and +encoder+.
271
- # Allows to use Duo like a proc object:
272
- #
273
- # CodeRay::Duo[:python => :yaml].call(code)
274
- #
275
- # or, in Ruby 1.9 and later:
276
- #
277
- # CodeRay::Duo[:python => :yaml].(code)
278
- def call(code, options = T.unsafe(nil)); end
279
-
280
- # Tokenize and highlight the code using +scanner+ and +encoder+.
281
- def encode(code, options = T.unsafe(nil)); end
282
-
283
- # The encoder of the duo. Only created once.
284
- def encoder; end
285
-
286
- # Returns the value of attribute format.
287
- def format; end
288
-
289
- # Sets the attribute format
290
- #
291
- # @param value the value to set the attribute format to.
292
- def format=(_arg0); end
293
-
294
- # Tokenize and highlight the code using +scanner+ and +encoder+.
295
- def highlight(code, options = T.unsafe(nil)); end
296
-
297
- # Returns the value of attribute lang.
298
- def lang; end
299
-
300
- # Sets the attribute lang
301
- #
302
- # @param value the value to set the attribute lang to.
303
- def lang=(_arg0); end
304
-
305
- # Returns the value of attribute options.
306
- def options; end
307
-
308
- # Sets the attribute options
309
- #
310
- # @param value the value to set the attribute options to.
311
- def options=(_arg0); end
312
-
313
- # The scanner of the duo. Only created once.
314
- def scanner; end
315
-
316
- class << self
317
- # To allow calls like Duo[:ruby, :html].highlight.
318
- def [](*_arg0); end
319
- end
320
- end
321
-
322
- # This module holds the Encoder class and its subclasses.
323
- # For example, the HTML encoder is named CodeRay::Encoders::HTML
324
- # can be found in coderay/encoders/html.
325
- #
326
- # Encoders also provides methods and constants for the register
327
- # mechanism and the [] method that returns the Encoder class
328
- # belonging to the given format.
329
- module CodeRay::Encoders
330
- extend ::CodeRay::PluginHost
331
- end
332
-
333
- # A simple Filter that removes all tokens of the :comment kind.
334
- #
335
- # Alias: +remove_comments+
336
- #
337
- # Usage:
338
- # CodeRay.scan('print # foo', :ruby).comment_filter.text
339
- # #-> "print "
340
- #
341
- # See also: TokenKindFilter, LinesOfCode
342
- class CodeRay::Encoders::CommentFilter < ::CodeRay::Encoders::TokenKindFilter; end
343
-
344
- CodeRay::Encoders::CommentFilter::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
345
-
346
- # Returns the number of tokens.
347
- #
348
- # Text and block tokens are counted.
349
- class CodeRay::Encoders::Count < ::CodeRay::Encoders::Encoder
350
- def begin_group(kind); end
351
- def begin_line(kind); end
352
- def end_group(kind); end
353
- def end_line(kind); end
354
- def text_token(text, kind); end
355
-
356
- protected
357
-
358
- def finish(options); end
359
- def setup(options); end
360
- end
361
-
362
- # = Debug Encoder
363
- #
364
- # Fast encoder producing simple debug output.
365
- #
366
- # It is readable and diff-able and is used for testing.
367
- #
368
- # You cannot fully restore the tokens information from the
369
- # output, because consecutive :space tokens are merged.
370
- #
371
- # See also: Scanners::Debug
372
- class CodeRay::Encoders::Debug < ::CodeRay::Encoders::Encoder
373
- def begin_group(kind); end
374
- def begin_line(kind); end
375
- def end_group(kind); end
376
- def end_line(kind); end
377
- def text_token(text, kind); end
378
- end
379
-
380
- CodeRay::Encoders::Debug::FILE_EXTENSION = T.let(T.unsafe(nil), String)
381
-
382
- # = Debug Lint Encoder
383
- #
384
- # Debug encoder with additional checks for:
385
- #
386
- # - empty tokens
387
- # - incorrect nesting
388
- #
389
- # It will raise an InvalidTokenStream exception when any of the above occurs.
390
- #
391
- # See also: Encoders::Debug
392
- class CodeRay::Encoders::DebugLint < ::CodeRay::Encoders::Debug
393
- def begin_group(kind); end
394
- def begin_line(kind); end
395
-
396
- # @raise [Lint::IncorrectTokenGroupNesting]
397
- def end_group(kind); end
398
-
399
- # @raise [Lint::IncorrectTokenGroupNesting]
400
- def end_line(kind); end
401
-
402
- # @raise [Lint::EmptyToken]
403
- def text_token(text, kind); end
404
-
405
- protected
406
-
407
- def finish(options); end
408
- def setup(options); end
409
- end
410
-
411
- # Wraps HTML output into a DIV element, using inline styles by default.
412
- #
413
- # See Encoders::HTML for available options.
414
- class CodeRay::Encoders::Div < ::CodeRay::Encoders::HTML; end
415
-
416
- CodeRay::Encoders::Div::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
417
- CodeRay::Encoders::Div::FILE_EXTENSION = T.let(T.unsafe(nil), String)
418
-
419
- # = Encoder
420
- #
421
- # The Encoder base class. Together with Scanner and
422
- # Tokens, it forms the highlighting triad.
423
- #
424
- # Encoder instances take a Tokens object and do something with it.
425
- #
426
- # The most common Encoder is surely the HTML encoder
427
- # (CodeRay::Encoders::HTML). It highlights the code in a colorful
428
- # html page.
429
- # If you want the highlighted code in a div or a span instead,
430
- # use its subclasses Div and Span.
431
- class CodeRay::Encoders::Encoder
432
- extend ::CodeRay::Plugin
433
-
434
- # Creates a new Encoder.
435
- # +options+ is saved and used for all encode operations, as long
436
- # as you don't overwrite it there by passing additional options.
437
- #
438
- # Encoder objects provide three encode methods:
439
- # - encode simply takes a +code+ string and a +lang+
440
- # - encode_tokens expects a +tokens+ object instead
441
- #
442
- # Each method has an optional +options+ parameter. These are
443
- # added to the options you passed at creation.
444
- #
445
- # @return [Encoder] a new instance of Encoder
446
- def initialize(options = T.unsafe(nil)); end
447
-
448
- def <<(token); end
449
-
450
- # Starts a token group with the given +kind+.
451
- def begin_group(kind); end
452
-
453
- # Starts a new line token group with the given +kind+.
454
- def begin_line(kind); end
455
-
456
- # Encode the given +code+ using the Scanner for +lang+.
457
- def encode(code, lang, options = T.unsafe(nil)); end
458
-
459
- # Encode a Tokens object.
460
- def encode_tokens(tokens, options = T.unsafe(nil)); end
461
-
462
- # Ends a token group with the given +kind+.
463
- def end_group(kind); end
464
-
465
- # Ends a new line token group with the given +kind+.
466
- def end_line(kind); end
467
-
468
- # The default file extension for this encoder.
469
- def file_extension; end
470
-
471
- # Encode the given +code+ using the Scanner for +lang+.
472
- # You can use highlight instead of encode, if that seems
473
- # more clear to you.
474
- def highlight(code, lang, options = T.unsafe(nil)); end
475
-
476
- # The options you gave the Encoder at creating.
477
- def options; end
478
-
479
- # The options you gave the Encoder at creating.
480
- def options=(_arg0); end
481
-
482
- # The options you gave the Encoder at creating.
483
- def scanner; end
484
-
485
- # The options you gave the Encoder at creating.
486
- def scanner=(_arg0); end
487
-
488
- # Called for each text token ([text, kind]), where text is a String.
489
- def text_token(text, kind); end
490
-
491
- # Called with +content+ and +kind+ of the currently scanned token.
492
- # For simple scanners, it's enougth to implement this method.
493
- #
494
- # By default, it calls text_token, begin_group, end_group, begin_line,
495
- # or end_line, depending on the +content+.
496
- def token(content, kind); end
497
-
498
- # Do the encoding.
499
- #
500
- # The already created +tokens+ object must be used; it must be a
501
- # Tokens object.
502
- def tokens(tokens, options = T.unsafe(nil)); end
503
-
504
- protected
505
-
506
- # Do the encoding.
507
- #
508
- # The already created +tokens+ object must be used; it must be a
509
- # Tokens object.
510
- def compile(tokens, options = T.unsafe(nil)); end
511
-
512
- # Called with merged options after encoding starts.
513
- # The return value is the result of encoding, typically @out.
514
- def finish(options); end
515
-
516
- def get_output(options); end
517
-
518
- # Append data.to_s to the output. Returns the argument.
519
- def output(data); end
520
-
521
- # Called with merged options before encoding starts.
522
- # Sets @out to an empty string.
523
- #
524
- # See the HTML Encoder for an example of option caching.
525
- def setup(options); end
526
-
527
- class << self
528
- # If FILE_EXTENSION isn't defined, this method returns the
529
- # downcase class name instead.
530
- def const_missing(sym); end
531
-
532
- # The default file extension for output file of this encoder class.
533
- def file_extension; end
534
- end
535
- end
536
-
537
- # Subclasses are to store their default options in this constant.
538
- CodeRay::Encoders::Encoder::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
539
-
540
- CodeRay::Encoders::Encoder::PLUGIN_HOST = CodeRay::Encoders
541
-
542
- # A Filter encoder has another Tokens instance as output.
543
- # It can be subclass to select, remove, or modify tokens in the stream.
544
- #
545
- # Subclasses of Filter are called "Filters" and can be chained.
546
- #
547
- # == Options
548
- #
549
- # === :tokens
550
- #
551
- # The Tokens object which will receive the output.
552
- #
553
- # Default: Tokens.new
554
- #
555
- # See also: TokenKindFilter
556
- class CodeRay::Encoders::Filter < ::CodeRay::Encoders::Encoder
557
- def begin_group(kind); end
558
- def begin_line(kind); end
559
- def end_group(kind); end
560
- def end_line(kind); end
561
- def text_token(text, kind); end
562
-
563
- protected
564
-
565
- def finish(options); end
566
- def setup(options); end
567
- end
568
-
569
- # = HTML Encoder
570
- #
571
- # This is CodeRay's most important highlighter:
572
- # It provides save, fast XHTML generation and CSS support.
573
- #
574
- # == Usage
575
- #
576
- # require 'coderay'
577
- # puts CodeRay.scan('Some /code/', :ruby).html #-> a HTML page
578
- # puts CodeRay.scan('Some /code/', :ruby).html(:wrap => :span)
579
- # #-> <span class="CodeRay"><span class="co">Some</span> /code/</span>
580
- # puts CodeRay.scan('Some /code/', :ruby).span #-> the same
581
- #
582
- # puts CodeRay.scan('Some code', :ruby).html(
583
- # :wrap => nil,
584
- # :line_numbers => :inline,
585
- # :css => :style
586
- # )
587
- #
588
- # == Options
589
- #
590
- # === :tab_width
591
- # Convert \t characters to +n+ spaces (a number or false.)
592
- # false will keep tab characters untouched.
593
- #
594
- # Default: 8
595
- #
596
- # === :css
597
- # How to include the styles; can be :class or :style.
598
- #
599
- # Default: :class
600
- #
601
- # === :wrap
602
- # Wrap in :page, :div, :span or nil.
603
- #
604
- # You can also use Encoders::Div and Encoders::Span.
605
- #
606
- # Default: nil
607
- #
608
- # === :title
609
- #
610
- # The title of the HTML page (works only when :wrap is set to :page.)
611
- #
612
- # Default: 'CodeRay output'
613
- #
614
- # === :break_lines
615
- #
616
- # Split multiline blocks at line breaks.
617
- # Forced to true if :line_numbers option is set to :inline.
618
- #
619
- # Default: false
620
- #
621
- # === :line_numbers
622
- # Include line numbers in :table, :inline, or nil (no line numbers)
623
- #
624
- # Default: nil
625
- #
626
- # === :line_number_anchors
627
- # Adds anchors and links to the line numbers. Can be false (off), true (on),
628
- # or a prefix string that will be prepended to the anchor name.
629
- #
630
- # The prefix must consist only of letters, digits, and underscores.
631
- #
632
- # Default: true, default prefix name: "line"
633
- #
634
- # === :line_number_start
635
- # Where to start with line number counting.
636
- #
637
- # Default: 1
638
- #
639
- # === :bold_every
640
- # Make every +n+-th number appear bold.
641
- #
642
- # Default: 10
643
- #
644
- # === :highlight_lines
645
- #
646
- # Highlights certain line numbers.
647
- # Can be any Enumerable, typically just an Array or Range, of numbers.
648
- #
649
- # Bolding is deactivated when :highlight_lines is set. It only makes sense
650
- # in combination with :line_numbers.
651
- #
652
- # Default: nil
653
- #
654
- # === :hint
655
- # Include some information into the output using the title attribute.
656
- # Can be :info (show token kind on mouse-over), :info_long (with full path)
657
- # or :debug (via inspect).
658
- #
659
- # Default: false
660
- class CodeRay::Encoders::HTML < ::CodeRay::Encoders::Encoder
661
- # token groups, eg. strings
662
- def begin_group(kind); end
663
-
664
- # whole lines to be highlighted, eg. a deleted line in a diff
665
- def begin_line(kind); end
666
-
667
- # Returns the value of attribute css.
668
- def css; end
669
-
670
- def end_group(kind); end
671
- def end_line(kind); end
672
- def text_token(text, kind); end
673
-
674
- protected
675
-
676
- def break_lines(text, style); end
677
- def check_group_nesting(name, kind); end
678
- def check_options!(options); end
679
- def close_span; end
680
- def css_class_for_kinds(kinds); end
681
- def finish(options); end
682
- def make_span_for_kinds(method, hint); end
683
- def setup(options); end
684
- def style_for_kinds(kinds); end
685
-
686
- class << self
687
- def make_html_escape_hash; end
688
-
689
- # Generate a hint about the given +kinds+ in a +hint+ style.
690
- #
691
- # +hint+ may be :info, :info_long or :debug.
692
- def token_path_to_hint(hint, kinds); end
693
- end
694
- end
695
-
696
- class CodeRay::Encoders::HTML::CSS
697
- # @return [CSS] a new instance of CSS
698
- def initialize(style = T.unsafe(nil)); end
699
-
700
- def get_style_for_css_classes(css_classes); end
701
-
702
- # Returns the value of attribute stylesheet.
703
- def stylesheet; end
704
-
705
- private
706
-
707
- def parse(stylesheet); end
708
-
709
- class << self
710
- def load_stylesheet(style = T.unsafe(nil)); end
711
- end
712
- end
713
-
714
- CodeRay::Encoders::HTML::CSS::CSS_CLASS_PATTERN = T.let(T.unsafe(nil), Regexp)
715
- CodeRay::Encoders::HTML::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
716
- CodeRay::Encoders::HTML::FILE_EXTENSION = T.let(T.unsafe(nil), String)
717
- CodeRay::Encoders::HTML::HTML_ESCAPE = T.let(T.unsafe(nil), Hash)
718
- CodeRay::Encoders::HTML::HTML_ESCAPE_PATTERN = T.let(T.unsafe(nil), Regexp)
719
-
720
- module CodeRay::Encoders::HTML::Numbering
721
- class << self
722
- def number!(output, mode = T.unsafe(nil), options = T.unsafe(nil)); end
723
- end
724
- end
725
-
726
- # This module is included in the output String of the HTML Encoder.
727
- #
728
- # It provides methods like wrap, div, page etc.
729
- #
730
- # Remember to use #clone instead of #dup to keep the modules the object was
731
- # extended with.
732
- #
733
- # TODO: Rewrite this without monkey patching.
734
- module CodeRay::Encoders::HTML::Output
735
- def apply_title!(title); end
736
-
737
- # Returns the value of attribute css.
738
- def css; end
739
-
740
- # Sets the attribute css
741
- #
742
- # @param value the value to set the attribute css to.
743
- def css=(_arg0); end
744
-
745
- def stylesheet(in_tag = T.unsafe(nil)); end
746
- def wrap!(element, *args); end
747
- def wrap_in!(template); end
748
- def wrapped_in; end
749
-
750
- # Sets the attribute wrapped_in
751
- #
752
- # @param value the value to set the attribute wrapped_in to.
753
- def wrapped_in=(_arg0); end
754
-
755
- # @return [Boolean]
756
- def wrapped_in?(element); end
757
-
758
- class << self
759
- # Raises an exception if an object that doesn't respond to to_str is extended by Output,
760
- # to prevent users from misuse. Use Module#remove_method to disable.
761
- def extended(o); end
762
-
763
- def make_stylesheet(css, in_tag = T.unsafe(nil)); end
764
- def page_template_for_css(css); end
765
- end
766
- end
767
-
768
- CodeRay::Encoders::HTML::Output::DIV = T.let(T.unsafe(nil), CodeRay::Encoders::HTML::Output::Template)
769
- CodeRay::Encoders::HTML::Output::PAGE = T.let(T.unsafe(nil), CodeRay::Encoders::HTML::Output::Template)
770
- CodeRay::Encoders::HTML::Output::SPAN = T.let(T.unsafe(nil), CodeRay::Encoders::HTML::Output::Template)
771
- CodeRay::Encoders::HTML::Output::TABLE = T.let(T.unsafe(nil), CodeRay::Encoders::HTML::Output::Template)
772
-
773
- # -- don't include the templates in docu
774
- class CodeRay::Encoders::HTML::Output::Template < ::String
775
- def apply(target, replacement); end
776
-
777
- class << self
778
- def wrap!(str, template, target); end
779
- end
780
- end
781
-
782
- CodeRay::Encoders::HTML::TOKEN_KIND_TO_INFO = T.let(T.unsafe(nil), Hash)
783
- CodeRay::Encoders::HTML::TRANSPARENT_TOKEN_KINDS = T.let(T.unsafe(nil), Set)
784
-
785
- # A simple JSON Encoder.
786
- #
787
- # Example:
788
- # CodeRay.scan('puts "Hello world!"', :ruby).json
789
- # yields
790
- # [
791
- # {"type"=>"text", "text"=>"puts", "kind"=>"ident"},
792
- # {"type"=>"text", "text"=>" ", "kind"=>"space"},
793
- # {"type"=>"block", "action"=>"open", "kind"=>"string"},
794
- # {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
795
- # {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"},
796
- # {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
797
- # {"type"=>"block", "action"=>"close", "kind"=>"string"},
798
- # ]
799
- class CodeRay::Encoders::JSON < ::CodeRay::Encoders::Encoder
800
- def begin_group(kind); end
801
- def begin_line(kind); end
802
- def end_group(kind); end
803
- def end_line(kind); end
804
- def text_token(text, kind); end
805
-
806
- protected
807
-
808
- def append(data); end
809
- def finish(options); end
810
- def setup(options); end
811
- end
812
-
813
- CodeRay::Encoders::JSON::FILE_EXTENSION = T.let(T.unsafe(nil), String)
814
-
815
- # Counts the LoC (Lines of Code). Returns an Integer >= 0.
816
- #
817
- # Alias: +loc+
818
- #
819
- # Everything that is not comment, markup, doctype/shebang, or an empty line,
820
- # is considered to be code.
821
- #
822
- # For example,
823
- # * HTML files not containing JavaScript have 0 LoC
824
- # * in a Java class without comments, LoC is the number of non-empty lines
825
- #
826
- # A Scanner class should define the token kinds that are not code in the
827
- # KINDS_NOT_LOC constant, which defaults to [:comment, :doctype].
828
- class CodeRay::Encoders::LinesOfCode < ::CodeRay::Encoders::TokenKindFilter
829
- protected
830
-
831
- def finish(options); end
832
- def setup(options); end
833
- end
834
-
835
- CodeRay::Encoders::LinesOfCode::NON_EMPTY_LINE = T.let(T.unsafe(nil), Regexp)
836
-
837
- # = Lint Encoder
838
- #
839
- # Checks for:
840
- #
841
- # - empty tokens
842
- # - incorrect nesting
843
- #
844
- # It will raise an InvalidTokenStream exception when any of the above occurs.
845
- #
846
- # See also: Encoders::DebugLint
847
- class CodeRay::Encoders::Lint < ::CodeRay::Encoders::Debug
848
- def begin_group(kind); end
849
- def begin_line(kind); end
850
-
851
- # @raise [IncorrectTokenGroupNesting]
852
- def end_group(kind); end
853
-
854
- # @raise [IncorrectTokenGroupNesting]
855
- def end_line(kind); end
856
-
857
- # @raise [EmptyToken]
858
- def text_token(text, kind); end
859
-
860
- protected
861
-
862
- def finish(options); end
863
- def setup(options); end
864
- end
865
-
866
- class CodeRay::Encoders::Lint::EmptyToken < ::CodeRay::Encoders::Lint::InvalidTokenStream; end
867
- class CodeRay::Encoders::Lint::IncorrectTokenGroupNesting < ::CodeRay::Encoders::Lint::InvalidTokenStream; end
868
- class CodeRay::Encoders::Lint::InvalidTokenStream < ::StandardError; end
869
- class CodeRay::Encoders::Lint::UnknownTokenKind < ::CodeRay::Encoders::Lint::InvalidTokenStream; end
870
-
871
- # = Null Encoder
872
- #
873
- # Does nothing and returns an empty string.
874
- class CodeRay::Encoders::Null < ::CodeRay::Encoders::Encoder
875
- def text_token(text, kind); end
876
- end
877
-
878
- # Wraps the output into a HTML page, using CSS classes and
879
- # line numbers in the table format by default.
880
- #
881
- # See Encoders::HTML for available options.
882
- class CodeRay::Encoders::Page < ::CodeRay::Encoders::HTML; end
883
-
884
- CodeRay::Encoders::Page::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
885
- CodeRay::Encoders::Page::FILE_EXTENSION = T.let(T.unsafe(nil), String)
886
-
887
- # Wraps HTML output into a SPAN element, using inline styles by default.
888
- #
889
- # See Encoders::HTML for available options.
890
- class CodeRay::Encoders::Span < ::CodeRay::Encoders::HTML; end
891
-
892
- CodeRay::Encoders::Span::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
893
- CodeRay::Encoders::Span::FILE_EXTENSION = T.let(T.unsafe(nil), String)
894
-
895
- # Makes a statistic for the given tokens.
896
- #
897
- # Alias: +stats+
898
- class CodeRay::Encoders::Statistic < ::CodeRay::Encoders::Encoder
899
- def begin_group(kind); end
900
- def begin_line(kind); end
901
- def block_token(action, kind); end
902
- def end_group(kind); end
903
- def end_line(kind); end
904
- def real_token_count; end
905
- def text_token(text, kind); end
906
- def type_stats; end
907
-
908
- protected
909
-
910
- def finish(options); end
911
- def setup(options); end
912
- end
913
-
914
- CodeRay::Encoders::Statistic::STATS = T.let(T.unsafe(nil), String)
915
- CodeRay::Encoders::Statistic::TOKEN_TYPES_ROW = T.let(T.unsafe(nil), String)
916
-
917
- class CodeRay::Encoders::Statistic::TypeStats < ::Struct
918
- # Returns the value of attribute count
919
- #
920
- # @return [Object] the current value of count
921
- def count; end
922
-
923
- # Sets the attribute count
924
- #
925
- # @param value [Object] the value to set the attribute count to.
926
- # @return [Object] the newly set value
927
- def count=(_); end
928
-
929
- # Returns the value of attribute size
930
- #
931
- # @return [Object] the current value of size
932
- def size; end
933
-
934
- # Sets the attribute size
935
- #
936
- # @param value [Object] the value to set the attribute size to.
937
- # @return [Object] the newly set value
938
- def size=(_); end
939
-
940
- class << self
941
- def [](*_arg0); end
942
- def inspect; end
943
- def members; end
944
- def new(*_arg0); end
945
- end
946
- end
947
-
948
- class CodeRay::Encoders::Terminal < ::CodeRay::Encoders::Encoder
949
- def begin_group(kind); end
950
- def begin_line(kind); end
951
- def end_group(kind); end
952
- def end_line(kind); end
953
- def text_token(text, kind); end
954
-
955
- protected
956
-
957
- def setup(options); end
958
-
959
- private
960
-
961
- def open_token(kind); end
962
- end
963
-
964
- CodeRay::Encoders::Terminal::TOKEN_COLORS = T.let(T.unsafe(nil), Hash)
965
-
966
- # Concats the tokens into a single string, resulting in the original
967
- # code string if no tokens were removed.
968
- #
969
- # Alias: +plain+, +plaintext+
970
- #
971
- # == Options
972
- #
973
- # === :separator
974
- # A separator string to join the tokens.
975
- #
976
- # Default: empty String
977
- class CodeRay::Encoders::Text < ::CodeRay::Encoders::Encoder
978
- def text_token(text, kind); end
979
-
980
- protected
981
-
982
- def setup(options); end
983
- end
984
-
985
- CodeRay::Encoders::Text::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
986
- CodeRay::Encoders::Text::FILE_EXTENSION = T.let(T.unsafe(nil), String)
987
-
988
- # A Filter that selects tokens based on their token kind.
989
- #
990
- # == Options
991
- #
992
- # === :exclude
993
- #
994
- # One or many symbols (in an Array) which shall be excluded.
995
- #
996
- # Default: []
997
- #
998
- # === :include
999
- #
1000
- # One or many symbols (in an array) which shall be included.
1001
- #
1002
- # Default: :all, which means all tokens are included.
1003
- #
1004
- # Exclusion wins over inclusion.
1005
- #
1006
- # See also: CommentFilter
1007
- class CodeRay::Encoders::TokenKindFilter < ::CodeRay::Encoders::Filter
1008
- # Add the token group to the output stream if +kind+ matches the
1009
- # conditions.
1010
- #
1011
- # If it does not, all tokens inside the group are excluded from the
1012
- # stream, even if their kinds match.
1013
- def begin_group(kind); end
1014
-
1015
- # See +begin_group+.
1016
- def begin_line(kind); end
1017
-
1018
- # Take care of re-enabling the delegation of tokens to the output stream
1019
- # if an exluded group has ended.
1020
- def end_group(kind); end
1021
-
1022
- # See +end_group+.
1023
- def end_line(kind); end
1024
-
1025
- # Add the token to the output stream if +kind+ matches the conditions.
1026
- def text_token(text, kind); end
1027
-
1028
- protected
1029
-
1030
- # @return [Boolean]
1031
- def include_group?(kind); end
1032
-
1033
- # @return [Boolean]
1034
- def include_text_token?(text, kind); end
1035
-
1036
- def setup(options); end
1037
- end
1038
-
1039
- CodeRay::Encoders::TokenKindFilter::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
1040
-
1041
- # = XML Encoder
1042
- #
1043
- # Uses REXML. Very slow.
1044
- class CodeRay::Encoders::XML < ::CodeRay::Encoders::Encoder
1045
- def begin_group(kind); end
1046
- def end_group(kind); end
1047
- def text_token(text, kind); end
1048
-
1049
- protected
1050
-
1051
- def finish(options); end
1052
- def setup(options); end
1053
- end
1054
-
1055
- CodeRay::Encoders::XML::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
1056
- CodeRay::Encoders::XML::FILE_EXTENSION = T.let(T.unsafe(nil), String)
1057
-
1058
- # = YAML Encoder
1059
- #
1060
- # Slow.
1061
- class CodeRay::Encoders::YAML < ::CodeRay::Encoders::Encoder
1062
- def begin_group(kind); end
1063
- def begin_line(kind); end
1064
- def end_group(kind); end
1065
- def end_line(kind); end
1066
- def text_token(text, kind); end
1067
-
1068
- protected
1069
-
1070
- def finish(options); end
1071
- def setup(options); end
1072
- end
1073
-
1074
- CodeRay::Encoders::YAML::FILE_EXTENSION = T.let(T.unsafe(nil), String)
1075
-
1076
- # = FileType
1077
- #
1078
- # A simple filetype recognizer.
1079
- #
1080
- # == Usage
1081
- #
1082
- # # determine the type of the given
1083
- # lang = FileType[file_name]
1084
- #
1085
- # # return :text if the file type is unknown
1086
- # lang = FileType.fetch file_name, :text
1087
- #
1088
- # # try the shebang line, too
1089
- # lang = FileType.fetch file_name, :text, true
1090
- module CodeRay::FileType
1091
- class << self
1092
- # Try to determine the file type of the file.
1093
- #
1094
- # +filename+ is a relative or absolute path to a file.
1095
- #
1096
- # The file itself is only accessed when +read_shebang+ is set to true.
1097
- # That means you can get filetypes from files that don't exist.
1098
- def [](filename, read_shebang = T.unsafe(nil)); end
1099
-
1100
- # This works like Hash#fetch.
1101
- #
1102
- # If the filetype cannot be found, the +default+ value
1103
- # is returned.
1104
- def fetch(filename, default = T.unsafe(nil), read_shebang = T.unsafe(nil)); end
1105
-
1106
- protected
1107
-
1108
- def type_from_shebang(filename); end
1109
- end
1110
- end
1111
-
1112
- CodeRay::FileType::TypeFromExt = T.let(T.unsafe(nil), Hash)
1113
- CodeRay::FileType::TypeFromName = T.let(T.unsafe(nil), Hash)
1114
- CodeRay::FileType::TypeFromShebang = T.let(T.unsafe(nil), Regexp)
1115
- class CodeRay::FileType::UnknownFileType < ::Exception; end
1116
-
1117
- # = Plugin
1118
- #
1119
- # Plugins have to include this module.
1120
- #
1121
- # IMPORTANT: Use extend for this module.
1122
- #
1123
- # See CodeRay::PluginHost for examples.
1124
- module CodeRay::Plugin
1125
- def aliases; end
1126
-
1127
- # The PluginHost for this Plugin class.
1128
- def plugin_host(host = T.unsafe(nil)); end
1129
-
1130
- # Returns the value of attribute plugin_id.
1131
- def plugin_id; end
1132
-
1133
- # Register this class for the given +id+.
1134
- #
1135
- # Example:
1136
- # class MyPlugin < PluginHost::BaseClass
1137
- # register_for :my_id
1138
- # ...
1139
- # end
1140
- #
1141
- # See PluginHost.register.
1142
- def register_for(id); end
1143
-
1144
- # Returns the title of the plugin, or sets it to the
1145
- # optional argument +title+.
1146
- def title(title = T.unsafe(nil)); end
1147
- end
1148
-
1149
- # = PluginHost
1150
- #
1151
- # A simple subclass/subfolder plugin system.
1152
- #
1153
- # Example:
1154
- # class Generators
1155
- # extend PluginHost
1156
- # plugin_path 'app/generators'
1157
- # end
1158
- #
1159
- # class Generator
1160
- # extend Plugin
1161
- # PLUGIN_HOST = Generators
1162
- # end
1163
- #
1164
- # class FancyGenerator < Generator
1165
- # register_for :fancy
1166
- # end
1167
- #
1168
- # Generators[:fancy] #-> FancyGenerator
1169
- # # or
1170
- # CodeRay.require_plugin 'Generators/fancy'
1171
- # # or
1172
- # Generators::Fancy
1173
- module CodeRay::PluginHost
1174
- # Returns the Plugin for +id+.
1175
- #
1176
- # Example:
1177
- # yaml_plugin = MyPluginHost[:yaml]
1178
- def [](id, *args, &blk); end
1179
-
1180
- # Returns an array of all Plugins.
1181
- #
1182
- # Note: This loads all plugins using load_all.
1183
- def all_plugins; end
1184
-
1185
- # Tries to +load+ the missing plugin by translating +const+ to the
1186
- # underscore form (eg. LinesOfCode becomes lines_of_code).
1187
- def const_missing(const); end
1188
-
1189
- # Define the default plugin to use when no plugin is found
1190
- # for a given id, or return the default plugin.
1191
- #
1192
- # See also map.
1193
- #
1194
- # class MyColorHost < PluginHost
1195
- # map :navy => :dark_blue
1196
- # default :gray
1197
- # end
1198
- #
1199
- # MyColorHost.default # loads and returns the Gray plugin
1200
- def default(id = T.unsafe(nil)); end
1201
-
1202
- # Returns an array of all .rb files in the plugin path.
1203
- #
1204
- # The extension .rb is not included.
1205
- def list; end
1206
-
1207
- # Returns the Plugin for +id+.
1208
- #
1209
- # Example:
1210
- # yaml_plugin = MyPluginHost[:yaml]
1211
- def load(id, *args, &blk); end
1212
-
1213
- # Loads all plugins using list and load.
1214
- def load_all; end
1215
-
1216
- # Loads the map file (see map).
1217
- #
1218
- # This is done automatically when plugin_path is called.
1219
- def load_plugin_map; end
1220
-
1221
- # Map a plugin_id to another.
1222
- #
1223
- # Usage: Put this in a file plugin_path/_map.rb.
1224
- #
1225
- # class MyColorHost < PluginHost
1226
- # map :navy => :dark_blue,
1227
- # :maroon => :brown,
1228
- # :luna => :moon
1229
- # end
1230
- def map(hash); end
1231
-
1232
- # A Hash of plugion_id => Plugin pairs.
1233
- def plugin_hash; end
1234
-
1235
- # The path where the plugins can be found.
1236
- def plugin_path(*args); end
1237
-
1238
- # Every plugin must register itself for +id+ by calling register_for,
1239
- # which calls this method.
1240
- #
1241
- # See Plugin#register_for.
1242
- def register(plugin, id); end
1243
-
1244
- protected
1245
-
1246
- # Return a plugin hash that automatically loads plugins.
1247
- def make_plugin_hash; end
1248
-
1249
- # Returns the expected path to the plugin file for the given id.
1250
- def path_to(plugin_id); end
1251
-
1252
- # Converts +id+ to a valid plugin ID String, or returns +nil+.
1253
- #
1254
- # Raises +ArgumentError+ for all other objects, or if the
1255
- # given String includes non-alphanumeric characters (\W).
1256
- def validate_id(id); end
1257
-
1258
- class << self
1259
- # Adds the module/class to the PLUGIN_HOSTS list.
1260
- def extended(mod); end
1261
- end
1262
- end
1263
-
1264
- class CodeRay::PluginHost::HostNotFound < ::LoadError; end
1265
- CodeRay::PluginHost::PLUGIN_HOSTS = T.let(T.unsafe(nil), Array)
1266
-
1267
- # dummy hash
1268
- CodeRay::PluginHost::PLUGIN_HOSTS_BY_ID = T.let(T.unsafe(nil), Hash)
1269
-
1270
- # Raised if Encoders::[] fails because:
1271
- # * a file could not be found
1272
- # * the requested Plugin is not registered
1273
- class CodeRay::PluginHost::PluginNotFound < ::LoadError; end
1274
-
1275
- # = Scanners
1276
- #
1277
- # This module holds the Scanner class and its subclasses.
1278
- # For example, the Ruby scanner is named CodeRay::Scanners::Ruby
1279
- # can be found in coderay/scanners/ruby.
1280
- #
1281
- # Scanner also provides methods and constants for the register
1282
- # mechanism and the [] method that returns the Scanner class
1283
- # belonging to the given lang.
1284
- #
1285
- # See PluginHost.
1286
- module CodeRay::Scanners
1287
- extend ::CodeRay::PluginHost
1288
- end
1289
-
1290
- # Scanner for C.
1291
- class CodeRay::Scanners::C < ::CodeRay::Scanners::Scanner
1292
- protected
1293
-
1294
- def scan_tokens(encoder, options); end
1295
- end
1296
-
1297
- CodeRay::Scanners::C::DIRECTIVES = T.let(T.unsafe(nil), Array)
1298
- CodeRay::Scanners::C::ESCAPE = T.let(T.unsafe(nil), Regexp)
1299
- CodeRay::Scanners::C::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1300
- CodeRay::Scanners::C::KEYWORDS = T.let(T.unsafe(nil), Array)
1301
- CodeRay::Scanners::C::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1302
- CodeRay::Scanners::C::PREDEFINED_TYPES = T.let(T.unsafe(nil), Array)
1303
- CodeRay::Scanners::C::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1304
-
1305
- # Scanner for C++.
1306
- #
1307
- # Aliases: +cplusplus+, c++
1308
- CodeRay::Scanners::CPlusPlus = CodeRay::Scanners::Text
1309
-
1310
- class CodeRay::Scanners::CSS < ::CodeRay::Scanners::Scanner
1311
- protected
1312
-
1313
- def scan_tokens(encoder, options); end
1314
- def setup; end
1315
- end
1316
-
1317
- CodeRay::Scanners::CSS::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1318
- module CodeRay::Scanners::CSS::RE; end
1319
- CodeRay::Scanners::CSS::RE::AtKeyword = T.let(T.unsafe(nil), Regexp)
1320
- CodeRay::Scanners::CSS::RE::AttributeSelector = T.let(T.unsafe(nil), Regexp)
1321
- CodeRay::Scanners::CSS::RE::Class = T.let(T.unsafe(nil), Regexp)
1322
- CodeRay::Scanners::CSS::RE::Dimension = T.let(T.unsafe(nil), Regexp)
1323
- CodeRay::Scanners::CSS::RE::Escape = T.let(T.unsafe(nil), Regexp)
1324
- CodeRay::Scanners::CSS::RE::Function = T.let(T.unsafe(nil), Regexp)
1325
- CodeRay::Scanners::CSS::RE::Hex = T.let(T.unsafe(nil), Regexp)
1326
- CodeRay::Scanners::CSS::RE::HexColor = T.let(T.unsafe(nil), Regexp)
1327
- CodeRay::Scanners::CSS::RE::Id = T.let(T.unsafe(nil), Regexp)
1328
- CodeRay::Scanners::CSS::RE::Ident = T.let(T.unsafe(nil), Regexp)
1329
- CodeRay::Scanners::CSS::RE::NMChar = T.let(T.unsafe(nil), Regexp)
1330
- CodeRay::Scanners::CSS::RE::NMStart = T.let(T.unsafe(nil), Regexp)
1331
- CodeRay::Scanners::CSS::RE::Name = T.let(T.unsafe(nil), Regexp)
1332
- CodeRay::Scanners::CSS::RE::Num = T.let(T.unsafe(nil), Regexp)
1333
- CodeRay::Scanners::CSS::RE::Percentage = T.let(T.unsafe(nil), Regexp)
1334
- CodeRay::Scanners::CSS::RE::PseudoClass = T.let(T.unsafe(nil), Regexp)
1335
- CodeRay::Scanners::CSS::RE::String = T.let(T.unsafe(nil), Regexp)
1336
-
1337
- # TODO: buggy regexp
1338
- CodeRay::Scanners::CSS::RE::String1 = T.let(T.unsafe(nil), Regexp)
1339
-
1340
- # TODO: buggy regexp
1341
- CodeRay::Scanners::CSS::RE::String2 = T.let(T.unsafe(nil), Regexp)
1342
-
1343
- # differs from standard because it allows uppercase hex too
1344
- CodeRay::Scanners::CSS::RE::Unicode = T.let(T.unsafe(nil), Regexp)
1345
-
1346
- CodeRay::Scanners::CSS::RE::Unit = T.let(T.unsafe(nil), Regexp)
1347
-
1348
- class CodeRay::Scanners::Clojure < ::CodeRay::Scanners::Scanner
1349
- protected
1350
-
1351
- def scan_tokens(encoder, options); end
1352
- end
1353
-
1354
- CodeRay::Scanners::Clojure::BASIC_IDENTIFIER = T.let(T.unsafe(nil), Regexp)
1355
- CodeRay::Scanners::Clojure::COMPLEX10 = T.let(T.unsafe(nil), Regexp)
1356
- CodeRay::Scanners::Clojure::COMPLEX16 = T.let(T.unsafe(nil), Regexp)
1357
- CodeRay::Scanners::Clojure::COMPLEX2 = T.let(T.unsafe(nil), Regexp)
1358
- CodeRay::Scanners::Clojure::COMPLEX8 = T.let(T.unsafe(nil), Regexp)
1359
- CodeRay::Scanners::Clojure::CORE_FORMS = T.let(T.unsafe(nil), Array)
1360
- CodeRay::Scanners::Clojure::DECIMAL = T.let(T.unsafe(nil), Regexp)
1361
- CodeRay::Scanners::Clojure::DIGIT = T.let(T.unsafe(nil), Regexp)
1362
- CodeRay::Scanners::Clojure::DIGIT10 = T.let(T.unsafe(nil), Regexp)
1363
- CodeRay::Scanners::Clojure::DIGIT16 = T.let(T.unsafe(nil), Regexp)
1364
- CodeRay::Scanners::Clojure::DIGIT2 = T.let(T.unsafe(nil), Regexp)
1365
- CodeRay::Scanners::Clojure::DIGIT8 = T.let(T.unsafe(nil), Regexp)
1366
- CodeRay::Scanners::Clojure::EXACTNESS = T.let(T.unsafe(nil), Regexp)
1367
- CodeRay::Scanners::Clojure::EXP = T.let(T.unsafe(nil), Regexp)
1368
- CodeRay::Scanners::Clojure::EXP_MARK = T.let(T.unsafe(nil), Regexp)
1369
- CodeRay::Scanners::Clojure::IDENTIFIER = T.let(T.unsafe(nil), Regexp)
1370
- CodeRay::Scanners::Clojure::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1371
- CodeRay::Scanners::Clojure::IMAG10 = T.let(T.unsafe(nil), Regexp)
1372
- CodeRay::Scanners::Clojure::IMAG16 = T.let(T.unsafe(nil), Regexp)
1373
- CodeRay::Scanners::Clojure::IMAG2 = T.let(T.unsafe(nil), Regexp)
1374
- CodeRay::Scanners::Clojure::IMAG8 = T.let(T.unsafe(nil), Regexp)
1375
- CodeRay::Scanners::Clojure::KEYWORD_NEXT_TOKEN_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1376
- CodeRay::Scanners::Clojure::NUM = T.let(T.unsafe(nil), Regexp)
1377
- CodeRay::Scanners::Clojure::NUM10 = T.let(T.unsafe(nil), Regexp)
1378
- CodeRay::Scanners::Clojure::NUM16 = T.let(T.unsafe(nil), Regexp)
1379
- CodeRay::Scanners::Clojure::NUM2 = T.let(T.unsafe(nil), Regexp)
1380
- CodeRay::Scanners::Clojure::NUM8 = T.let(T.unsafe(nil), Regexp)
1381
- CodeRay::Scanners::Clojure::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1382
- CodeRay::Scanners::Clojure::PREFIX10 = T.let(T.unsafe(nil), Regexp)
1383
- CodeRay::Scanners::Clojure::PREFIX16 = T.let(T.unsafe(nil), Regexp)
1384
- CodeRay::Scanners::Clojure::PREFIX2 = T.let(T.unsafe(nil), Regexp)
1385
- CodeRay::Scanners::Clojure::PREFIX8 = T.let(T.unsafe(nil), Regexp)
1386
- CodeRay::Scanners::Clojure::RADIX10 = T.let(T.unsafe(nil), Regexp)
1387
- CodeRay::Scanners::Clojure::RADIX16 = T.let(T.unsafe(nil), Regexp)
1388
- CodeRay::Scanners::Clojure::RADIX2 = T.let(T.unsafe(nil), Regexp)
1389
- CodeRay::Scanners::Clojure::RADIX8 = T.let(T.unsafe(nil), Regexp)
1390
- CodeRay::Scanners::Clojure::REAL10 = T.let(T.unsafe(nil), Regexp)
1391
- CodeRay::Scanners::Clojure::REAL16 = T.let(T.unsafe(nil), Regexp)
1392
- CodeRay::Scanners::Clojure::REAL2 = T.let(T.unsafe(nil), Regexp)
1393
- CodeRay::Scanners::Clojure::REAL8 = T.let(T.unsafe(nil), Regexp)
1394
- CodeRay::Scanners::Clojure::SIGN = T.let(T.unsafe(nil), Regexp)
1395
- CodeRay::Scanners::Clojure::SPECIAL_FORMS = T.let(T.unsafe(nil), Array)
1396
- CodeRay::Scanners::Clojure::SUFFIX = T.let(T.unsafe(nil), Regexp)
1397
- CodeRay::Scanners::Clojure::SYMBOL = T.let(T.unsafe(nil), Regexp)
1398
- CodeRay::Scanners::Clojure::UINT10 = T.let(T.unsafe(nil), Regexp)
1399
- CodeRay::Scanners::Clojure::UINT16 = T.let(T.unsafe(nil), Regexp)
1400
- CodeRay::Scanners::Clojure::UINT2 = T.let(T.unsafe(nil), Regexp)
1401
- CodeRay::Scanners::Clojure::UINT8 = T.let(T.unsafe(nil), Regexp)
1402
- CodeRay::Scanners::Clojure::UREAL10 = T.let(T.unsafe(nil), Regexp)
1403
- CodeRay::Scanners::Clojure::UREAL16 = T.let(T.unsafe(nil), Regexp)
1404
- CodeRay::Scanners::Clojure::UREAL2 = T.let(T.unsafe(nil), Regexp)
1405
- CodeRay::Scanners::Clojure::UREAL8 = T.let(T.unsafe(nil), Regexp)
1406
-
1407
- # = Debug Scanner
1408
- #
1409
- # Interprets the output of the Encoders::Debug encoder (basically the inverse function).
1410
- class CodeRay::Scanners::Debug < ::CodeRay::Scanners::Scanner
1411
- protected
1412
-
1413
- def scan_tokens(encoder, options); end
1414
- def setup; end
1415
- end
1416
-
1417
- # Scanner for the Delphi language (Object Pascal).
1418
- #
1419
- # Alias: +pascal+
1420
- class CodeRay::Scanners::Delphi < ::CodeRay::Scanners::Scanner
1421
- protected
1422
-
1423
- def scan_tokens(encoder, options); end
1424
- end
1425
-
1426
- CodeRay::Scanners::Delphi::DIRECTIVES = T.let(T.unsafe(nil), Array)
1427
- CodeRay::Scanners::Delphi::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList::CaseIgnoring)
1428
- CodeRay::Scanners::Delphi::KEYWORDS = T.let(T.unsafe(nil), Array)
1429
- CodeRay::Scanners::Delphi::NAME_FOLLOWS = T.let(T.unsafe(nil), CodeRay::WordList::CaseIgnoring)
1430
-
1431
- # Scanner for output of the diff command.
1432
- #
1433
- # Alias: +patch+
1434
- class CodeRay::Scanners::Diff < ::CodeRay::Scanners::Scanner
1435
- protected
1436
-
1437
- def scan_tokens(encoder, options); end
1438
-
1439
- private
1440
-
1441
- def diff(a, b); end
1442
- end
1443
-
1444
- CodeRay::Scanners::Diff::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
1445
-
1446
- # Scanner for HTML ERB templates.
1447
- class CodeRay::Scanners::ERB < ::CodeRay::Scanners::Scanner
1448
- protected
1449
-
1450
- def reset_instance; end
1451
- def scan_tokens(encoder, options); end
1452
- def setup; end
1453
- end
1454
-
1455
- CodeRay::Scanners::ERB::ERB_RUBY_BLOCK = T.let(T.unsafe(nil), Regexp)
1456
- CodeRay::Scanners::ERB::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1457
- CodeRay::Scanners::ERB::START_OF_ERB = T.let(T.unsafe(nil), Regexp)
1458
-
1459
- class CodeRay::Scanners::Go < ::CodeRay::Scanners::Scanner
1460
- protected
1461
-
1462
- def scan_tokens(encoder, options); end
1463
- end
1464
-
1465
- CodeRay::Scanners::Go::ESCAPE = T.let(T.unsafe(nil), Regexp)
1466
- CodeRay::Scanners::Go::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1467
-
1468
- # http://golang.org/ref/spec#Keywords
1469
- CodeRay::Scanners::Go::KEYWORDS = T.let(T.unsafe(nil), Array)
1470
-
1471
- CodeRay::Scanners::Go::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1472
- CodeRay::Scanners::Go::PREDEFINED_FUNCTIONS = T.let(T.unsafe(nil), Array)
1473
-
1474
- # http://golang.org/ref/spec#Types
1475
- CodeRay::Scanners::Go::PREDEFINED_TYPES = T.let(T.unsafe(nil), Array)
1476
-
1477
- CodeRay::Scanners::Go::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1478
-
1479
- # Scanner for Groovy.
1480
- class CodeRay::Scanners::Groovy < ::CodeRay::Scanners::Java
1481
- protected
1482
-
1483
- def scan_tokens(encoder, options); end
1484
- def setup; end
1485
- end
1486
-
1487
- CodeRay::Scanners::Groovy::ESCAPE = T.let(T.unsafe(nil), Regexp)
1488
-
1489
- # TODO: check list of keywords
1490
- CodeRay::Scanners::Groovy::GROOVY_KEYWORDS = T.let(T.unsafe(nil), Array)
1491
-
1492
- CodeRay::Scanners::Groovy::GROOVY_MAGIC_VARIABLES = T.let(T.unsafe(nil), Array)
1493
- CodeRay::Scanners::Groovy::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1494
- CodeRay::Scanners::Groovy::KEYWORDS_EXPECTING_VALUE = T.let(T.unsafe(nil), CodeRay::WordList)
1495
- CodeRay::Scanners::Groovy::REGEXP_ESCAPE = T.let(T.unsafe(nil), Regexp)
1496
-
1497
- # TODO: interpretation inside ', ", /
1498
- CodeRay::Scanners::Groovy::STRING_CONTENT_PATTERN = T.let(T.unsafe(nil), Hash)
1499
-
1500
- CodeRay::Scanners::Groovy::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1501
-
1502
- class CodeRay::Scanners::HAML < ::CodeRay::Scanners::Scanner
1503
- protected
1504
-
1505
- def scan_tokens(encoder, options); end
1506
- def setup; end
1507
- end
1508
-
1509
- CodeRay::Scanners::HAML::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1510
-
1511
- # HTML Scanner
1512
- #
1513
- # Alias: +xhtml+
1514
- #
1515
- # See also: Scanners::XML
1516
- class CodeRay::Scanners::HTML < ::CodeRay::Scanners::Scanner
1517
- def reset; end
1518
-
1519
- protected
1520
-
1521
- def scan_css(encoder, code, state = T.unsafe(nil)); end
1522
- def scan_java_script(encoder, code); end
1523
- def scan_tokens(encoder, options); end
1524
- def setup; end
1525
- end
1526
-
1527
- CodeRay::Scanners::HTML::ATTR_NAME = T.let(T.unsafe(nil), Regexp)
1528
- CodeRay::Scanners::HTML::ENTITY = T.let(T.unsafe(nil), Regexp)
1529
- CodeRay::Scanners::HTML::EVENT_ATTRIBUTES = T.let(T.unsafe(nil), Array)
1530
- CodeRay::Scanners::HTML::HEX = T.let(T.unsafe(nil), Regexp)
1531
- CodeRay::Scanners::HTML::IN_ATTRIBUTE = T.let(T.unsafe(nil), CodeRay::WordList::CaseIgnoring)
1532
- CodeRay::Scanners::HTML::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1533
- CodeRay::Scanners::HTML::PLAIN_STRING_CONTENT = T.let(T.unsafe(nil), Hash)
1534
- CodeRay::Scanners::HTML::TAG_END = T.let(T.unsafe(nil), Regexp)
1535
-
1536
- # Scanner for JSON (JavaScript Object Notation).
1537
- class CodeRay::Scanners::JSON < ::CodeRay::Scanners::Scanner
1538
- protected
1539
-
1540
- # See http://json.org/ for a definition of the JSON lexic/grammar.
1541
- def scan_tokens(encoder, options); end
1542
-
1543
- def setup; end
1544
- end
1545
-
1546
- CodeRay::Scanners::JSON::ESCAPE = T.let(T.unsafe(nil), Regexp)
1547
- CodeRay::Scanners::JSON::KEY = T.let(T.unsafe(nil), Regexp)
1548
- CodeRay::Scanners::JSON::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1549
- CodeRay::Scanners::JSON::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1550
-
1551
- # Scanner for Java.
1552
- class CodeRay::Scanners::Java < ::CodeRay::Scanners::Scanner
1553
- protected
1554
-
1555
- def scan_tokens(encoder, options); end
1556
- end
1557
-
1558
- module CodeRay::Scanners::Java::BuiltinTypes; end
1559
- CodeRay::Scanners::Java::BuiltinTypes::List = T.let(T.unsafe(nil), Array)
1560
- CodeRay::Scanners::Java::CONSTANTS = T.let(T.unsafe(nil), Array)
1561
- CodeRay::Scanners::Java::DIRECTIVES = T.let(T.unsafe(nil), Array)
1562
- CodeRay::Scanners::Java::ESCAPE = T.let(T.unsafe(nil), Regexp)
1563
- CodeRay::Scanners::Java::IDENT = T.let(T.unsafe(nil), Regexp)
1564
- CodeRay::Scanners::Java::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1565
-
1566
- # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
1567
- CodeRay::Scanners::Java::KEYWORDS = T.let(T.unsafe(nil), Array)
1568
-
1569
- CodeRay::Scanners::Java::MAGIC_VARIABLES = T.let(T.unsafe(nil), Array)
1570
- CodeRay::Scanners::Java::RESERVED = T.let(T.unsafe(nil), Array)
1571
- CodeRay::Scanners::Java::STRING_CONTENT_PATTERN = T.let(T.unsafe(nil), Hash)
1572
- CodeRay::Scanners::Java::TYPES = T.let(T.unsafe(nil), Array)
1573
- CodeRay::Scanners::Java::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1574
-
1575
- # Scanner for JavaScript.
1576
- #
1577
- # Aliases: +ecmascript+, +ecma_script+, +javascript+
1578
- class CodeRay::Scanners::JavaScript < ::CodeRay::Scanners::Scanner
1579
- protected
1580
-
1581
- def reset_instance; end
1582
- def scan_tokens(encoder, options); end
1583
- def setup; end
1584
- def xml_scanner; end
1585
- end
1586
-
1587
- CodeRay::Scanners::JavaScript::ESCAPE = T.let(T.unsafe(nil), Regexp)
1588
- CodeRay::Scanners::JavaScript::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1589
-
1590
- # The actual JavaScript keywords.
1591
- CodeRay::Scanners::JavaScript::KEYWORDS = T.let(T.unsafe(nil), Array)
1592
-
1593
- CodeRay::Scanners::JavaScript::KEYWORDS_EXPECTING_VALUE = T.let(T.unsafe(nil), CodeRay::WordList)
1594
- CodeRay::Scanners::JavaScript::KEY_CHECK_PATTERN = T.let(T.unsafe(nil), Hash)
1595
- CodeRay::Scanners::JavaScript::MAGIC_VARIABLES = T.let(T.unsafe(nil), Array)
1596
- CodeRay::Scanners::JavaScript::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1597
- CodeRay::Scanners::JavaScript::REGEXP_ESCAPE = T.let(T.unsafe(nil), Regexp)
1598
-
1599
- # Reserved for future use.
1600
- CodeRay::Scanners::JavaScript::RESERVED_WORDS = T.let(T.unsafe(nil), Array)
1601
-
1602
- CodeRay::Scanners::JavaScript::STRING_CONTENT_PATTERN = T.let(T.unsafe(nil), Hash)
1603
- CodeRay::Scanners::JavaScript::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1604
-
1605
- # Scanner for the Lua[http://lua.org] programming lanuage.
1606
- #
1607
- # The language’s complete syntax is defined in
1608
- # {the Lua manual}[http://www.lua.org/manual/5.2/manual.html],
1609
- # which is what this scanner tries to conform to.
1610
- class CodeRay::Scanners::Lua < ::CodeRay::Scanners::Scanner
1611
- protected
1612
-
1613
- # CodeRay entry hook. Starts parsing.
1614
- def scan_tokens(encoder, options); end
1615
-
1616
- # Scanner initialization.
1617
- def setup; end
1618
- end
1619
-
1620
- # Automatic token kind selection for normal words.
1621
- CodeRay::Scanners::Lua::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1622
-
1623
- # Keywords used in Lua.
1624
- CodeRay::Scanners::Lua::KEYWORDS = T.let(T.unsafe(nil), Array)
1625
-
1626
- # Constants set by the Lua core.
1627
- CodeRay::Scanners::Lua::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1628
-
1629
- # The expressions contained in this array are parts of Lua’s `basic'
1630
- # library. Although it’s not entirely necessary to load that library,
1631
- # it is highly recommended and one would have to provide own implementations
1632
- # of some of these expressions if one does not do so. They however aren’t
1633
- # keywords, neither are they constants, but nearly predefined, so they
1634
- # get tagged as `predefined' rather than anything else.
1635
- #
1636
- # This list excludes values of form `_UPPERCASE' because the Lua manual
1637
- # requires such identifiers to be reserved by Lua anyway and they are
1638
- # highlighted directly accordingly, without the need for specific
1639
- # identifiers to be listed here.
1640
- CodeRay::Scanners::Lua::PREDEFINED_EXPRESSIONS = T.let(T.unsafe(nil), Array)
1641
-
1642
- # Scanner for PHP.
1643
- #
1644
- # Original by Stefan Walk.
1645
- class CodeRay::Scanners::PHP < ::CodeRay::Scanners::Scanner
1646
- protected
1647
-
1648
- def reset_instance; end
1649
- def scan_tokens(encoder, options); end
1650
- def setup; end
1651
- end
1652
-
1653
- CodeRay::Scanners::PHP::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1654
- module CodeRay::Scanners::PHP::RE; end
1655
- CodeRay::Scanners::PHP::RE::HTML_INDICATOR = T.let(T.unsafe(nil), Regexp)
1656
- CodeRay::Scanners::PHP::RE::IDENTIFIER = T.let(T.unsafe(nil), Regexp)
1657
- CodeRay::Scanners::PHP::RE::OPERATOR = T.let(T.unsafe(nil), Regexp)
1658
- CodeRay::Scanners::PHP::RE::PHP_END = T.let(T.unsafe(nil), Regexp)
1659
- CodeRay::Scanners::PHP::RE::PHP_START = T.let(T.unsafe(nil), Regexp)
1660
- CodeRay::Scanners::PHP::RE::VARIABLE = T.let(T.unsafe(nil), Regexp)
1661
- module CodeRay::Scanners::PHP::Words; end
1662
-
1663
- # according to http://php.net/quickref.php on 2009-04-21;
1664
- # all functions with _ excluded (module functions) and selected additional functions
1665
- CodeRay::Scanners::PHP::Words::BUILTIN_FUNCTIONS = T.let(T.unsafe(nil), Array)
1666
-
1667
- CodeRay::Scanners::PHP::Words::CLASSES = T.let(T.unsafe(nil), Array)
1668
- CodeRay::Scanners::PHP::Words::CONSTANTS = T.let(T.unsafe(nil), Array)
1669
-
1670
- # TODO: more built-in PHP functions?
1671
- CodeRay::Scanners::PHP::Words::EXCEPTIONS = T.let(T.unsafe(nil), Array)
1672
-
1673
- CodeRay::Scanners::PHP::Words::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList::CaseIgnoring)
1674
-
1675
- # according to http://www.php.net/manual/en/reserved.keywords.php
1676
- CodeRay::Scanners::PHP::Words::KEYWORDS = T.let(T.unsafe(nil), Array)
1677
-
1678
- CodeRay::Scanners::PHP::Words::LANGUAGE_CONSTRUCTS = T.let(T.unsafe(nil), Array)
1679
- CodeRay::Scanners::PHP::Words::PREDEFINED = T.let(T.unsafe(nil), Array)
1680
- CodeRay::Scanners::PHP::Words::TYPES = T.let(T.unsafe(nil), Array)
1681
- CodeRay::Scanners::PHP::Words::VARIABLE_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1682
-
1683
- # Scanner for Python. Supports Python 3.
1684
- #
1685
- # Based on pygments' PythonLexer, see
1686
- # http://dev.pocoo.org/projects/pygments/browser/pygments/lexers/agile.py.
1687
- class CodeRay::Scanners::Python < ::CodeRay::Scanners::Scanner
1688
- protected
1689
-
1690
- def scan_tokens(encoder, options); end
1691
- end
1692
-
1693
- CodeRay::Scanners::Python::DEF_NEW_STATE = T.let(T.unsafe(nil), CodeRay::WordList)
1694
- CodeRay::Scanners::Python::DESCRIPTOR = T.let(T.unsafe(nil), Regexp)
1695
- CodeRay::Scanners::Python::DOCSTRING_COMING = T.let(T.unsafe(nil), Regexp)
1696
- CodeRay::Scanners::Python::ESCAPE = T.let(T.unsafe(nil), Regexp)
1697
- CodeRay::Scanners::Python::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1698
- CodeRay::Scanners::Python::KEYWORDS = T.let(T.unsafe(nil), Array)
1699
- CodeRay::Scanners::Python::NAME = T.let(T.unsafe(nil), Regexp)
1700
- CodeRay::Scanners::Python::OLD_KEYWORDS = T.let(T.unsafe(nil), Array)
1701
- CodeRay::Scanners::Python::OPERATOR = T.let(T.unsafe(nil), Regexp)
1702
- CodeRay::Scanners::Python::PREDEFINED_EXCEPTIONS = T.let(T.unsafe(nil), Array)
1703
- CodeRay::Scanners::Python::PREDEFINED_METHODS_AND_TYPES = T.let(T.unsafe(nil), Array)
1704
- CodeRay::Scanners::Python::PREDEFINED_VARIABLES_AND_CONSTANTS = T.let(T.unsafe(nil), Array)
1705
- CodeRay::Scanners::Python::STRING_CONTENT_REGEXP = T.let(T.unsafe(nil), Hash)
1706
- CodeRay::Scanners::Python::STRING_DELIMITER_REGEXP = T.let(T.unsafe(nil), Hash)
1707
- CodeRay::Scanners::Python::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1708
-
1709
- # = Raydebug Scanner
1710
- #
1711
- # Highlights the output of the Encoders::Debug encoder.
1712
- class CodeRay::Scanners::Raydebug < ::CodeRay::Scanners::Scanner
1713
- protected
1714
-
1715
- def scan_tokens(encoder, options); end
1716
- def setup; end
1717
- end
1718
-
1719
- # This scanner is really complex, since Ruby _is_ a complex language!
1720
- #
1721
- # It tries to highlight 100% of all common code,
1722
- # and 90% of strange codes.
1723
- #
1724
- # It is optimized for HTML highlighting, and is not very useful for
1725
- # parsing or pretty printing.
1726
- class CodeRay::Scanners::Ruby < ::CodeRay::Scanners::Scanner
1727
- def interpreted_string_state; end
1728
-
1729
- protected
1730
-
1731
- def scan_tokens(encoder, options); end
1732
- def setup; end
1733
- end
1734
-
1735
- module CodeRay::Scanners::Ruby::Patterns; end
1736
- CodeRay::Scanners::Ruby::Patterns::BINARY = T.let(T.unsafe(nil), Regexp)
1737
- CodeRay::Scanners::Ruby::Patterns::CHARACTER = T.let(T.unsafe(nil), Regexp)
1738
- CodeRay::Scanners::Ruby::Patterns::CLASS_VARIABLE = T.let(T.unsafe(nil), Regexp)
1739
- CodeRay::Scanners::Ruby::Patterns::CONTROL_META_ESCAPE = T.let(T.unsafe(nil), Regexp)
1740
- CodeRay::Scanners::Ruby::Patterns::DATA = T.let(T.unsafe(nil), Regexp)
1741
- CodeRay::Scanners::Ruby::Patterns::DECIMAL = T.let(T.unsafe(nil), Regexp)
1742
- CodeRay::Scanners::Ruby::Patterns::ESCAPE = T.let(T.unsafe(nil), Regexp)
1743
- CodeRay::Scanners::Ruby::Patterns::EXPONENT = T.let(T.unsafe(nil), Regexp)
1744
- CodeRay::Scanners::Ruby::Patterns::FANCY_STRING_INTERPRETED = T.let(T.unsafe(nil), Hash)
1745
- CodeRay::Scanners::Ruby::Patterns::FANCY_STRING_KIND = T.let(T.unsafe(nil), Hash)
1746
- CodeRay::Scanners::Ruby::Patterns::FANCY_STRING_START = T.let(T.unsafe(nil), Regexp)
1747
- CodeRay::Scanners::Ruby::Patterns::FLOAT_OR_INT = T.let(T.unsafe(nil), Regexp)
1748
- CodeRay::Scanners::Ruby::Patterns::FLOAT_SUFFIX = T.let(T.unsafe(nil), Regexp)
1749
- CodeRay::Scanners::Ruby::Patterns::GLOBAL_VARIABLE = T.let(T.unsafe(nil), Regexp)
1750
-
1751
- # NOTE: This is not completely correct, but
1752
- # nobody needs heredoc delimiters ending with \n.
1753
- CodeRay::Scanners::Ruby::Patterns::HEREDOC_OPEN = T.let(T.unsafe(nil), Regexp)
1754
-
1755
- CodeRay::Scanners::Ruby::Patterns::HEXADECIMAL = T.let(T.unsafe(nil), Regexp)
1756
- CodeRay::Scanners::Ruby::Patterns::IDENT = T.let(T.unsafe(nil), Regexp)
1757
- CodeRay::Scanners::Ruby::Patterns::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList)
1758
- CodeRay::Scanners::Ruby::Patterns::INSTANCE_VARIABLE = T.let(T.unsafe(nil), Regexp)
1759
- CodeRay::Scanners::Ruby::Patterns::KEYWORDS = T.let(T.unsafe(nil), Array)
1760
- CodeRay::Scanners::Ruby::Patterns::KEYWORDS_EXPECTING_VALUE = T.let(T.unsafe(nil), CodeRay::WordList)
1761
- CodeRay::Scanners::Ruby::Patterns::KEYWORD_NEW_STATE = T.let(T.unsafe(nil), CodeRay::WordList)
1762
- CodeRay::Scanners::Ruby::Patterns::METHOD_AFTER_DOT = T.let(T.unsafe(nil), Regexp)
1763
- CodeRay::Scanners::Ruby::Patterns::METHOD_NAME = T.let(T.unsafe(nil), Regexp)
1764
- CodeRay::Scanners::Ruby::Patterns::METHOD_NAME_EX = T.let(T.unsafe(nil), Regexp)
1765
- CodeRay::Scanners::Ruby::Patterns::METHOD_NAME_OPERATOR = T.let(T.unsafe(nil), Regexp)
1766
- CodeRay::Scanners::Ruby::Patterns::METHOD_NAME_OR_SYMBOL = T.let(T.unsafe(nil), Regexp)
1767
- CodeRay::Scanners::Ruby::Patterns::METHOD_SUFFIX = T.let(T.unsafe(nil), Regexp)
1768
- CodeRay::Scanners::Ruby::Patterns::NUMERIC = T.let(T.unsafe(nil), Regexp)
1769
- CodeRay::Scanners::Ruby::Patterns::OBJECT_VARIABLE = T.let(T.unsafe(nil), Regexp)
1770
- CodeRay::Scanners::Ruby::Patterns::OCTAL = T.let(T.unsafe(nil), Regexp)
1771
-
1772
- # See http://murfy.de/ruby-constants.
1773
- CodeRay::Scanners::Ruby::Patterns::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1774
-
1775
- CodeRay::Scanners::Ruby::Patterns::PREFIX_VARIABLE = T.let(T.unsafe(nil), Regexp)
1776
- CodeRay::Scanners::Ruby::Patterns::QUOTE_TO_TYPE = T.let(T.unsafe(nil), Hash)
1777
- CodeRay::Scanners::Ruby::Patterns::REGEXP_MODIFIERS = T.let(T.unsafe(nil), Regexp)
1778
- CodeRay::Scanners::Ruby::Patterns::RUBYDOC = T.let(T.unsafe(nil), Regexp)
1779
- CodeRay::Scanners::Ruby::Patterns::RUBYDOC_OR_DATA = T.let(T.unsafe(nil), Regexp)
1780
- CodeRay::Scanners::Ruby::Patterns::SIMPLE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1781
- CodeRay::Scanners::Ruby::Patterns::SYMBOL = T.let(T.unsafe(nil), Regexp)
1782
-
1783
- # Checks for a valid value to follow. This enables
1784
- # value_expected in method calls without parentheses.
1785
- CodeRay::Scanners::Ruby::Patterns::VALUE_FOLLOWS = T.let(T.unsafe(nil), Regexp)
1786
-
1787
- CodeRay::Scanners::Ruby::Patterns::VARIABLE = T.let(T.unsafe(nil), Regexp)
1788
-
1789
- class CodeRay::Scanners::Ruby::StringState < ::Struct
1790
- # @return [StringState] a new instance of StringState
1791
- def initialize(kind, interpreted, delim, heredoc = T.unsafe(nil)); end
1792
-
1793
- def heredoc_pattern(delim, interpreted, indented); end
1794
-
1795
- class << self
1796
- def simple_key_pattern(delim); end
1797
- end
1798
- end
1799
-
1800
- CodeRay::Scanners::Ruby::StringState::CLOSING_PAREN = T.let(T.unsafe(nil), Hash)
1801
- CodeRay::Scanners::Ruby::StringState::STRING_PATTERN = T.let(T.unsafe(nil), Hash)
1802
-
1803
- # by Josh Goebel
1804
- class CodeRay::Scanners::SQL < ::CodeRay::Scanners::Scanner
1805
- def scan_tokens(encoder, options); end
1806
- end
1807
-
1808
- CodeRay::Scanners::SQL::COMMANDS = T.let(T.unsafe(nil), Array)
1809
- CodeRay::Scanners::SQL::DIRECTIVES = T.let(T.unsafe(nil), Array)
1810
- CodeRay::Scanners::SQL::ESCAPE = T.let(T.unsafe(nil), Regexp)
1811
- CodeRay::Scanners::SQL::IDENT_KIND = T.let(T.unsafe(nil), CodeRay::WordList::CaseIgnoring)
1812
- CodeRay::Scanners::SQL::KEYWORDS = T.let(T.unsafe(nil), Array)
1813
- CodeRay::Scanners::SQL::OBJECTS = T.let(T.unsafe(nil), Array)
1814
- CodeRay::Scanners::SQL::PREDEFINED_CONSTANTS = T.let(T.unsafe(nil), Array)
1815
- CodeRay::Scanners::SQL::PREDEFINED_FUNCTIONS = T.let(T.unsafe(nil), Array)
1816
- CodeRay::Scanners::SQL::PREDEFINED_TYPES = T.let(T.unsafe(nil), Array)
1817
- CodeRay::Scanners::SQL::STRING_CONTENT_PATTERN = T.let(T.unsafe(nil), Hash)
1818
- CodeRay::Scanners::SQL::STRING_PREFIXES = T.let(T.unsafe(nil), Regexp)
1819
- CodeRay::Scanners::SQL::UNICODE_ESCAPE = T.let(T.unsafe(nil), Regexp)
1820
-
1821
- # A scanner for Sass.
1822
- class CodeRay::Scanners::Sass < ::CodeRay::Scanners::CSS
1823
- protected
1824
-
1825
- def scan_tokens(encoder, options); end
1826
- def setup; end
1827
- end
1828
-
1829
- # = Scanner
1830
- #
1831
- # The base class for all Scanners.
1832
- #
1833
- # It is a subclass of Ruby's great +StringScanner+, which
1834
- # makes it easy to access the scanning methods inside.
1835
- #
1836
- # It is also +Enumerable+, so you can use it like an Array of
1837
- # Tokens:
1838
- #
1839
- # require 'coderay'
1840
- #
1841
- # c_scanner = CodeRay::Scanners[:c].new "if (*p == '{') nest++;"
1842
- #
1843
- # for text, kind in c_scanner
1844
- # puts text if kind == :operator
1845
- # end
1846
- #
1847
- # # prints: (*==)++;
1848
- #
1849
- # OK, this is a very simple example :)
1850
- # You can also use +map+, +any?+, +find+ and even +sort_by+,
1851
- # if you want.
1852
- class CodeRay::Scanners::Scanner < ::StringScanner
1853
- include ::Enumerable
1854
- extend ::CodeRay::Plugin
1855
-
1856
- # Create a new Scanner.
1857
- #
1858
- # * +code+ is the input String and is handled by the superclass
1859
- # StringScanner.
1860
- # * +options+ is a Hash with Symbols as keys.
1861
- # It is merged with the default options of the class (you can
1862
- # overwrite default options here.)
1863
- #
1864
- # Else, a Tokens object is used.
1865
- #
1866
- # @return [Scanner] a new instance of Scanner
1867
- def initialize(code = T.unsafe(nil), options = T.unsafe(nil)); end
1868
-
1869
- # The string in binary encoding.
1870
- #
1871
- # To be used with #pos, which is the index of the byte the scanner
1872
- # will scan next.
1873
- def binary_string; end
1874
-
1875
- # The current column position of the scanner, starting with 1.
1876
- # See also: #line.
1877
- def column(pos = T.unsafe(nil)); end
1878
-
1879
- # Traverse the tokens.
1880
- def each(&block); end
1881
-
1882
- # the default file extension for this scanner
1883
- def file_extension; end
1884
-
1885
- # the Plugin ID for this scanner
1886
- def lang; end
1887
-
1888
- # The current line position of the scanner, starting with 1.
1889
- # See also: #column.
1890
- #
1891
- # Beware, this is implemented inefficiently. It should be used
1892
- # for debugging only.
1893
- def line(pos = T.unsafe(nil)); end
1894
-
1895
- # Sets back the scanner. Subclasses should redefine the reset_instance
1896
- # method instead of this one.
1897
- def reset; end
1898
-
1899
- # Returns the value of attribute state.
1900
- def state; end
1901
-
1902
- # Sets the attribute state
1903
- #
1904
- # @param value the value to set the attribute state to.
1905
- def state=(_arg0); end
1906
-
1907
- # Set a new string to be scanned.
1908
- def string=(code); end
1909
-
1910
- # Scan the code and returns all tokens in a Tokens object.
1911
- def tokenize(source = T.unsafe(nil), options = T.unsafe(nil)); end
1912
-
1913
- # Cache the result of tokenize.
1914
- def tokens; end
1915
-
1916
- protected
1917
-
1918
- # Scanner error with additional status information
1919
- #
1920
- # @raise [ScanError]
1921
- def raise_inspect(message, tokens, state = T.unsafe(nil), ambit = T.unsafe(nil), backtrace = T.unsafe(nil)); end
1922
-
1923
- def raise_inspect_arguments(message, tokens, state, ambit); end
1924
-
1925
- # Resets the scanner.
1926
- def reset_instance; end
1927
-
1928
- # Shorthand for scan_until(/\z/).
1929
- # This method also avoids a JRuby 1.9 mode bug.
1930
- def scan_rest; end
1931
-
1932
- # This is the central method, and commonly the only one a
1933
- # subclass implements.
1934
- #
1935
- # Subclasses must implement this method; it must return +tokens+
1936
- # and must only use Tokens#<< for storing scanned tokens!
1937
- #
1938
- # @raise [NotImplementedError]
1939
- def scan_tokens(tokens, options); end
1940
-
1941
- def scanner_state_info(state); end
1942
- def set_string_from_source(source); end
1943
- def set_tokens_from_options(options); end
1944
-
1945
- # Can be implemented by subclasses to do some initialization
1946
- # that has to be done once per instance.
1947
- #
1948
- # Use reset for initialization that has to be done once per
1949
- # scan.
1950
- def setup; end
1951
-
1952
- def tokens_last(tokens, n); end
1953
- def tokens_size(tokens); end
1954
-
1955
- class << self
1956
- # The encoding used internally by this scanner.
1957
- def encoding(name = T.unsafe(nil)); end
1958
-
1959
- # The typical filename suffix for this scanner's language.
1960
- def file_extension(extension = T.unsafe(nil)); end
1961
-
1962
- # The lang of this Scanner class, which is equal to its Plugin ID.
1963
- def lang; end
1964
-
1965
- # Normalizes the given code into a string with UNIX newlines, in the
1966
- # scanner's internal encoding, with invalid and undefined charachters
1967
- # replaced by placeholders. Always returns a new object.
1968
- def normalize(code); end
1969
-
1970
- protected
1971
-
1972
- def encode_with_encoding(code, target_encoding); end
1973
- def guess_encoding(s); end
1974
- def to_unix(code); end
1975
- end
1976
- end
1977
-
1978
- # The default options for all scanner classes.
1979
- #
1980
- # Define @default_options for subclasses.
1981
- CodeRay::Scanners::Scanner::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
1982
-
1983
- CodeRay::Scanners::Scanner::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
1984
- CodeRay::Scanners::Scanner::PLUGIN_HOST = CodeRay::Scanners
1985
- CodeRay::Scanners::Scanner::SCANNER_STATE_INFO = T.let(T.unsafe(nil), String)
1986
- CodeRay::Scanners::Scanner::SCAN_ERROR_MESSAGE = T.let(T.unsafe(nil), String)
1987
-
1988
- # Raised if a Scanner fails while scanning
1989
- class CodeRay::Scanners::Scanner::ScanError < ::StandardError; end
1990
-
1991
- class CodeRay::Scanners::Taskpaper < ::CodeRay::Scanners::Scanner
1992
- protected
1993
-
1994
- def scan_tokens(encoder, options); end
1995
- end
1996
-
1997
- # Scanner for plain text.
1998
- #
1999
- # Yields just one token of the kind :plain.
2000
- #
2001
- # Alias: +plaintext+, +plain+
2002
- class CodeRay::Scanners::Text < ::CodeRay::Scanners::Scanner
2003
- protected
2004
-
2005
- def scan_tokens(encoder, options); end
2006
- end
2007
-
2008
- CodeRay::Scanners::Text::KINDS_NOT_LOC = T.let(T.unsafe(nil), Array)
2009
-
2010
- # Scanner for XML.
2011
- #
2012
- # Currently this is the same scanner as Scanners::HTML.
2013
- class CodeRay::Scanners::XML < ::CodeRay::Scanners::HTML; end
2014
-
2015
- # Scanner for YAML.
2016
- #
2017
- # Based on the YAML scanner from Syntax by Jamis Buck.
2018
- class CodeRay::Scanners::YAML < ::CodeRay::Scanners::Scanner
2019
- protected
2020
-
2021
- def scan_tokens(encoder, options); end
2022
- end
2023
-
2024
- CodeRay::Scanners::YAML::KINDS_NOT_LOC = T.let(T.unsafe(nil), Symbol)
2025
-
2026
- # This module holds the Style class and its subclasses.
2027
- #
2028
- # See Plugin.
2029
- module CodeRay::Styles
2030
- extend ::CodeRay::PluginHost
2031
- end
2032
-
2033
- # A colorful theme using CSS 3 colors (with alpha channel).
2034
- class CodeRay::Styles::Alpha < ::CodeRay::Styles::Style; end
2035
-
2036
- CodeRay::Styles::Alpha::CSS_MAIN_STYLES = T.let(T.unsafe(nil), String)
2037
- CodeRay::Styles::Alpha::TOKEN_COLORS = T.let(T.unsafe(nil), String)
2038
-
2039
- # Base class for styles.
2040
- #
2041
- # Styles are used by Encoders::HTML to colorize tokens.
2042
- class CodeRay::Styles::Style
2043
- extend ::CodeRay::Plugin
2044
- end
2045
-
2046
- CodeRay::Styles::Style::DEFAULT_OPTIONS = T.let(T.unsafe(nil), Hash)
2047
- CodeRay::Styles::Style::PLUGIN_HOST = CodeRay::Styles
2048
-
2049
- # A Hash of all known token kinds and their associated CSS classes.
2050
- CodeRay::TokenKinds = T.let(T.unsafe(nil), Hash)
2051
-
2052
- # The Tokens class represents a list of tokens returned from
2053
- # a Scanner. It's actually just an Array with a few helper methods.
2054
- #
2055
- # A token itself is not a special object, just two elements in an Array:
2056
- # * the _token_ _text_ (the original source of the token in a String) or
2057
- # a _token_ _action_ (begin_group, end_group, begin_line, end_line)
2058
- # * the _token_ _kind_ (a Symbol representing the type of the token)
2059
- #
2060
- # It looks like this:
2061
- #
2062
- # ..., '# It looks like this', :comment, ...
2063
- # ..., '3.1415926', :float, ...
2064
- # ..., '$^', :error, ...
2065
- #
2066
- # Some scanners also yield sub-tokens, represented by special
2067
- # token actions, for example :begin_group and :end_group.
2068
- #
2069
- # The Ruby scanner, for example, splits "a string" into:
2070
- #
2071
- # [
2072
- # :begin_group, :string,
2073
- # '"', :delimiter,
2074
- # 'a string', :content,
2075
- # '"', :delimiter,
2076
- # :end_group, :string
2077
- # ]
2078
- #
2079
- # Tokens can be used to save the output of a Scanners in a simple
2080
- # Ruby object that can be send to an Encoder later:
2081
- #
2082
- # tokens = CodeRay.scan('price = 2.59', :ruby).tokens
2083
- # tokens.encode(:html)
2084
- # tokens.html
2085
- # CodeRay.encoder(:html).encode_tokens(tokens)
2086
- #
2087
- # Tokens gives you the power to handle pre-scanned code very easily:
2088
- # You can serialize it to a JSON string and store it in a database, pass it
2089
- # around to encode it more than once, send it to other algorithms...
2090
- class CodeRay::Tokens < ::Array
2091
- def begin_group(kind); end
2092
- def begin_line(kind); end
2093
-
2094
- # Return the actual number of tokens.
2095
- def count; end
2096
-
2097
- # Encode the tokens using encoder.
2098
- #
2099
- # encoder can be
2100
- # * a plugin name like :html oder 'statistic'
2101
- # * an Encoder object
2102
- #
2103
- # options are passed to the encoder.
2104
- def encode(encoder, options = T.unsafe(nil)); end
2105
-
2106
- def end_group(kind); end
2107
- def end_line(kind); end
2108
-
2109
- # Redirects unknown methods to encoder calls.
2110
- #
2111
- # For example, if you call +tokens.html+, the HTML encoder
2112
- # is used to highlight the tokens.
2113
- def method_missing(meth, options = T.unsafe(nil)); end
2114
-
2115
- # The Scanner instance that created the tokens.
2116
- def scanner; end
2117
-
2118
- # The Scanner instance that created the tokens.
2119
- def scanner=(_arg0); end
2120
-
2121
- # Split the tokens into parts of the given +sizes+.
2122
- #
2123
- # The result will be an Array of Tokens objects. The parts have
2124
- # the text size specified by the parameter. In addition, each
2125
- # part closes all opened tokens. This is useful to insert tokens
2126
- # betweem them.
2127
- #
2128
- # This method is used by @Scanner#tokenize@ when called with an Array
2129
- # of source strings. The Diff encoder uses it for inline highlighting.
2130
- def split_into_parts(*sizes); end
2131
-
2132
- def text_token(*_arg0); end
2133
-
2134
- # Turn tokens into a string by concatenating them.
2135
- def to_s; end
2136
-
2137
- def tokens(*_arg0); end
2138
- end
2139
-
2140
- # The result of a scan operation is a TokensProxy, but should act like Tokens.
2141
- #
2142
- # This proxy makes it possible to use the classic CodeRay.scan.encode API
2143
- # while still providing the benefits of direct streaming.
2144
- class CodeRay::TokensProxy
2145
- # Create a new TokensProxy with the arguments of CodeRay.scan.
2146
- #
2147
- # @return [TokensProxy] a new instance of TokensProxy
2148
- def initialize(input, lang, options = T.unsafe(nil), block = T.unsafe(nil)); end
2149
-
2150
- # Returns the value of attribute block.
2151
- def block; end
2152
-
2153
- # Sets the attribute block
2154
- #
2155
- # @param value the value to set the attribute block to.
2156
- def block=(_arg0); end
2157
-
2158
- # Overwrite Struct#each.
2159
- def each(*args, &blk); end
2160
-
2161
- # Call CodeRay.encode if +encoder+ is a Symbol;
2162
- # otherwise, convert the receiver to tokens and call encoder.encode_tokens.
2163
- def encode(encoder, options = T.unsafe(nil)); end
2164
-
2165
- # Returns the value of attribute input.
2166
- def input; end
2167
-
2168
- # Sets the attribute input
2169
- #
2170
- # @param value the value to set the attribute input to.
2171
- def input=(_arg0); end
2172
-
2173
- # Returns the value of attribute lang.
2174
- def lang; end
2175
-
2176
- # Sets the attribute lang
2177
- #
2178
- # @param value the value to set the attribute lang to.
2179
- def lang=(_arg0); end
2180
-
2181
- # Tries to call encode;
2182
- # delegates to tokens otherwise.
2183
- def method_missing(method, *args, &blk); end
2184
-
2185
- # Returns the value of attribute options.
2186
- def options; end
2187
-
2188
- # Sets the attribute options
2189
- #
2190
- # @param value the value to set the attribute options to.
2191
- def options=(_arg0); end
2192
-
2193
- # A (cached) scanner instance to use for the scan task.
2194
- def scanner; end
2195
-
2196
- # The (cached) result of the tokenized input; a Tokens instance.
2197
- def tokens; end
2198
- end
2199
-
2200
- CodeRay::VERSION = T.let(T.unsafe(nil), String)
2201
-
2202
- # = WordList
2203
- #
2204
- # <b>A Hash subclass designed for mapping word lists to token types.</b>
2205
- #
2206
- # A WordList is a Hash with some additional features.
2207
- # It is intended to be used for keyword recognition.
2208
- #
2209
- # WordList is optimized to be used in Scanners,
2210
- # typically to decide whether a given ident is a special token.
2211
- #
2212
- # For case insensitive words use WordList::CaseIgnoring.
2213
- #
2214
- # Example:
2215
- #
2216
- # # define word arrays
2217
- # RESERVED_WORDS = %w[
2218
- # asm break case continue default do else
2219
- # ]
2220
- #
2221
- # PREDEFINED_TYPES = %w[
2222
- # int long short char void
2223
- # ]
2224
- #
2225
- # # make a WordList
2226
- # IDENT_KIND = WordList.new(:ident).
2227
- # add(RESERVED_WORDS, :reserved).
2228
- # add(PREDEFINED_TYPES, :predefined_type)
2229
- #
2230
- # ...
2231
- #
2232
- # def scan_tokens tokens, options
2233
- # ...
2234
- #
2235
- # elsif scan(/[A-Za-z_][A-Za-z_0-9]*/)
2236
- # # use it
2237
- # kind = IDENT_KIND[match]
2238
- # ...
2239
- class CodeRay::WordList < ::Hash
2240
- # Create a new WordList with +default+ as default value.
2241
- #
2242
- # @return [WordList] a new instance of WordList
2243
- def initialize(default = T.unsafe(nil)); end
2244
-
2245
- # Add words to the list and associate them with +value+.
2246
- #
2247
- # Returns +self+, so you can concat add calls.
2248
- def add(words, value = T.unsafe(nil)); end
2249
- end
2250
-
2251
- # A CaseIgnoring WordList is like a WordList, only that
2252
- # keys are compared case-insensitively (normalizing keys using +downcase+).
2253
- class CodeRay::WordList::CaseIgnoring < ::CodeRay::WordList
2254
- def [](key); end
2255
- def []=(key, value); end
2256
- end