Skip to content

More detailed info on block scalars #2319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

kk-at-redhat
Copy link

No description provided.

@ansible-documentation-bot ansible-documentation-bot bot added the new_contributor This PR is the first contribution by a new community member. label Jan 1, 2025
@ansible-documentation-bot
Copy link
Contributor

Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the dawgs-meeting tag to a forum topic to bring it up at the next meeting.

@ansible-documentation-bot
Copy link
Contributor

Thanks for your contribution, @kk-at-redhat! Please make sure that your pull request includes sufficient and meaningful details in the description.
PR descriptions provide important context and allow other developers and our future selves to understand a change's rationale and what it actually fixes or accomplishes.

@samccann samccann added the techreview needs technical review label Mar 20, 2025
@@ -68,19 +66,18 @@ More complicated data structures are possible, such as lists of dictionaries, di
- fortran
- erlang

Dictionaries and lists can also be represented in an abbreviated form if you really want to:
Dictionaries and lists can also be written in a short form called "Flow collections":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aka YAML shorthand, which is also a superset of JSON

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a suggested addition?


There's another small quirk to YAML. All YAML files (regardless of their association with Ansible or not) can optionally
begin with ``---`` and end with ``...``. This is part of the YAML format and indicates the start and end of a document.
One of the most common structures that can be found in a yaml file is a list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
One of the most common structures that can be found in a yaml file is a list.
Ansible playbooks and task files are lists.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to leave it as it was since at this point we are talking about yaml in general (regardless of its association with Ansible). Also, variables file being a dictionary can still have fields that are lists and thus we can say that lists can be found in those files too even though the files are dictionaries.

@@ -38,7 +36,7 @@ All members of a list are lines beginning at the same indentation level starting
- Mango
...

A dictionary is represented in a simple ``key: value`` form (the colon must be followed by a space):
Another common structure is a dictionary which consists of one or more key/value pairs: ``key: value`` (the colon must be followed by a space):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictionaries don't need to contain at least one key/value pair.

Suggested change
Another common structure is a dictionary which consists of one or more key/value pairs: ``key: value`` (the colon must be followed by a space):
Ansible variable files are dictionaries.
A YAML dictionary is represented in a simple ``key: value`` form (the colon must be followed by a space):

Copy link
Author

@kk-at-redhat kk-at-redhat Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictionaries don't need to contain at least one key/value pair.

Meaning empty dictionary? Formally it's correct, of course, but I think for the purposes of the doc it's not relevant really.

Also, if we get into saying that a certain yaml file is a list or a dictionary then the next question would be: is empty yaml file an empty list or empty dictionary, lol? I'm not sure we want to put ourselves in that discussion :-) I'd prefer to keep my version if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new_contributor This PR is the first contribution by a new community member. techreview needs technical review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants