diff mbox series

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

Message ID 9de0174c0818edd7c3f1f58a264a6ea3c5c3be50.1623243063.git.public@yoctocell.xyz
State New
Headers show
Series Some improvements to (gnu services configuration) | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Xinglu Chen June 9, 2021, 1:06 p.m. UTC
* 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 mbox series

Patch

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)