aboutsummaryrefslogtreecommitdiffstats
path: root/ast.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-25 19:42:47 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-25 19:42:47 +0900
commite9d6d2a57949541fd8775832b9ee55cf0df67006 (patch)
tree5eaea8068b81776597faa02baf67d34ffdd3baf6 /ast.rb
parentfb7598fb3e2b9da289556b0a4fa7c9e42e45121a (diff)
downloadruby-e9d6d2a57949541fd8775832b9ee55cf0df67006.tar.gz
[DOC] Fix AST documents
- Fix indents of `tokens`, to make the contents of Token a list - Move the example of `tokens` to separate from the above list - Markup keyword argument and method name
Diffstat (limited to 'ast.rb')
-rw-r--r--ast.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/ast.rb b/ast.rb
index 24740ebe28..2b803461ed 100644
--- a/ast.rb
+++ b/ast.rb
@@ -139,18 +139,19 @@ module RubyVM::AbstractSyntaxTree
# call-seq:
# node.tokens -> array
#
- # Returns tokens corresponding to the location of the node.
- # Returns nil if keep_tokens is not enabled when parse method is called.
- # Token is an array of:
- #
- # - id
- # - token type
- # - source code text
- # - location [first_lineno, first_column, last_lineno, last_column]
+ # Returns tokens corresponding to the location of the node.
+ # Returns +nil+ if +keep_tokens+ is not enabled when #parse method is called.
#
# root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2", keep_tokens: true)
# root.tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...]
# root.tokens.map{_1[2]}.join # => "x = 1 + 2"
+ #
+ # Token is an array of:
+ #
+ # - id
+ # - token type
+ # - source code text
+ # - location [ first_lineno, first_column, last_lineno, last_column ]
def tokens
return nil unless all_tokens
@@ -166,8 +167,8 @@ module RubyVM::AbstractSyntaxTree
# call-seq:
# node.all_tokens -> array
#
- # Returns all tokens for the input script regardless the receiver node.
- # Returns nil if keep_tokens is not enabled when parse method is called.
+ # Returns all tokens for the input script regardless the receiver node.
+ # Returns +nil+ if +keep_tokens+ is not enabled when #parse method is called.
#
# root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2", keep_tokens: true)
# root.all_tokens # => [[0, :tIDENTIFIER, "x", [1, 0, 1, 1]], [1, :tSP, " ", [1, 1, 1, 2]], ...]