1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-28 03:51:53 +02:00

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>
This commit is contained in:
Xinglu Chen
2021-06-09 15:06:26 +02:00
committed by Maxim Cournoyer
parent 5b2b834269
commit ad945029a2
+31 -26
View File
@@ -255,32 +255,37 @@ does not have a default value" field kind)))
(define (generate configuration-name) (define (generate configuration-name)
(match (assq-ref documentation configuration-name) (match (assq-ref documentation configuration-name)
((fields . sub-documentation) ((fields . sub-documentation)
`((para "Available " (code ,(str configuration-name)) " fields are:") `((deftp (% (category "Data Type") (name ,(str configuration-name)))
,@(map (para "Available " (code ,(str configuration-name)) " fields are:")
(lambda (f) (table
(let ((field-name (configuration-field-name f)) (% (formatter (asis)))
(field-type (configuration-field-type f)) ,@(map
(field-docs (cdr (texi-fragment->stexi (lambda (f)
(configuration-field-documentation f)))) (let ((field-name (configuration-field-name f))
(default (catch #t (field-type (configuration-field-type f))
(configuration-field-default-value-thunk f) (field-docs (cdr (texi-fragment->stexi
(lambda _ '%invalid)))) (configuration-field-documentation f))))
(define (show-default? val) (default (catch #t
(or (string? val) (number? val) (boolean? val) (configuration-field-default-value-thunk f)
(and (symbol? val) (not (eq? val '%invalid))) (lambda _ '%invalid))))
(and (list? val) (and-map show-default? val)))) (define (show-default? val)
`(deftypevr (% (category (or (string? val) (number? val) (boolean? val)
(code ,(str configuration-name)) " parameter") (and (symbol? val) (not (eq? val '%invalid)))
(data-type ,(str field-type)) (and (list? val) (and-map show-default? val))))
(name ,(str field-name)))
,@field-docs `(entry (% (heading
,@(if (show-default? default) (code ,(str field-name))
`((para "Defaults to " (samp ,(str default)) ".")) ,@(if (show-default? default)
'()) `(" (default: "
,@(append-map (code ,(str default)) ")")
generate '())
(or (assq-ref sub-documentation field-name) '()))))) " (type: " ,(str field-type) ")"))
fields))))) (para ,@field-docs)
,@(append-map
generate
(or (assq-ref sub-documentation field-name)
'())))))
fields)))))))
(stexi->texi `(*fragment* . ,(generate documentation-name)))) (stexi->texi `(*fragment* . ,(generate documentation-name))))
(define (configuration->documentation configuration-symbol) (define (configuration->documentation configuration-symbol)