diff options
Diffstat (limited to 'doc/skribilo.scm')
-rw-r--r-- | doc/skribilo.scm | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/doc/skribilo.scm b/doc/skribilo.scm index 1025db4..a666eed 100644 --- a/doc/skribilo.scm +++ b/doc/skribilo.scm @@ -1,5 +1,5 @@ ;;; guix-forge --- Guix software forge meta-service -;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2022–2023 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of guix-forge. ;;; @@ -207,13 +207,28 @@ the default value. DEFAULT, when specified, will override the default value extracted from the source." (make-record-field identifier #f default documentation)) +(define (quoted-write object port) + "Write @var{object} to @var{port} printing quoted expressions using +the quote character." + (match object + (('quote child) + (display "'" port) + (quoted-write child port)) + ((parent children ...) + (display "(" port) + (quoted-write parent port) + (unless (null? children) + (display " " port)) + (for-each (cut quoted-write <> port) + children) + (display ")" port)) + (_ (write object port)))) + (define (expression->string exp) "Return EXP as a human-readable string. In particular, quote forms are printed using the quote symbol." - (match exp - (('quote exp) - (string-append "'" (expression->string exp))) - (_ (format "~s" exp)))) + (call-with-output-string + (cut quoted-write exp <>))) (define (record-documentation file identifier . fields) "Document record identified by IDENTIFIER, a symbol, in FILE. FIELDS |