From 143c1dffed15f1cab3eb06e148fe11224e39471c Mon Sep 17 00:00:00 2001 From: Andreas Kurth Date: Wed, 21 Jan 2026 01:13:44 +0100 Subject: Remove --no-doc argument from yq-yaml formatter (#386) The --no-doc argument removes existing document separators (---) from yaml files. It is perfectly valid and common practice to use multiple documents within a single file, e.g. in the kubernetes universe. Formatting such files with --no-doc breaks their validity. See also the prettier-yaml test, which preserves the document separator, too. --- CHANGELOG.md | 2 ++ apheleia-formatters.el | 2 +- test/formatters/samplecode/yq-yaml/out.yml | 1 + .../samplecode/yq-yaml/test-dont-add-docsep/in.yml | 12 ++++++++++++ .../samplecode/yq-yaml/test-dont-add-docsep/out.yml | 12 ++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/formatters/samplecode/yq-yaml/test-dont-add-docsep/in.yml create mode 100644 test/formatters/samplecode/yq-yaml/test-dont-add-docsep/out.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cda2e9..51b6b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog]. ## Unreleased ### Formatters +* Removed `--no-doc` argument from yq-yaml to avoid breaking + multi-document yaml files ([#386]). * Use clang-format for formatting Objective-C/C++ files ([#378]). * `bibtex-reformat` for BibTeX files. * `rubocop` changed to use `--force-exclusion` to obey exclusions in config diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 53e7387..c98b790 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -238,7 +238,7 @@ (yq-xml . ("yq" "--prettyPrint" "--no-colors" "--input-format" "xml" "--output-format" "xml" (apheleia-formatters-indent nil "--indent"))) - (yq-yaml . ("yq" "--prettyPrint" "--no-colors" "--no-doc" + (yq-yaml . ("yq" "--prettyPrint" "--no-colors" "--input-format" "yaml" "--output-format" "yaml" (apheleia-formatters-indent nil "--indent"))) (zig-fmt . ("zig" "fmt" "--stdin"))) diff --git a/test/formatters/samplecode/yq-yaml/out.yml b/test/formatters/samplecode/yq-yaml/out.yml index 8b4f56d..e85025b 100644 --- a/test/formatters/samplecode/yq-yaml/out.yml +++ b/test/formatters/samplecode/yq-yaml/out.yml @@ -1,3 +1,4 @@ +--- - hosts: all tasks: - name: Get software for apt repository management. diff --git a/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/in.yml b/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/in.yml new file mode 100644 index 0000000..fe6f000 --- /dev/null +++ b/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/in.yml @@ -0,0 +1,12 @@ +doc: v1 +meta: + title: t1 + sub: + - sub1: 42 + sub2: 3333 +doc: v1 +meta: + title: t2 + sub: + - sub1: 43 + sub2: 4444 diff --git a/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/out.yml b/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/out.yml new file mode 100644 index 0000000..b61f9b4 --- /dev/null +++ b/test/formatters/samplecode/yq-yaml/test-dont-add-docsep/out.yml @@ -0,0 +1,12 @@ +doc: v1 +meta: + title: t1 + sub: + - sub1: 42 + sub2: 3333 +doc: v1 +meta: + title: t2 + sub: + - sub1: 43 + sub2: 4444 -- cgit v1.0