From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: Should synopsis handle texinfo markup? Date: Mon, 20 Mar 2017 13:52:12 +0300 Message-ID: <8737e85ig3.fsf@gmail.com> References: <874lyz396q.fsf@gmail.com> <877f3q8qlp.fsf@gnu.org> <874lyt38nk.fsf@gmail.com> <87d1dgua7v.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpuvC-0004ea-I5 for guix-devel@gnu.org; Mon, 20 Mar 2017 06:52:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpuv9-0001Ok-EM for guix-devel@gnu.org; Mon, 20 Mar 2017 06:52:18 -0400 In-Reply-To: <87d1dgua7v.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 16 Mar 2017 23:29:24 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2017-03-16 23:29 +0100) wrote: > Alex Kost skribis: > >> Ludovic Court=C3=A8s (2017-03-15 17:14 +0100) wrote: >> >>> Alex Kost skribis: >>> >>>> Hello, I've noticed that several packages contain "@code" structures in >>>> their synopses, but only 'description' field supports texinfo markup. >>>> For example, look at: >>>> >>>> guix package -s ruby-minitest-bonus-assertions >>>> >>>> So I wonder, should these synopses be adjusted to remove @code things, >>>> or would it be better to make sysnopses support it? >>> >>> Maybe we should support Texinfo in synopses after all. I don=E2=80=99t= think >>> there were good reasons not to do it. >>> >>> Thoughts? >> >> I'm not aware of potential problems so I think it would be good to add >> this support to synopses. > > Cool. Would you or anyone like to give it a try? Alternatively we can > mail it to bug-guix for later. I gave it a try (the patch is attached). I hope I didn't miss anything. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-ui-Support-Texinfo-markup-in-package-synopses.patch Content-Transfer-Encoding: quoted-printable >From 8d8a79d69619b68dd3a798e7456bfd871fcb8395 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Mon, 20 Mar 2017 13:41:41 +0300 Subject: [PATCH] ui: Support Texinfo markup in package synopses. * guix/ui.scm (package-field-string): New procedure. (package-description-string): Use it. (package-synopsis-string): New procedure. (package->recutils): Use it. * guix/scripts/lint.scm (check-synopsis-style)[check-texinfo-markup]: New procedure. Use it in checks. * gnu/packages/perl.scm (perl-try-tiny)[synopsis]: Adjust for the Texinfo markup. --- gnu/packages/perl.scm | 2 +- guix/scripts/lint.scm | 22 +++++++++++++++++++--- guix/ui.scm | 17 +++++++++++++---- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm index 840e0b7..c415208 100644 --- a/gnu/packages/perl.scm +++ b/gnu/packages/perl.scm @@ -7580,7 +7580,7 @@ Tree::Simple::Visitor::* objects.") "068vdbpacfawc3lkfs0b82xxl27h3l0gj14iada3vlwk8rps9yv0")))) (build-system perl-build-system) (home-page "http://search.cpan.org/dist/Try-Tiny") - (synopsis "Minimal try/catch with proper preservation of $@") + (synopsis "Minimal try/catch with proper preservation of $@@") (description "This module provides bare bones try/catch/finally statem= ents that are designed to minimize common mistakes with eval blocks, and nothing else.") diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 66c82f0..811f167 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -5,6 +5,7 @@ ;;; Copyright =C2=A9 2015, 2016 Mathieu Lirzin ;;; Copyright =C2=A9 2016 Danny Milosavljevic ;;; Copyright =C2=A9 2016 Hartmut Goebel +;;; Copyright =C2=A9 2017 Alex Kost ;;; ;;; This file is part of GNU Guix. ;;; @@ -347,10 +348,25 @@ the synopsis") (_ "synopsis should not start with the package name") 'synopsis))) =20 + (define (check-texinfo-markup synopsis) + "Check that SYNOPSIS can be parsed as a Texinfo fragment. If the +markup is valid return a plain-text version of SYNOPSIS, otherwise #f." + (catch #t + (lambda () (texi->plain-text synopsis)) + (lambda (keys . args) + (emit-warning package + (_ "Texinfo markup in synopsis is invalid") + 'synopsis) + #f))) + (define checks - (list check-not-empty check-proper-start check-final-period - check-start-article check-start-with-package-name - check-synopsis-length)) + (list check-not-empty + check-proper-start + check-final-period + check-start-article + check-start-with-package-name + check-synopsis-length + check-texinfo-markup)) =20 (match (package-synopsis package) ((? string? synopsis) diff --git a/guix/ui.scm b/guix/ui.scm index 3a0a650..345bf49 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -4,7 +4,7 @@ ;;; Copyright =C2=A9 2013 Nikita Karetnikov ;;; Copyright =C2=A9 2014 Cyril Roelandt ;;; Copyright =C2=A9 2014 Cyrill Schenkel -;;; Copyright =C2=A9 2014, 2015 Alex Kost +;;; Copyright =C2=A9 2014, 2015, 2017 Alex Kost ;;; Copyright =C2=A9 2015 David Thompson ;;; Copyright =C2=A9 2015, 2016 Mathieu Lirzin ;;; Copyright =C2=A9 2016 Roel Janssen @@ -81,6 +81,7 @@ fill-paragraph texi->plain-text package-description-string + package-synopsis-string string->recutils package->recutils package-specification->name+version+output @@ -848,10 +849,18 @@ converted to a space; sequences of more than one line= break are preserved." (with-fluids ((%default-port-encoding "UTF-8")) (stexi->plain-text (texi-fragment->stexi str)))) =20 +(define (package-field-string package field-accessor) + "Return a plain-text representation of PACKAGE field." + (and=3D> (field-accessor package) + (compose texi->plain-text P_))) + (define (package-description-string package) "Return a plain-text representation of PACKAGE description field." - (and=3D> (package-description package) - (compose texi->plain-text P_))) + (package-field-string package package-description)) + +(define (package-synopsis-string package) + "Return a plain-text representation of PACKAGE synopsis field." + (package-field-string package package-synopsis)) =20 (define (string->recutils str) "Return a version of STR where newlines have been replaced by newlines @@ -914,7 +923,7 @@ WIDTH columns." (string-map (match-lambda (#\newline #\space) (chr chr)) - (or (and=3D> (package-synopsis p) P_) + (or (and=3D> (package-synopsis-string p) P_) ""))) (format port "~a~2%" (string->recutils --=20 2.10.2 --=-=-=--