YamlDocumentPart
OfficeIMO.Yaml
One document of a YAML stream: its directives, its --- and ... markers, its root node and the comments around it. A file with several documents (a Kubernetes manifest list, for example) has one part per document.
Inheritance
- object
- YamlDocumentPart
Usage
Explore 5 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 5
- Method YamlDocument.AddDocument
- Property YamlDocument.Documents
- Method YamlDocumentPart.SetComment
- Method YamlDocumentPart.SetCommentAfter
- Method YamlDocumentPart.SetCommentBefore
Methods
public YamlDocumentPart SetComment(string? text) #Sets the comment at the end of the --- line, or removes it with null. In a document added by editing whose root is a scalar or flow collection, the root is written on the --- line and the comment follows it.
Parameters
- text string?
Exceptions
ArgumentException– The text contains a line break.InvalidOperationException– The document has no --- marker, or its root starts on the --- line, where the comment is the root's.
public YamlDocumentPart SetCommentAfter(string? text) #Replaces the comment lines after the root's last line; null removes them.
Parameters
- text string?
public YamlDocumentPart SetCommentBefore(string? text) #Replaces the header comments; each line of text becomes one # line comment. In a document without --- a blank line follows them so they stay the document's. null removes them.
Parameters
- text string?
Inherited Methods
Properties
public YamlNode Root { get; set; } #Gets the root node, or sets a new one in its place. A document without content has an empty plain scalar root, which reads as null. Setting writes the new root in place of the old one and leaves the comments around it.
Exceptions
InvalidOperationException– Setting: the node already belongs to a document, or aliases refer to the old root.
public YamlSchema Schema { get; } #Gets the schema the typed reads of this document use: the schema forced through YamlLoadOptions.Schema, otherwise YamlSchema.Yaml11 for a %YAML 1.1 document and YamlSchema.Core for every other document.
public string? Version { get; } #Gets the version a %YAML directive declares, such as 1.1, or null without one.
public IReadOnlyList<YamlTagDirective> TagDirectives { get; } #Gets the document's %TAG directives in source order.
public bool HasStartMarker { get; } #Gets whether the document starts with an explicit --- marker.
public bool HasEndMarker { get; internal set; } #Gets whether the document ends with an explicit ... marker.
public string? CommentBefore { get; } #Gets the document's header comments, such as a license, joined with line breaks and without their # and one following space; null when there are none. They are the comment lines before ---, or, in a document without one, the comment lines at its top that a blank line separates from the first entry.
public string? CommentAfter { get; } #Gets the comment lines after the root's last line, joined with line breaks; null when there are none.
public string? Comment { get; } #Gets the comment at the end of the --- line (--- # generated by Helm), without its # and one following space; null when there is none or the document has no ---. When the root or its anchor or tag starts on the --- line (--- |, --- !!map, an empty document), the comment on that line is the root's YamlNode.Comment instead.