[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/07: lint: Suggest @code instead of quotes.
From: |
Ludovic Courtès |
Subject: |
04/07: lint: Suggest @code instead of quotes. |
Date: |
Wed, 19 Oct 2016 13:55:00 +0000 (UTC) |
civodul pushed a commit to branch master
in repository guix.
commit 4bb54cc42ff5653fe59f5a8ebf39515ba1840a6d
Author: Ludovic Courtès <address@hidden>
Date: Wed Oct 19 13:55:25 2016 +0200
lint: Suggest @code instead of quotes.
* guix/scripts/lint.scm (%quoted-identifier-rx): New variable.
(check-description-style)[check-quotes]: New procedure.
Use it.
* tests/lint.scm ("description: suggest ornament instead of quotes"):
New test.
---
guix/scripts/lint.scm | 15 +++++++++++++++
tests/lint.scm | 8 ++++++++
2 files changed, 23 insertions(+)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index b3ec6d6..d6281ea 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -142,6 +142,10 @@ monad."
"Return #t if S starts with what looks like an abbreviation or acronym."
(string-match "^[A-Z][A-Z0-9]+\\>" s))
+(define %quoted-identifier-rx
+ ;; A quoted identifier, like 'this'.
+ (make-regexp "['`][[:graph:]]+'"))
+
(define (check-description-style package)
;; Emit a warning if stylistic issues are found in the description of
PACKAGE.
(define (check-not-empty description)
@@ -173,6 +177,16 @@ trademark sign '~a' at ~d")
'description))
(else #t)))
+ (define (check-quotes description)
+ "Check whether DESCRIPTION contains single quotes and suggest @code."
+ (when (regexp-exec %quoted-identifier-rx description)
+ (emit-warning package
+
+ ;; TRANSLATORS: '@code' is Texinfo markup and must be kept
+ ;; as is.
+ (_ "use @code or similar ornament instead of quotes")
+ 'description)))
+
(define (check-proper-start description)
(unless (or (properly-starts-sentence? description)
(string-prefix-ci? (package-name package) description))
@@ -203,6 +217,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
(if (string? description)
(begin
(check-not-empty description)
+ (check-quotes description)
(check-trademarks description)
;; Use raw description for this because Texinfo rendering
;; automatically fixes end of sentence space.
diff --git a/tests/lint.scm b/tests/lint.scm
index d692b42..fa2d19b 100644
--- a/tests/lint.scm
+++ b/tests/lint.scm
@@ -218,6 +218,14 @@ string) on HTTP requests."
(check-description-style pkg)))
"should not contain trademark sign"))))
+(test-assert "description: suggest ornament instead of quotes"
+ (->bool
+ (string-contains (with-warnings
+ (let ((pkg (dummy-package "x"
+ (description "This is a 'quoted' thing."))))
+ (check-description-style pkg)))
+ "use @code")))
+
(test-assert "synopsis: not a string"
(->bool
(string-contains (with-warnings
- branch master updated (99df12c -> fe9bdb5), Ludovic Courtès, 2016/10/19
- 04/07: lint: Suggest @code instead of quotes.,
Ludovic Courtès <=
- 02/07: gnu: glfw: Propagate the relevant inputs., Ludovic Courtès, 2016/10/19
- 06/07: tests: Fix typo in 'with-graft' transformation test., Ludovic Courtès, 2016/10/19
- 07/07: tests: Make sure child process of 'pivot-root' test exits., Ludovic Courtès, 2016/10/19
- 01/07: container: Allow 'container-excursion' to the same namespaces., Ludovic Courtès, 2016/10/19
- 03/07: gnu: Add Ao., Ludovic Courtès, 2016/10/19
- 05/07: Use (ice-9 binary-ports) instead of (rnrs io ports)., Ludovic Courtès, 2016/10/19