1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Update documentation for Ripper.{lex,tokenize,sexp,sexp_raw} [ci skip]

This commit is contained in:
Jeremy Evans 2020-11-17 21:26:24 -08:00
parent cd0877a93e
commit 1301bd8ca9
2 changed files with 17 additions and 0 deletions

View file

@ -14,6 +14,11 @@ require 'ripper/core'
class Ripper class Ripper
# Tokenizes the Ruby program and returns an array of strings. # Tokenizes the Ruby program and returns an array of strings.
# The +filename+ and +lineno+ arguments are mostly ignored, since the
# return value is just the tokenized input.
# By default, this method does not handle syntax errors in +src+,
# ignoring tokens after the syntax error. Use the +raise_errors+ keyword
# to raise a SyntaxError for an error in +src+.
# #
# p Ripper.tokenize("def m(a) nil end") # p Ripper.tokenize("def m(a) nil end")
# # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"] # # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
@ -32,6 +37,10 @@ class Ripper
# Tokenizes the Ruby program and returns an array of an array, # Tokenizes the Ruby program and returns an array of an array,
# which is formatted like # which is formatted like
# <code>[[lineno, column], type, token, state]</code>. # <code>[[lineno, column], type, token, state]</code>.
# The +filename+ argument is mostly ignored.
# By default, this method does not handle syntax errors in +src+,
# ignoring tokens after the syntax error. Use the +raise_errors+ keyword
# to raise a SyntaxError for an error in +src+.
# #
# require 'ripper' # require 'ripper'
# require 'pp' # require 'pp'

View file

@ -17,6 +17,10 @@ class Ripper
# Parses +src+ and create S-exp tree. # Parses +src+ and create S-exp tree.
# Returns more readable tree rather than Ripper.sexp_raw. # Returns more readable tree rather than Ripper.sexp_raw.
# This method is mainly for developer use. # This method is mainly for developer use.
# The +filename+ argument is mostly ignored.
# By default, this method does not handle syntax errors in +src+,
# returning +nil+ in such cases. Use the +raise_errors+ keyword
# to raise a SyntaxError for an error in +src+.
# #
# require 'ripper' # require 'ripper'
# require 'pp' # require 'pp'
@ -43,6 +47,10 @@ class Ripper
# [EXPERIMENTAL] # [EXPERIMENTAL]
# Parses +src+ and create S-exp tree. # Parses +src+ and create S-exp tree.
# This method is mainly for developer use. # This method is mainly for developer use.
# The +filename+ argument is mostly ignored.
# By default, this method does not handle syntax errors in +src+,
# returning +nil+ in such cases. Use the +raise_errors+ keyword
# to raise a SyntaxError for an error in +src+.
# #
# require 'ripper' # require 'ripper'
# require 'pp' # require 'pp'