@@ -11,7 +11,7 @@ module Opal
11
11
# Opal.compile "ruby_code"
12
12
# # => "string of javascript code"
13
13
#
14
- # @see [ Opal::Compiler.new] for compiler options
14
+ # @see Opal::Compiler.new for compiler options
15
15
#
16
16
# @param source [String] ruby source
17
17
# @param options [Hash] compiler options
@@ -21,27 +21,24 @@ def self.compile(source, options = {})
21
21
Compiler . new ( source , options ) . compile
22
22
end
23
23
24
- # [ Opal::Compiler] is the main class used to compile ruby to javascript code.
25
- # This class uses [ Opal::Parser] to gather the sexp syntax tree for the ruby
26
- # code, and then uses [ Opal::Node] to step through the sexp to generate valid
24
+ # { Opal::Compiler} is the main class used to compile ruby to javascript code.
25
+ # This class uses { Opal::Parser} to gather the sexp syntax tree for the ruby
26
+ # code, and then uses { Opal::Node} to step through the sexp to generate valid
27
27
# javascript.
28
28
#
29
29
# @example
30
+ # Opal::Compiler.new("ruby code").compile
31
+ # # => "javascript code"
30
32
#
31
- # Opal::Compiler.new("ruby code").compile
32
- # # => "javascript code"
33
+ # @example Accessing result
34
+ # compiler = Opal::Compiler.new("ruby_code")
35
+ # compiler.compile
36
+ # compiler.result # => "javascript code"
33
37
#
34
- # @example accessing result
35
- #
36
- # compiler = Opal::Compiler.new("ruby_code")
37
- # compiler.compile
38
- # compiler.result # => "javascript code"
39
- #
40
- # @example SourceMaps
41
- #
42
- # compiler = Opal::Compiler.new("")
43
- # compiler.compile
44
- # compiler.source_map # => #<SourceMap:>
38
+ # @example Source Maps
39
+ # compiler = Opal::Compiler.new("")
40
+ # compiler.compile
41
+ # compiler.source_map # => #<SourceMap:>
45
42
#
46
43
class Compiler
47
44
# Generated code gets indented with two spaces on each scope
@@ -62,24 +59,45 @@ def self.compiler_option(name, default_value, options = {})
62
59
end
63
60
end
64
61
65
- # used for __FILE__ directives as well as finding relative require()
62
+ # @!method file
63
+ #
64
+ # The filename to use for compiling this code. Used for __FILE__ directives
65
+ # as well as finding relative require()
66
+ #
67
+ # @return [String]
66
68
compiler_option :file , '(file)'
67
69
70
+ # @!method method_missing?
71
+ #
68
72
# adds method stubs for all used methods in file
73
+ #
74
+ # @return [Boolean]
69
75
compiler_option :method_missing , true , :as => :method_missing?
70
76
77
+ # @!method arity_check?
78
+ #
71
79
# adds an arity check to every method definition
80
+ #
81
+ # @return [Boolean]
72
82
compiler_option :arity_check , false , :as => :arity_check?
73
83
84
+ # @!method irb?
85
+ #
74
86
# compile top level local vars with support for irb style vars
75
87
compiler_option :irb , false , :as => :irb?
76
88
89
+ # @!method dynamic_require_severity
90
+ #
77
91
# how to handle dynamic requires (:error, :warning, :ignore)
78
92
compiler_option :dynamic_require_severity , :error , :valid_values => [ :error , :warning , :ignore ]
79
93
94
+ # @!method requirable?
95
+ #
80
96
# Prepare the code for future requires
81
97
compiler_option :requirable , false , :as => :requirable?
82
98
99
+ # @!method inline_operators?
100
+ #
83
101
# are operators compiled inline
84
102
compiler_option :inline_operators , false , :as => :inline_operators?
85
103
@@ -128,7 +146,7 @@ def source_map(source_file = nil)
128
146
Opal ::SourceMap . new ( @fragments , source_file || self . file )
129
147
end
130
148
131
- # Any helpers required by this file. Used by [ Opal::Nodes::Top] to reference
149
+ # Any helpers required by this file. Used by { Opal::Nodes::Top} to reference
132
150
# runtime helpers that are needed. These are used to minify resulting
133
151
# javascript by keeping a reference to helpers used.
134
152
#
@@ -276,7 +294,7 @@ def required_trees
276
294
#
277
295
# Sexps that need to be returned are passed to this method, and the
278
296
# alterned/new sexps are returned and should be used instead. Most
279
- # sexps can just be added into a s(:return) sexp, so that is the
297
+ # sexps can just be added into a ` s(:return) sexp` , so that is the
280
298
# default action if no special case is required.
281
299
def returns ( sexp )
282
300
return returns s ( :nil ) unless sexp
0 commit comments