From 5d9a5e230189347ba6f5b78a3d74b36a867aa9e6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 2 Jan 2022 18:14:00 +0100 Subject: style: '-S format' canonicalizes comments. * guix/scripts/style.scm (canonicalize-comment): New procedure. (pretty-print-with-comments): Add #:format-comment. and honor it. (object->string*): Add 'args' and honor them. (format-package-definition): Pass #:format-comment to 'object->string*'. * tests/style.scm ("pretty-print-with-comments, canonicalize-comment"): New test. --- tests/style.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/style.scm b/tests/style.scm index 7dae543860..8c6d37a661 100644 --- a/tests/style.scm +++ b/tests/style.scm @@ -485,6 +485,31 @@ mnopqrstuvwxyz.\")" '(#:phases %standard-phases #:tests? #f)))") +(test-equal "pretty-print-with-comments, canonicalize-comment" + "\ +(list abc + ;; Not a margin comment. + ;; Ditto. + ;; + ;; There's a blank line above. + def ;margin comment + ghi)" + (let ((sexp (call-with-input-string + "\ +(list abc + ;Not a margin comment. + ;;; Ditto. + ;;;;; + ; There's a blank line above. + def ;; margin comment + ghi)" + read-with-comments))) + (call-with-output-string + (lambda (port) + (pretty-print-with-comments port sexp + #:format-comment + canonicalize-comment))))) + (test-end) ;; Local Variables: -- cgit 1.4.1