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,
lib/ast/merge/comment/region.rb,
lib/ast/merge/comment/augmenter.rb,
lib/ast/merge/comment/attachment.rb,
lib/ast/merge/comment/capability.rb,
lib/ast/merge/comment/support_style.rb,
lib/ast/merge/comment/hash_tracker_base.rb,
lib/ast/merge/comment/region_merge_policy.rb,
lib/ast/merge/comment/c_style_tracker_base.rb,
lib/ast/merge/comment/tracked_hash_adapter.rb,
lib/ast/merge/comment/quoted_hash_line_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: Attachment, Augmenter, Block, CStyleTrackerBase, Capability, Empty, HashTrackerBase, Line, Parser, QuotedHashLineParser, Region, RegionMergePolicy, Style, SupportStyle, TrackedHashAdapter