Skip to content
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

Reformat documentation with 'andebox yaml-doc' #1020

Merged
merged 5 commits into from
Dec 28, 2024

Conversation

felixfontein
Copy link
Collaborator

SUMMARY

Reformat the YAML documentation embedded into Python files with andebox.

ISSUE TYPE
  • Docs Pull Request
COMPONENT NAME

various

Copy link

github-actions bot commented Dec 28, 2024

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and the docs are now incorporated into main:
https://ansible-collections.github.io/community.docker/branch/main

plugins/doc_fragments/compose_v2.py Outdated Show resolved Hide resolved
plugins/modules/docker_config.py Outdated Show resolved Hide resolved
plugins/modules/docker_config.py Outdated Show resolved Hide resolved
plugins/modules/docker_config.py Outdated Show resolved Hide resolved
plugins/modules/docker_container.py Outdated Show resolved Hide resolved
plugins/modules/docker_prune.py Outdated Show resolved Hide resolved
plugins/modules/docker_secret.py Outdated Show resolved Hide resolved
plugins/modules/docker_secret.py Outdated Show resolved Hide resolved
plugins/modules/docker_secret.py Outdated Show resolved Hide resolved
plugins/modules/docker_swarm_service.py Outdated Show resolved Hide resolved
plugins/inventory/docker_containers.py Outdated Show resolved Hide resolved
plugins/modules/docker_container.py Outdated Show resolved Hide resolved
plugins/modules/docker_image_build.py Outdated Show resolved Hide resolved
plugins/modules/docker_volume.py Outdated Show resolved Hide resolved
@felixfontein felixfontein merged commit 769d15d into ansible-collections:main Dec 28, 2024
78 checks passed
@felixfontein felixfontein deleted the docs branch December 28, 2024 15:40
@russoz
Copy link
Contributor

russoz commented Dec 29, 2024

Thanks for using andebox, as you noticed it is far from perfect - it will solve most of the problem, but still some quirks. This action in andebox is largly dependent on ruamel.yaml, so I am considering submitting bug reports and feature requests to them later on. For now this is good enough to get going.

@felixfontein
Copy link
Collaborator Author

I did look a bit at how andebox works internally and noticed that it's basically a ruamel.yaml problem, and there doesn't seem to be obvious configurations for it. The good thing is that the examples here are reproducers of the problems ;)

For example:

content = r"""
- a:
    # Comment
    b: c
    # Comment

- a:
    - d: e
      # Comment
      f: g
      # Comment
    - h: j
      # Comment
      k: l

- a:
    - foo
      # Comment
    - baz
      # Comment
"""
from ruamel.yaml import YAML
from io import StringIO
yaml = YAML(typ='rt')
yaml.preserve_quotes = True
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.explicit_start = False
yaml.width = 120
yaml.top_level_colon_align = False
yaml.compact_seq_seq = False
data = yaml.load(content)
output = StringIO()
yaml.dump(data, output)
print(output.getvalue())

This results in

  - a:
    # Comment
      b: c
    # Comment

  - a:
      - d: e
      # Comment
        f: g
      # Comment
      - h: j
      # Comment
        k: l

  - a:
      - foo
      # Comment
      - baz
      # Comment

printed. At least in the first two items the comments should be indented by two more spaces. In the third one I guess it is debatable...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants