parse_comments(source, **options) -> ArrayRuby 3.3 から[permalink][rdoc][edit]-
sourceを構文解析し、見つかったコメントを表すオブジェクトの配列を返します。配列の要素はPrism::InlineComment(# ...形式のコメント)またはPrism::EmbDocComment(=begin/=end形式のコメント)のインスタンスです。オプションは Prism?.parse と同じです。- [PARAM]
source: - 解析する Ruby プログラムの文字列を指定します。
- [PARAM]
options: - Prism?.parse を参照してください。
require "prism" comments = Prism.parse_comments("# hello\n1 + 1") p comments.size # => 1 p comments.first.class # => Prism::InlineComment p comments.first.location.slice # => "# hello"[SEE_ALSO] Prism::ParseResult#comments
- [PARAM]