unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mathieu Lirzin <mthl@openmailbox.org>
To: guix-devel@gnu.org
Cc: Alex Kost <alezost@gmail.com>
Subject: Re: Texinfo in descriptions?
Date: Thu, 27 Aug 2015 23:04:14 +0200	[thread overview]
Message-ID: <87a8tcfnox.fsf@openmailbox.org> (raw)
In-Reply-To: <87h9ov51j9.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 22 Jul 2015 23:24:10 +0200")

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:

> With Benno being OK, we should start looking at implementing the change.
> The various parts that I can think of are:
>
>   • Having a ‘package-description-string’ procedure that would return
>     the description rendered as a string, using the (stexi) modules.
>
>   • ‘--search’ could use the raw description (including markup).
>     However, ‘package->recutils’ must use ‘package-description-string’
>     or similar.

Here is a first attempt.  It doesn't feel right to me but fornow I don't
know what to do without duplicating code or reorganizing the world.  The
problem is that translations are handle in (guix ui) so we need to
regenerate texi->plain-text.


[-- Attachment #2: 0001-packages-Add-package-description-string.patch --]
[-- Type: text/x-diff, Size: 7141 bytes --]

From 665c92dc5e9976719ac7a6e427253b6ee65c78d8 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@openmailbox.org>
Date: Fri, 7 Aug 2015 00:10:43 +0200
Subject: [PATCH] packages: Add package-description-string.

* guix/packages.scm (package-description-string): New variable.
* guix/utils.scm (texi->plain-text): Likewise.
* guix/ui.scm (package->recutils): Use it.
* gnu/packages/perl.scm (perl-devel-globaldestruction)
  (perl-devel-lexalias, perl-exporter-lite): Adapt to Texinfo's markup.
* gnu/packages/python.scm (python2-empy): Likewise.
---
 gnu/packages/perl.scm   | 6 +++---
 gnu/packages/python.scm | 2 +-
 guix/packages.scm       | 6 ++++++
 guix/ui.scm             | 5 +++--
 guix/utils.scm          | 8 ++++++++
 5 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index f784798..0236d05 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -1665,7 +1665,7 @@ particular command is available.")
     (home-page "http://search.cpan.org/dist/Devel-GlobalDestruction")
     (synopsis "Provides equivalent of ${^GLOBAL_PHASE} eq 'DESTRUCT' for older perls")
     (description "Devel::GlobalDestruction provides a function returning the
-equivalent of \"${^GLOBAL_PHASE} eq 'DESTRUCT'\" for older perls.")
+equivalent of \"$@{^GLOBAL_PHASE@} eq 'DESTRUCT'\" for older perls.")
     (license (package-license perl))))
 
 (define-public perl-devel-lexalias
@@ -1909,7 +1909,7 @@ constructors, which speeds code up at runtime by a significant amount.  String
 eval is not without its issues however - it's difficult to control the scope
 it's used in (which determines which variables are in scope inside the eval),
 and it's easy to miss compilation errors, since eval catches them and sticks
-them in $@ instead.  This module attempts to solve these problems.  It
+them in $@@ instead.  This module attempts to solve these problems.  It
 provides an eval_closure function, which evals a string in a clean
 environment, other than a fixed list of specified variables.  Compilation
 errors are rethrown automatically.")
@@ -1953,7 +1953,7 @@ in your modules in a \"Java-esque\" manner.")
     (description
      "Exporter::Lite is an alternative to Exporter, intended to provide a
 lightweight subset of the most commonly-used functionality.  It supports
-import(), @EXPORT and @EXPORT_OK and not a whole lot else.")
+import(), @@EXPORT and @@EXPORT_OK and not a whole lot else.")
     (home-page (string-append "http://search.cpan.org/~neilb/"
                               "Exporter-Lite-" version))
     (license (package-license perl))))
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 940efec..07275d7 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -1171,7 +1171,7 @@ other Python program.")
      "EmPy is a system for embedding Python expressions and statements in
 template text; it takes an EmPy source file, processes it, and produces
 output.  This is accomplished via expansions, which are special signals to the
-EmPy system and are set off by a special prefix (by default the at sign, @).
+EmPy system and are set off by a special prefix (by default the at sign, @@).
 EmPy can expand arbitrary Python expressions and statements in this way, as
 well as a variety of special forms.  Textual data not explicitly delimited in
 this way is sent unaffected to the output, allowing Python to be used in
diff --git a/guix/packages.scm b/guix/packages.scm
index 3983d14..56d0f56 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -71,6 +72,7 @@
             package-replacement
             package-synopsis
             package-description
+            package-description-string
             package-license
             package-home-page
             package-supported-systems
@@ -315,6 +317,10 @@ representation."
   "Return the full name of PACKAGE--i.e., `NAME-VERSION'."
   (string-append (package-name package) "-" (package-version package)))
 
+(define (package-description-string package)
+  "Return a plain-text representation of PACKAGE description field."
+  (texi->plain-text (package-description package)))
+
 (define (%standard-patch-inputs)
   (let* ((canonical (module-ref (resolve-interface '(gnu packages base))
                                 'canonical-package))
diff --git a/guix/ui.scm b/guix/ui.scm
index a6d4fd1..f0a31f3 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
 ;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -784,8 +785,8 @@ followed by \"+ \", which makes for a valid multi-line field value in the
                                                   80)))
   "Write to PORT a `recutils' record of package P, arranging to fit within
 WIDTH columns."
-  (define (description->recutils str)
-    (let ((str (P_ str)))
+  (define (description->recutils package)
+    (let ((str (texi->plain-text (P_ str))))
       (string->recutils
        (fill-paragraph str width
                        (string-length "description: ")))))
diff --git a/guix/utils.scm b/guix/utils.scm
index 44913c6..e6513aa 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -38,6 +39,8 @@
   #:use-module (ice-9 regex)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
+  #:use-module (texinfo)
+  #:use-module (texinfo plain-text)
   #:use-module (system foreign)
   #:export (bytevector->base16-string
             base16-string->bytevector
@@ -72,6 +75,7 @@
             version-major+minor
             guile-version>?
             package-name->name+version
+            texi->plain-text
             string-replace-substring
             arguments-from-environment-variable
             file-extension
@@ -594,6 +598,10 @@ introduce the version part."
       ((head tail ...)
        (loop tail (cons head prefix))))))
 
+(define (texi->plain-text str)
+  "Return a plain-text representation of texinfo fragment STR."
+  (stexi->plain-text (texi-fragment->stexi str)))
+
 (define (file-extension file)
   "Return the extension of FILE or #f if there is none."
   (let ((dot (string-rindex file #\.)))
-- 
2.1.4


[-- Attachment #3: Type: text/plain, Size: 195 bytes --]


>
>   • guix.el, guix-web, and the web site need to do the right thing when
>     displaying descriptions.

I've succeed to do something for the website but with the same
aftertaste.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-website-packages-Support-Texinfo-s-markup.patch --]
[-- Type: text/x-diff, Size: 1820 bytes --]

From 66ddc73d11fd6b9b5fb77021a04e42086096fc79 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@openmailbox.org>
Date: Thu, 27 Aug 2015 17:51:11 +0200
Subject: [PATCH] website: packages: Support Texinfo's markup.

* website/www/packages.scm (package->sxml): Adapt to new Texinfo's
  markup in package description.
---
 website/www/packages.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/website/www/packages.scm b/website/www/packages.scm
index 09da932..48ed703 100644
--- a/website/www/packages.scm
+++ b/website/www/packages.scm
@@ -37,6 +37,8 @@
   #:use-module (ice-9 i18n)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-19)
+  #:use-module (texinfo)
+  #:use-module (texinfo html)
   #:export (packages-page))
 
 (define lookup-gnu-package
@@ -170,6 +172,12 @@ decreasing, is 1."
                             (package-transitive-supported-systems package)))
                       " ")))
 
+  (define (package-description-shtml package)
+    "Return a SXML representation of PACKAGE description field with HTML
+vocabulary."
+    (and=> (package-description package)
+           (lambda (str) (stexi->shtml (texi-fragment->stexi str)))))
+
   (define (package-logo name)
     (and=> (lookup-gnu-package name)
            gnu-package-logo))
@@ -203,7 +211,7 @@ description-ids as formal parameters."
                                  (class "package-logo")
                                  (alt ("Logo of " ,(package-name package))))))
                        (_ #f))
-                    (p ,(package-description package))
+                    (p ,(package-description-shtml package))
                     ,(license package)
                     (a (@ (href ,(package-home-page package))
                           (title "Link to the package's website"))
-- 
2.1.4


[-- Attachment #5: Type: text/plain, Size: 395 bytes --]


What "feels right" to me is to redefine 'package-description' in (guix
package) to return an stexi output by default with optional #:plain-text
#:l10n keys And that each interface handle other ways of displaying
description by using (stexi->...).  IIUC This would lead to reorganize a
few modules so I prefer asking for advices or other proposals before
digging too far. ;)

--
Mathieu Lirzin


  parent reply	other threads:[~2015-08-27 21:05 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 11:17 [PATCH] gnu packages: Clean up synopses and descriptions Alex Kost
2015-07-16  9:40 ` Eric Bavier
2015-07-16 15:55   ` Alex Kost
2015-07-16 19:08     ` Ludovic Courtès
2015-07-17 12:41       ` Alex Kost
2015-07-17 21:24         ` Ludovic Courtès
2015-07-18 10:07           ` Alex Kost
2015-07-16 11:52 ` Mathieu Lirzin
2015-07-16 15:50   ` Ludovic Courtès
2015-07-16 21:33     ` Mathieu Lirzin
2015-07-17 21:18       ` Texinfo in descriptions? Ludovic Courtès
2015-07-21 21:37         ` Mathieu Lirzin
2015-07-22 13:35           ` Ludovic Courtès
2015-07-22 21:24             ` Ludovic Courtès
2015-07-22 22:08               ` Andreas Enge
2015-07-23  9:49                 ` Mathieu Lirzin
2015-07-23 13:57                   ` Ludovic Courtès
2015-07-23 15:09                     ` Daniel Pimentel
2015-07-23 18:00                       ` Andreas Enge
2015-08-25 22:09                     ` Mathieu Lirzin
2015-08-26  7:57                       ` Andy Wingo
2015-08-27 19:48                         ` Mathieu Lirzin
2015-07-23 13:54                 ` Ludovic Courtès
2015-08-27 21:04               ` Mathieu Lirzin [this message]
2015-08-28 21:47                 ` Mathieu Lirzin
2015-08-30 17:23                   ` Ludovic Courtès
2015-08-30 19:06                     ` Alex Kost
2015-08-30 20:42                     ` Mathieu Lirzin
2015-08-31 21:21                       ` Ludovic Courtès
2015-09-01 16:41                         ` Mathieu Lirzin
2015-09-02 21:27                         ` Mathieu Lirzin
2015-09-03 22:12                           ` Ludovic Courtès
2015-09-04 19:43                             ` Mathieu Lirzin
2015-09-06 13:51                               ` Ludovic Courtès
2015-09-06 20:10                                 ` Alex Kost
2015-09-06 21:31                                   ` Ludovic Courtès
2015-09-07 15:50                                     ` Alex Kost
2015-09-07 15:59                                       ` Ludovic Courtès
2015-08-30 10:10                 ` Alex Kost
2015-08-30 12:24                   ` Mathieu Lirzin
2015-08-30 15:19                     ` Alex Kost
2015-07-17 12:35     ` [PATCHES] gnu packages: Clean up synopses and descriptions Alex Kost
2015-07-17 21:07       ` Mathieu Lirzin
2015-07-17 21:30       ` Ludovic Courtès
2015-07-18 10:08         ` Alex Kost
2015-07-18 21:13           ` Andreas Enge
2015-07-19  9:58             ` Alex Kost
2015-07-16 16:03   ` [PATCH] " Alex Kost
2015-07-16 20:02     ` Mathieu Lirzin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8tcfnox.fsf@openmailbox.org \
    --to=mthl@openmailbox.org \
    --cc=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).