mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
import/utils: beautify-description: Wrap class names in @code{...}.
* guix/import/utils.scm (beautify-description): Add procedure to wrap words in @code{...} markup. * tests/import-utils.scm: Add two tests.
This commit is contained in:
parent
5566f691a2
commit
b9bd1bcce9
2 changed files with 16 additions and 2 deletions
|
@ -335,7 +335,13 @@ (define* (beautify-description description #:optional (length 80))
|
|||
(cut string-trim-both <> #\')
|
||||
;; Escape single @ to prevent it from being understood as
|
||||
;; invalid Texinfo syntax.
|
||||
(cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)))))
|
||||
(cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)
|
||||
;; Wrap camelCase or PascalCase words in @code{...}.
|
||||
(lambda (word)
|
||||
(let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])")))
|
||||
(match (list-matches pattern word)
|
||||
(() word)
|
||||
(_ (string-append "@code{" word "}")))))))))
|
||||
(words
|
||||
(string-tokenize (string-trim-both description)
|
||||
(char-set-complement
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2015, 2017, 2022 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;; Copyright © 2015, 2017, 2022, 2023 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
|
||||
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
|
||||
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
||||
|
@ -53,6 +53,14 @@ (define-module (test-import-utils)
|
|||
"This @@ is not Texinfo syntax. Neither is this %@@>%."
|
||||
(beautify-description "This @ is not Texinfo syntax. Neither is this %@>%."))
|
||||
|
||||
(test-equal "beautify-description: wrap PascalCase words in @code"
|
||||
"The term @code{DelayedMatrix} refers to a class."
|
||||
(beautify-description "The term DelayedMatrix refers to a class."))
|
||||
|
||||
(test-equal "beautify-description: do not wrap acronyms in @code"
|
||||
"The term API is not code, but @code{myAPI} might be."
|
||||
(beautify-description "The term API is not code, but myAPI might be."))
|
||||
|
||||
(test-equal "license->symbol"
|
||||
'license:lgpl2.0
|
||||
(license->symbol license:lgpl2.0))
|
||||
|
|
Loading…
Reference in a new issue