Subject: [bug#48934] [PATCH 2/2] services: configuration: Show default value when it is a

From: Xinglu Chen <[email-masked]>
Date: Wed, 09 Jun 2021 15:06:27 +0200

* gnu/services/configuration.scm (generate-documentation): If the default
  value of a field is a package, show the value of the ‘name’ field of the
  package.  This might not be the correct name in some cases though.
---
 gnu/services/configuration.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index abcbc70520..99687d065a 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -252,12 +252,20 @@ does not have a default value" field kind)))
                                         (configuration-field-default-value-thunk f)
                                         (lambda _ '%invalid))))
                          (define (show-default? val)
-                           (or (string? val) (number? val) (boolean? val)
+                           (or (string? val) (number? val) (boolean? val) (package? val)
                                (and (symbol? val) (not (eq? val '%invalid)))
                                (and (list? val) (and-map show-default? val))))
+
+                         (define (show-default val)
+                           (cond
+                            ((package? val)
+                             ;; Maybe not always correct.
+                             (package-name val))
+                            (else (str val))))
+
                          `(entry (% (heading (code ,(str field-name))
                                              ,@(if (show-default? default)
-                                                   `(" (default: " (code ,(str default)) ")")
+                                                   `(" (default: " (code ,(show-default default)) ")")
                                                    '())
                                              " (type: "
                                              ,(str field-type)
-- 
2.32.0