mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 13:36:36 +01:00
import: utils: Wrap function names in @code.
* guix/import/utils.scm (beautify-description): Adjust to include "()" in @code wrapper. * tests/import-utils.scm ("beautify-description: wrap function names in @code"): New test. Change-Id: I2b58728571a18ce8302c1b6f98b0c16dbe5931c3
This commit is contained in:
parent
c851b73e79
commit
8bee3a5910
2 changed files with 17 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
;;; Copyright © 2012, 2013, 2018, 2019, 2020, 2023 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012, 2013, 2018, 2019, 2020, 2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
|
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
|
||||||
;;; Copyright © 2016 David Craven <david@craven.ch>
|
;;; Copyright © 2016 David Craven <david@craven.ch>
|
||||||
;;; Copyright © 2017, 2019, 2020, 2022, 2023 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2017, 2019, 2020, 2022, 2023, 2024 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
|
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
|
||||||
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
|
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
|
||||||
;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com>
|
;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com>
|
||||||
|
@ -338,15 +338,21 @@ (define* (beautify-description description #:optional (length 80))
|
||||||
;; Escape single @ to prevent it from being understood as
|
;; Escape single @ to prevent it from being understood as
|
||||||
;; invalid Texinfo syntax.
|
;; invalid Texinfo syntax.
|
||||||
(cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)
|
(cut regexp-substitute/global #f "@" <> 'pre "@@" 'post)
|
||||||
;; Wrap camelCase or PascalCase words in @code{...}.
|
;; Wrap camelCase or PascalCase words or text followed
|
||||||
|
;; immediately by "()" in @code{...}.
|
||||||
(lambda (word)
|
(lambda (word)
|
||||||
(let ((pattern (make-regexp "([A-Z][a-z]+[A-Z]|[a-z]+[A-Z])")))
|
(let ((pattern
|
||||||
|
(make-regexp
|
||||||
|
"([A-Z][a-z]+[A-Z]|[a-z]+[A-Z]|.+\\(\\))")))
|
||||||
(match (list-matches pattern word)
|
(match (list-matches pattern word)
|
||||||
(() word)
|
(() word)
|
||||||
((m . rest)
|
((m . rest)
|
||||||
;; Do not include leading or trailing punctuation.
|
;; Do not include leading or trailing punctuation,
|
||||||
(let* ((last-text (or (and=> (string-skip-right word char-set:punctuation) 1+)
|
;; unless its "()".
|
||||||
(string-length word)))
|
(let* ((last-text (if (string-suffix? "()" (match:substring m 1))
|
||||||
|
(string-length (match:substring m 1))
|
||||||
|
(or (and=> (string-skip-right word char-set:punctuation) 1+)
|
||||||
|
(string-length word))))
|
||||||
(inner (substring word (match:start m) last-text))
|
(inner (substring word (match:start m) last-text))
|
||||||
(pre (string-take word (match:start m)))
|
(pre (string-take word (match:start m)))
|
||||||
(post (substring word last-text (string-length word))))
|
(post (substring word last-text (string-length word))))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2015, 2017, 2022, 2023 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2015, 2017, 2022, 2023, 2024 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
|
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
|
||||||
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
|
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
|
||||||
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
||||||
|
@ -65,6 +65,10 @@ (define-module (test-import-utils)
|
||||||
"Code (@code{DelayedMatrix}, @code{MaMa}, or @code{MeMe}) should be wrapped."
|
"Code (@code{DelayedMatrix}, @code{MaMa}, or @code{MeMe}) should be wrapped."
|
||||||
(beautify-description "Code (DelayedMatrix, MaMa, or MeMe) should be wrapped."))
|
(beautify-description "Code (DelayedMatrix, MaMa, or MeMe) should be wrapped."))
|
||||||
|
|
||||||
|
(test-equal "beautify-description: wrap function names in @code"
|
||||||
|
"The main functions are: @code{haplo.em()} and @code{haplo.power()}; FYI."
|
||||||
|
(beautify-description "The main functions are: haplo.em() and haplo.power(); FYI."))
|
||||||
|
|
||||||
(test-equal "license->symbol"
|
(test-equal "license->symbol"
|
||||||
'license:lgpl2.0
|
'license:lgpl2.0
|
||||||
(license->symbol license:lgpl2.0))
|
(license->symbol license:lgpl2.0))
|
||||||
|
|
Loading…
Reference in a new issue