struct KYAML::Doc

Overview

A container holding both a parsed K/YAML doc tree and its sister sidecar comments.

This is only useful for cases where comments must survive the parse -> emit process unmodified. Consumers who don't need/care about comments should use straight up KYAML.parse which produces a KYAML::Any tree without any comments and no scanner overhead.

Defined in:

kyaml/comment.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Struct

==(other : KYAML::Any) ==

Instance methods inherited from struct Value

==(other : KYAML::Any) ==

Instance methods inherited from class Object

to_kyaml(io : IO) : Nil
to_kyaml(builder : KYAML::Builder) : Nil
to_kyaml : String
to_kyaml

Constructor Detail

def self.new(root : KYAML::Any, comments : Array(KYAML::Comment), yaml_doc : YAML::Nodes::Document | Nil = nil) #

[View source]

Instance Method Detail

def comments : Array(KYAML::Comment) #

[View source]
def root : KYAML::Any #

[View source]
def to_kyaml(io : IO) : Nil #

Emits this doc as complete KYAML to io.


[View source]
def to_kyaml : String #

Emits this doc as complete KYAML and returns it as a String.


[View source]
def yaml_doc : YAML::Nodes::Document | Nil #

Original parsed YAML node tree, retained so emit-side comment classification can walk it in parallel with #root and recover source positions.

nil for hand-constructed docs that don't have a corresponding parsed node tree.


[View source]