Skip to content

YAML Style Guide

TingPing edited this page Oct 13, 2018 · 3 revisions

YAML is a very flexible language so to make it easier for everybody involved there are a few guidelines to follow when submitting manifests to Flathub.

  • 2 spaces for indentation

  • Insert newlines between modules

modules:
  - name: module-one
    sources:
      - type: archive
        url: 'https://example.org'
 
  - name: module-two
    sources:
      - type: archive
        url: 'https://example.org'

  - name: module-three
    sources:
      - type: archive
        url: 'https://example.org'
  • Always indent child elements
# GOOD:
modules:
  - name: foo
    sources:
      - type: bar

# BAD:
modules:
- name: foo
  sources:
  - type: bar
  • Do not align values

Aligning values means you have to have automated tooling to sanely format it and many simple changes result in full file modifications making diffs harder to review, revert, or otherwise manage.

# BAD:
id:           org.example.Foo   
modules:
  - name:     foo
    sources:
      - type: git