guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

10/12: import/utils: Add beautify-synopsis.


From: guix-commits
Subject: 10/12: import/utils: Add beautify-synopsis.
Date: Wed, 28 Sep 2022 16:14:57 -0400 (EDT)

rekado pushed a commit to branch master
in repository guix.

commit 7ea6e9f79f8d259a75c455183e07afa60771abcc
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Wed Sep 28 22:05:52 2022 +0200

    import/utils: Add beautify-synopsis.
    
    * guix/import/utils.scm (beautify-synopsis): New procedure.
---
 guix/import/utils.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 7e7d116d1d..dd8c61b79a 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -72,6 +72,7 @@
 
             snake-case
             beautify-description
+            beautify-synopsis
 
             alist->package
 
@@ -295,7 +296,22 @@ LENGTH characters."
     ;; Use double spacing between sentences
     (fill-paragraph (regexp-substitute/global #f "\\. \\b"
                                           cleaned 'pre ".  " 'post)
-                length)))
+                    length)))
+
+(define (beautify-synopsis synopsis)
+  "Improve the package SYNOPSIS."
+  (let ((cleaned (cond
+                  ((not (string? synopsis))
+                   (G_ "This package lacks a synopsis.  Run \
+\"info '(guix) Synopses and Descriptions'\" for more information."))
+                  ((string-prefix? "A " synopsis)
+                   (substring synopsis 1))
+                  ;; Remove trailing period.
+                  ((string-suffix? "." synopsis)
+                   (substring synopsis 0
+                              (1- (string-length synopsis))))
+                  (else synopsis))))
+    (string-trim-both cleaned)))
 
 (define* (package-names->package-inputs names #:optional (output #f))
   "Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an



reply via email to

[Prev in Thread] Current Thread [Next in Thread]