GNU bug report logs -
#51581
[PATCH 0/2] Wrap lines in the description of generated packages
Previous Next
Reported by: Xinglu Chen <public <at> yoctocell.xyz>
Date: Wed, 3 Nov 2021 10:18:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51581 in the body.
You can then email your comments to 51581 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#51581
; Package
guix-patches
.
(Wed, 03 Nov 2021 10:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Xinglu Chen <public <at> yoctocell.xyz>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Wed, 03 Nov 2021 10:18:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This series adds a ‘wrap-lines’ procedure which wraps the line in a
string, similar to ‘fill-paragraph’ in Emacs. This is used to chop the
description of imported packages into multiple lines, instead of just
having one really long line.
Before:
--8<---------------cut here---------------start------------->8---
(description
"Hakyll is a static website compiler library. It provides you with the tools to create a simple or advanced static website using a Haskell DSL and formats such as markdown or RST. You can find more information, including a tutorial, on the website: . * <http://jaspervdj.be/hakyll> . If you seek assistance, there's: . * A google group: <http://groups.google.com/group/hakyll> . * An IRC channel, @#hakyll@ on irc.libera.chat (we *do not* have a channel on Freenode anymore) . Additionally, there's the Haddock documentation in the different modules, meant as a reference.")
--8<---------------cut here---------------end--------------->8---
After:
--8<---------------cut here---------------start------------->8---
(description
"Hakyll is a static website compiler library. It provides you with the tools to
create a simple or advanced static website using a Haskell DSL and formats such
as markdown or RST. You can find more information, including a tutorial, on the
website: . * <http://jaspervdj.be/hakyll> . If you seek assistance, there's: . *
A google group: <http://groups.google.com/group/hakyll> . * An IRC channel,
@#hakyll@ on irc.libera.chat (we *do not* have a channel on Freenode anymore) .
Additionally, there's the Haddock documentation in the different modules, meant as
a reference.")
--8<---------------cut here---------------end--------------->8---
Xinglu Chen (2):
import: utils: Add ‘wrap-lines’ procedure.
import: Beautify descriptions when appropriate.
guix/import/elpa.scm | 2 +-
guix/import/gnu.scm | 3 ++-
guix/import/hackage.scm | 4 ++--
guix/import/minetest.scm | 2 +-
guix/import/opam.scm | 3 ++-
guix/import/pypi.scm | 2 +-
guix/import/utils.scm | 36 +++++++++++++++++++++++++++++++-----
tests/import-utils.scm | 5 +++++
8 files changed, 45 insertions(+), 12 deletions(-)
base-commit: 0e19713c1fbfd3a01347e0d490434a53a596ed3c
--
2.33.0
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51581
; Package
guix-patches
.
(Wed, 03 Nov 2021 10:20:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 51581 <at> debbugs.gnu.org (full text, mbox):
* guix/import/utils.scm (wrap-lines): New procedure.
(beautify-description): Use it; add optional ‘length’ argument.
* tests/import-utils.scm ("wrap-lines: 80 characters"): Test it.
---
guix/import/utils.scm | 36 +++++++++++++++++++++++++++++++-----
tests/import-utils.scm | 5 +++++
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index a180742ca3..103ec2ffe1 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -66,6 +67,7 @@ (define-module (guix import utils)
license->symbol
snake-case
+ wrap-lines
beautify-description
alist->package
@@ -231,9 +233,32 @@ (define (snake-case str)
with dashes."
(string-join (string-split (string-downcase str) #\_) "-"))
-(define (beautify-description description)
- "Improve the package DESCRIPTION by turning a beginning sentence fragment
-into a proper sentence and by using two spaces between sentences."
+(define* (wrap-lines str #:optional (length 80))
+ "Given a string STR, wrap lines at LENGTH characters"
+ (define (aux str acc counter)
+ (cond
+ ((string-null? str) acc)
+ ((and (not (= (string-length acc) 0))
+ (= (modulo (string-length acc) length) 0)
+ (not (= counter 1)))
+ (let ((before (substring acc 0 (- counter 1)))
+ (after (substring acc counter)))
+ (aux str (string-append before "\n" after) 1)))
+ ((char=? (string-ref str 0) #\space)
+ (aux (substring str 1)
+ (string-append acc (char-set->string (char-set (string-ref str 0))))
+ (+ (string-length acc) 1)))
+ (else
+ (aux (substring str 1)
+ (string-append acc (char-set->string (char-set (string-ref str 0))))
+ counter))))
+
+ (aux str "" 1))
+
+(define* (beautify-description description #:optional (length 80))
+ "Improve the package DESCRIPTION by turning a beginning sentence fragment into
+a proper sentence and by using two spaces between sentences, and wrap lines at
+LENGTH characters."
(let ((cleaned (cond
((string-prefix? "A " description)
(string-append "This package provides a"
@@ -248,8 +273,9 @@ (define (beautify-description description)
(string-length "Functions"))))
(else description))))
;; Use double spacing between sentences
- (regexp-substitute/global #f "\\. \\b"
- cleaned 'pre ". " 'post)))
+ (wrap-lines (regexp-substitute/global #f "\\. \\b"
+ cleaned 'pre ". " 'post)
+ length)))
(define* (package-names->package-inputs names #:optional (output #f))
"Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index 7c6c782917..c6790f624a 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2016 Ben Woodcroft <donttrustben <at> gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -31,6 +32,10 @@ (define-module (test-import-utils)
(test-begin "import-utils")
+(test-equal "wrap-lines: 80 characters"
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\nincididunt ut labore et dolore magna aliqua."
+ (wrap-lines "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."))
+
(test-equal "beautify-description: use double spacing"
"This is a package. It is great. Trust me Mr. Hendrix."
(beautify-description
--
2.33.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51581
; Package
guix-patches
.
(Wed, 03 Nov 2021 10:20:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 51581 <at> debbugs.gnu.org (full text, mbox):
* guix/import/elpa.scm (elpa-package->sexp)
* guix/import/gnu.scm (gnu-package->sexp)
* guix/import/hackage.scm (hackage-module->sexp)
* guix/import/minetest.scm (make-minetest-sexp)
* guix/import/opam.scm (opam->guix-package)
* guix/import/pypi.scm (make-pypi-sexp): Beautify descriptions.
---
guix/import/elpa.scm | 2 +-
guix/import/gnu.scm | 3 ++-
guix/import/hackage.scm | 4 ++--
guix/import/minetest.scm | 2 +-
guix/import/opam.scm | 3 ++-
guix/import/pypi.scm | 2 +-
6 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index 96ebc17af1..8daa77bfcd 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -390,7 +390,7 @@ (define melpa-source
'())
(home-page ,(elpa-package-home-page pkg))
(synopsis ,(elpa-package-synopsis pkg))
- (description ,(elpa-package-description pkg))
+ (description ,(beautify-description (elpa-package-description pkg)))
(license ,license))
dependencies-names))
diff --git a/guix/import/gnu.scm b/guix/import/gnu.scm
index 51d5b77d34..2b9b71feb0 100644
--- a/guix/import/gnu.scm
+++ b/guix/import/gnu.scm
@@ -100,7 +100,8 @@ (define sig-url
(file-sha256 tarball))))))
(build-system gnu-build-system)
(synopsis ,(gnu-package-doc-summary package))
- (description ,(gnu-package-doc-description package))
+ (description ,(beautify-description
+ (gnu-package-doc-description package)))
(home-page ,(match (gnu-package-doc-urls package)
((head . tail) (qualified-url head))))
(license find-by-yourself!)))
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 03881f1a3d..95955e27a0 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -32,7 +32,7 @@ (define-module (guix import hackage)
#:use-module ((guix utils) #:select (package-name->name+version
canonical-newline-port))
#:use-module (guix http-client)
- #:use-module ((guix import utils) #:select (factorize-uri recursive-import))
+ #:use-module (guix import utils)
#:use-module (guix import cabal)
#:use-module (guix store)
#:use-module (gcrypt hash)
@@ -315,7 +315,7 @@ (define (maybe-arguments)
,@(maybe-arguments)
(home-page ,(cabal-package-home-page cabal))
(synopsis ,(cabal-package-synopsis cabal))
- (description ,(cabal-package-description cabal))
+ (description ,(beautify-description (cabal-package-description cabal)))
(license ,(string->license (cabal-package-license cabal))))
(append hackage-dependencies hackage-native-dependencies))))
diff --git a/guix/import/minetest.scm b/guix/import/minetest.scm
index 0f3ab473ca..abddd885ee 100644
--- a/guix/import/minetest.scm
+++ b/guix/import/minetest.scm
@@ -322,7 +322,7 @@ (define (make-minetest-sexp author/name version repository commit
,@(maybe-propagated-inputs (map contentdb->package-name inputs))
(home-page ,home-page)
(synopsis ,(delete-cr synopsis))
- (description ,(delete-cr description))
+ (description ,(beautify-description (delete-cr description)))
(license ,(if (eq? media-license license)
license
`(list ,media-license ,license)))
diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index fe13d29f03..395019d758 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -371,7 +371,8 @@ (define* (opam->guix-package name #:key (repo '()) version)
,(list 'quasiquote `((upstream-name . ,name))))))
(home-page ,(metadata-ref opam-content "homepage"))
(synopsis ,(metadata-ref opam-content "synopsis"))
- (description ,(metadata-ref opam-content "description"))
+ (description ,(beautify-description
+ (metadata-ref opam-content "description")))
(license ,(spdx-string->license
(metadata-ref opam-content "license"))))
(filter
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index f908136481..3d463a0775 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -474,7 +474,7 @@ (define (maybe-upstream-name name)
,@(maybe-inputs native-inputs 'native-inputs)
(home-page ,home-page)
(synopsis ,synopsis)
- (description ,description)
+ (description ,(beautify-description description))
(license ,(license->symbol license)))
upstream-dependencies))))))))
--
2.33.0
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51581
; Package
guix-patches
.
(Fri, 12 Nov 2021 22:45:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 51581 <at> debbugs.gnu.org (full text, mbox):
Hi!
Xinglu Chen <public <at> yoctocell.xyz> skribis:
> This series adds a ‘wrap-lines’ procedure which wraps the line in a
> string, similar to ‘fill-paragraph’ in Emacs. This is used to chop the
> description of imported packages into multiple lines, instead of just
> having one really long line.
Does (@ (guix ui) fill-paragraph) suit your needs? :-)
If so, could you send updated patches? The rest LGTM.
Thanks,
Ludo’.
Information forwarded
to
guix-patches <at> gnu.org
:
bug#51581
; Package
guix-patches
.
(Wed, 01 Dec 2021 15:33:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 51581 <at> debbugs.gnu.org (full text, mbox):
Ping! :-)
Ludovic Courtès <ludo <at> gnu.org> skribis:
> Hi!
>
> Xinglu Chen <public <at> yoctocell.xyz> skribis:
>
>> This series adds a ‘wrap-lines’ procedure which wraps the line in a
>> string, similar to ‘fill-paragraph’ in Emacs. This is used to chop the
>> description of imported packages into multiple lines, instead of just
>> having one really long line.
>
> Does (@ (guix ui) fill-paragraph) suit your needs? :-)
>
> If so, could you send updated patches? The rest LGTM.
>
> Thanks,
> Ludo’.
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Fri, 17 Dec 2021 15:54:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Xinglu Chen <public <at> yoctocell.xyz>
:
bug acknowledged by developer.
(Fri, 17 Dec 2021 15:54:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 51581-done <at> debbugs.gnu.org (full text, mbox):
Hi,
Xinglu Chen <public <at> yoctocell.xyz> skribis:
> import: utils: Wrap files in description.
> import: Beautify descriptions when appropriate.
Applied, thanks!
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 15 Jan 2022 12:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 99 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.