From e9d6d2a57949541fd8775832b9ee55cf0df67006 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 25 Nov 2022 19:42:47 +0900 Subject: [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 --- ast.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'ast.rb') 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]], ...] -- cgit v1.2.3