mirror of
git://git.savannah.gnu.org/guix.git
synced 2023-12-14 03:33:07 +01:00
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.
This commit is contained in:
parent
4534d85e70
commit
4bb54cc42f
2 changed files with 23 additions and 0 deletions
|
@ -142,6 +142,10 @@ monad."
|
||||||
"Return #t if S starts with what looks like an abbreviation or acronym."
|
"Return #t if S starts with what looks like an abbreviation or acronym."
|
||||||
(string-match "^[A-Z][A-Z0-9]+\\>" s))
|
(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)
|
(define (check-description-style package)
|
||||||
;; Emit a warning if stylistic issues are found in the description of PACKAGE.
|
;; Emit a warning if stylistic issues are found in the description of PACKAGE.
|
||||||
(define (check-not-empty description)
|
(define (check-not-empty description)
|
||||||
|
@ -173,6 +177,16 @@ trademark sign '~a' at ~d")
|
||||||
'description))
|
'description))
|
||||||
(else #t)))
|
(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)
|
(define (check-proper-start description)
|
||||||
(unless (or (properly-starts-sentence? description)
|
(unless (or (properly-starts-sentence? description)
|
||||||
(string-prefix-ci? (package-name package) description))
|
(string-prefix-ci? (package-name package) description))
|
||||||
|
@ -203,6 +217,7 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
|
||||||
(if (string? description)
|
(if (string? description)
|
||||||
(begin
|
(begin
|
||||||
(check-not-empty description)
|
(check-not-empty description)
|
||||||
|
(check-quotes description)
|
||||||
(check-trademarks description)
|
(check-trademarks description)
|
||||||
;; Use raw description for this because Texinfo rendering
|
;; Use raw description for this because Texinfo rendering
|
||||||
;; automatically fixes end of sentence space.
|
;; automatically fixes end of sentence space.
|
||||||
|
|
|
@ -218,6 +218,14 @@ string) on HTTP requests."
|
||||||
(check-description-style pkg)))
|
(check-description-style pkg)))
|
||||||
"should not contain trademark sign"))))
|
"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"
|
(test-assert "synopsis: not a string"
|
||||||
(->bool
|
(->bool
|
||||||
(string-contains (with-warnings
|
(string-contains (with-warnings
|
||||||
|
|
Loading…
Reference in a new issue