Comment Operators - Yq - GitBook
Maybe your like
Use these comment operators to set or retrieve comments. Note that line comments on maps/arrays are actually set on the key node as opposed to the value (map/array). See below for examples.
Like the = and |= assign operators, the same syntax applies when updating comments:
hashtagplain form: =
This will set the LHS nodes' comments equal to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
hashtagrelative form: |=
This is similar to the plain form, but it evaluates the RHS with each matching LHS node as context. This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
hashtagSet line comment
Set the comment on the key node for more reliability (see below).
Given a sample.yml file of:
Copya:catthen
Copyyq'.a line_comment="single"'sample.ymlwill output
Copya:cat# singlehashtagSet line comment of a maps/arrays
For maps and arrays, you need to set the line comment on the key node. This will also work for scalars.
Given a sample.yml file of:
then
will output
hashtagUse update assign to perform relative updates
Given a sample.yml file of:
then
will output
hashtagWhere is the comment - map key example
The underlying yaml parser can assign comments in a document to surprising nodes. Use an expression like this to find where you comment is. 'p' indicates the path, 'isKey' is if the node is a map key (as opposed to a map value). From this, you can see the 'hello-world-comment' is actually on the 'hello' key
Given a sample.yml file of:
then
will output
hashtagRetrieve comment - map key example
From the previous example, we know that the comment is on the 'hello' key as a lineComment
Given a sample.yml file of:
then
will output
hashtagWhere is the comment - array example
The underlying yaml parser can assign comments in a document to surprising nodes. Use an expression like this to find where you comment is. 'p' indicates the path, 'isKey' is if the node is a map key (as opposed to a map value). From this, you can see the 'under-name-comment' is actually on the first child
Given a sample.yml file of:
then
will output
hashtagRetrieve comment - array example
From the previous example, we know that the comment is on the first child as a headComment
Given a sample.yml file of:
then
will output
hashtagSet head comment
Given a sample.yml file of:
then
will output
hashtagSet head comment of a map entry
Given a sample.yml file of:
then
will output
hashtagSet foot comment, using an expression
Given a sample.yml file of:
then
will output
hashtagRemove comment
Given a sample.yml file of:
then
will output
hashtagRemove (strip) all comments
Note the use of ... to ensure key nodes are included.
Given a sample.yml file of:
then
will output
hashtagGet line comment
Given a sample.yml file of:
then
will output
hashtagGet head comment
Given a sample.yml file of:
then
will output
hashtagHead comment with document split
Given a sample.yml file of:
then
will output
hashtagGet foot comment
Given a sample.yml file of:
then
will output
Tag » Add Comments In Yaml
-
YAML - Comments - Tutorialspoint
-
How Do You Do Block Comments In YAML? - Stack Overflow
-
Add Comments To YAML File - WPLauncher - Courses
-
Learn YAML Comments - Inline And Block Level ...
-
How To Write Comments In YAML
-
How To Block Comments In YAML ? - GeeksforGeeks
-
Inline And Block Comment In YAML File - ProgrammingBasic
-
How To Comment In Yaml Code Example
-
GitHub Actions — How To Add Comments In YAML Files
-
YAML Comments - Linux Hint
-
Create And Save YAML Files With Comments - Gists · GitHub
-
New Post Add-in Strips Helpful Comments From YAML #560 - GitHub
-
AWS CloudFormation Template Formats
-
YAML Comments - Javatpoint