Skip to content

Commit 67de707

Browse files
committedDec 7, 2014
Cleanup some docs formatting
1 parent a15ed49 commit 67de707

File tree

4 files changed

+46
-32
lines changed

4 files changed

+46
-32
lines changed
 

‎.yardopts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lib/opal.rb
2+
lib/opal/**/*.rb
13
--markup markdown
24
-
35
CHANGELOG.md

‎lib/opal/compiler.rb

+38-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Opal
1111
# Opal.compile "ruby_code"
1212
# # => "string of javascript code"
1313
#
14-
# @see [Opal::Compiler.new] for compiler options
14+
# @see Opal::Compiler.new for compiler options
1515
#
1616
# @param source [String] ruby source
1717
# @param options [Hash] compiler options
@@ -21,27 +21,24 @@ def self.compile(source, options = {})
2121
Compiler.new(source, options).compile
2222
end
2323

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
2727
# javascript.
2828
#
2929
# @example
30+
# Opal::Compiler.new("ruby code").compile
31+
# # => "javascript code"
3032
#
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"
3337
#
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:>
4542
#
4643
class Compiler
4744
# Generated code gets indented with two spaces on each scope
@@ -62,24 +59,45 @@ def self.compiler_option(name, default_value, options = {})
6259
end
6360
end
6461

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]
6668
compiler_option :file, '(file)'
6769

70+
# @!method method_missing?
71+
#
6872
# adds method stubs for all used methods in file
73+
#
74+
# @return [Boolean]
6975
compiler_option :method_missing, true, :as => :method_missing?
7076

77+
# @!method arity_check?
78+
#
7179
# adds an arity check to every method definition
80+
#
81+
# @return [Boolean]
7282
compiler_option :arity_check, false, :as => :arity_check?
7383

84+
# @!method irb?
85+
#
7486
# compile top level local vars with support for irb style vars
7587
compiler_option :irb, false, :as => :irb?
7688

89+
# @!method dynamic_require_severity
90+
#
7791
# how to handle dynamic requires (:error, :warning, :ignore)
7892
compiler_option :dynamic_require_severity, :error, :valid_values => [:error, :warning, :ignore]
7993

94+
# @!method requirable?
95+
#
8096
# Prepare the code for future requires
8197
compiler_option :requirable, false, :as => :requirable?
8298

99+
# @!method inline_operators?
100+
#
83101
# are operators compiled inline
84102
compiler_option :inline_operators, false, :as => :inline_operators?
85103

@@ -128,7 +146,7 @@ def source_map(source_file = nil)
128146
Opal::SourceMap.new(@fragments, source_file || self.file)
129147
end
130148

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
132150
# runtime helpers that are needed. These are used to minify resulting
133151
# javascript by keeping a reference to helpers used.
134152
#
@@ -276,7 +294,7 @@ def required_trees
276294
#
277295
# Sexps that need to be returned are passed to this method, and the
278296
# 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
280298
# default action if no special case is required.
281299
def returns(sexp)
282300
return returns s(:nil) unless sexp

‎lib/opal/parser.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
require 'opal/parser/parser_scope'
55

66
module Opal
7-
# [Parser] is used to parse a string of ruby code into a tree of [Opal::Sexp]
8-
# to represent the given ruby source code. The [Opal::Compiler] used this tree
7+
# {Parser} is used to parse a string of ruby code into a tree of {Opal::Sexp}
8+
# to represent the given ruby source code. The {Opal::Compiler} used this tree
99
# of sexp expressions, and turns them into the resulting javascript code.
1010
#
11-
# Usually, you would want to use [Opal::Compiler] directly, but this class
11+
# Usually, you would want to use {Opal::Compiler} directly, but this class
1212
# can be useful for debugging the compiler, as well as building tools around
1313
# the opal compiler to view the code structure.
1414
#
1515
# Invalid ruby code will raise an exception.
1616
#
17-
# @example
18-
#
1917
# Opal::Parser.new.parse "ruby code"
2018
# # => sexp tree
2119
#

‎lib/opal/parser/lexer.rb

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'opal/parser/keywords'
33

44
module Opal
5-
# [Opal::Lexer] is used by [Opal::Parser] to step through ruby code, and
5+
# {Opal::Lexer} is used by {Opal::Parser} to step through ruby code, and
66
# returning tokens representing each chunk of ruby code.
77
#
88
# Tokens are in the form:
@@ -13,11 +13,11 @@ module Opal
1313
# data can be used to produce source maps in the compiler. Tokens are
1414
# generally ruby symbols, and the value will always be a string value.
1515
#
16-
# The main method used by the parser is `next_token`, which is called
16+
# The main method used by the parser is {#next_token}, which is called
1717
# repeatedly until a token of value `false` is returned, which indicated the
1818
# EOF has been reached.
1919
#
20-
# Generally this class is only used by [Opal::Parser] directly.
20+
# Generally this class is only used by {Opal::Parser} directly.
2121
#
2222
class Lexer
2323

@@ -51,13 +51,10 @@ class Lexer
5151
# Create a new instance using the given ruby code and filename for
5252
# reference.
5353
#
54-
# @example
55-
#
5654
# Opal::Lexer.new("ruby code", "my_file.rb")
5755
#
5856
# @param source [String] ruby code to lex
5957
# @param file [String] filename of given ruby code
60-
#
6158
def initialize(source, file)
6259
@lex_state = :expr_beg
6360
@cond = 0
@@ -82,7 +79,6 @@ def initialize(source, file)
8279
# [token, [value, [source_line, source_column]]]
8380
#
8481
# @return [Array]
85-
#
8682
def next_token
8783
token = self.yylex
8884
value = self.yylval

0 commit comments

Comments
 (0)
Please sign in to comment.