From 3500e659f114e0e8213f2b8340128f66251bd7b4 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@openmailbox.org>
Date: Tue, 15 Sep 2015 17:38:56 +0200
Subject: [PATCH] lint: Add 'check-texinfo-markup' checker.

* guix/script/lint.scm (check-description-style): Check for invalid
  Texinfo markup.
* tests/lint.scm: Test it.
---
 guix/scripts/lint.scm | 9 +++++++++
 tests/lint.scm        | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index ab7d7c67dc1..71f582afe73 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
 ;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -141,6 +142,13 @@ (define (check-not-empty description)
                     (_ "description should not be empty")
                     'description)))
 
+  (define (check-texinfo-markup package)
+    "Check that PACKAGE description can be parsed as a Texinfo fragment."
+    (catch 'parser-error
+      (lambda () (package-description-string package))
+      (lambda (keys . args)
+        (emit-warning package (_ "Texinfo markup in description is invalid")))))
+
   (define (check-proper-start description)
     (unless (or (properly-starts-sentence? description)
                 (string-prefix-ci? (package-name package) description))
@@ -170,6 +178,7 @@ (define (check-end-of-sentence-space description)
   (let ((description (package-description package)))
     (when (string? description)
       (check-not-empty description)
+      (check-texinfo-markup package)
       (check-proper-start description)
       (check-end-of-sentence-space description))))
 
diff --git a/tests/lint.scm b/tests/lint.scm
index 76040c1f3ed..9634fb68e72 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com>
 ;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -142,6 +143,13 @@ (define-syntax-rule (with-warnings body ...)
                         (check-description-style pkg)))
                     "description should not be empty")))
 
+(test-assert "description: valid Texinfo markup"
+  (->bool
+   (string-contains
+    (with-warnings
+      (check-description-style (dummy-package "x" (description "f{oo}b@r"))))
+    "Texinfo markup in description is invalid")))
+
 (test-assert "description: does not start with an upper-case letter"
   (->bool
    (string-contains (with-warnings
-- 
GitLab