Module: Ast::Merge::Comment

Defined in:
lib/ast/merge/comment.rb,
lib/ast/merge/comment/line.rb,
lib/ast/merge/comment/block.rb,
lib/ast/merge/comment/empty.rb,
lib/ast/merge/comment/style.rb,
lib/ast/merge/comment/parser.rb

Overview

Comment AST nodes for representing comment-only content.

This module provides generic, language-agnostic comment representation
that supports multiple comment syntax styles:

  • :hash_comment - Ruby/Python/YAML/Shell style (# comment)
  • :html_comment - HTML/XML/Markdown style (<!-- comment -->)
  • :c_style_line - C/JavaScript/Go line comments (// comment)
  • :c_style_block - C/JavaScript/CSS block comments (/* comment */)
  • :semicolon_comment - Lisp/Clojure/Assembly style (; comment)
  • :double_dash_comment - SQL/Haskell/Lua style (-- comment)

Examples:

Parsing Ruby-style comments

lines = ["# frozen_string_literal: true", "", "# Main comment"]
nodes = Comment::Parser.parse(lines, style: :hash_comment)

Parsing JavaScript-style comments

lines = ["// Header comment", "// continues here"]
nodes = Comment::Parser.parse(lines, style: :c_style_line)

Auto-detecting style

lines = ["<!-- HTML comment -->"]
nodes = Comment::Parser.parse(lines, style: :auto)

Defined Under Namespace

Classes: Block, Empty, Line, Parser, Style