summary refs log tree commit diff
path: root/gnu/services
diff options
context:
space:
mode:
authorXinglu Chen <public@yoctocell.xyz>2021-06-09 15:06:26 +0200
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-08-02 14:16:22 -0400
commitad945029a2dbd1fb741be573f13e42c061e72d0f (patch)
treead9cf1a67a6ce0771137adb8783177906398d332 /gnu/services
parent5b2b834269f74865c8ca6ab5e81f6834228490d4 (diff)
downloadguix-ad945029a2dbd1fb741be573f13e42c061e72d0f.tar.gz
services: configuration: Uniformize the generated documentation.
Make the formatting of the generated docs more consistent with the rest of the
docs in the “Services” section of the manual.

* gnu/services/configuration (generate-documentation): Represent the data type
documentation of a field using a DEFTP table rather than DEFTYPEVR elements.

Modified-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/configuration.scm57
1 files changed, 31 insertions, 26 deletions
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index fd07b6fa49..3974fba92d 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -255,32 +255,37 @@ does not have a default value" field kind)))
   (define (generate configuration-name)
     (match (assq-ref documentation configuration-name)
       ((fields . sub-documentation)
-       `((para "Available " (code ,(str configuration-name)) " fields are:")
-         ,@(map
-            (lambda (f)
-              (let ((field-name (configuration-field-name f))
-                    (field-type (configuration-field-type f))
-                    (field-docs (cdr (texi-fragment->stexi
-                                      (configuration-field-documentation f))))
-                    (default (catch #t
-                               (configuration-field-default-value-thunk f)
-                               (lambda _ '%invalid))))
-                (define (show-default? val)
-                  (or (string? val) (number? val) (boolean? val)
-                      (and (symbol? val) (not (eq? val '%invalid)))
-                      (and (list? val) (and-map show-default? val))))
-                `(deftypevr (% (category
-                                (code ,(str configuration-name)) " parameter")
-                               (data-type ,(str field-type))
-                               (name ,(str field-name)))
-                   ,@field-docs
-                   ,@(if (show-default? default)
-                         `((para "Defaults to " (samp ,(str default)) "."))
-                         '())
-                   ,@(append-map
-                      generate
-                      (or (assq-ref sub-documentation field-name) '())))))
-            fields)))))
+       `((deftp (% (category "Data Type") (name ,(str configuration-name)))
+           (para "Available " (code ,(str configuration-name)) " fields are:")
+           (table
+            (% (formatter (asis)))
+            ,@(map
+               (lambda (f)
+                 (let ((field-name (configuration-field-name f))
+                       (field-type (configuration-field-type f))
+                       (field-docs (cdr (texi-fragment->stexi
+                                         (configuration-field-documentation f))))
+                       (default (catch #t
+                                  (configuration-field-default-value-thunk f)
+                                  (lambda _ '%invalid))))
+                   (define (show-default? val)
+                     (or (string? val) (number? val) (boolean? val)
+                         (and (symbol? val) (not (eq? val '%invalid)))
+                         (and (list? val) (and-map show-default? val))))
+
+                   `(entry (% (heading
+                               (code ,(str field-name))
+                               ,@(if (show-default? default)
+                                     `(" (default: "
+                                       (code ,(str default)) ")")
+                                     '())
+                               " (type: " ,(str field-type) ")"))
+                           (para ,@field-docs)
+                           ,@(append-map
+                              generate
+                              (or (assq-ref sub-documentation field-name)
+                                  '())))))
+               fields)))))))
   (stexi->texi `(*fragment* . ,(generate documentation-name))))
 
 (define (configuration->documentation configuration-symbol)