From: Xinglu Chen <public@yoctocell.xyz>
To: 48934@debbugs.gnu.org
Subject: [bug#48934] [PATCH 1/2] services: configuration: Change formatting of generated
Date: Wed, 09 Jun 2021 15:06:26 +0200 [thread overview]
Message-ID: <07aed2e6ffe6c6fdab4a38207cafb7d3169c6e11.1623243063.git.public@yoctocell.xyz> (raw)
In-Reply-To: <cover.1623243063.git.public@yoctocell.xyz>
* gnu/services/configuration (generate-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.scm | 54 ++++++++++++++++++----------------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index f23840ee6d..abcbc70520 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -239,32 +239,34 @@ 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)
--
2.32.0
next prev parent reply other threads:[~2021-06-09 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 13:04 [bug#48934] [PATCH 0/2] Some improvements to (gnu services configuration) Xinglu Chen
2021-06-09 13:06 ` Xinglu Chen [this message]
2021-08-02 18:10 ` Maxim Cournoyer
2021-06-09 13:06 ` [bug#48934] [PATCH 2/2] services: configuration: Show default value when it is a Xinglu Chen
2021-08-02 18:21 ` bug#48934: [PATCH 0/2] Some improvements to (gnu services configuration) Maxim Cournoyer
2021-08-03 7:24 ` [bug#48934] " Xinglu Chen
2021-08-03 14:38 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07aed2e6ffe6c6fdab4a38207cafb7d3169c6e11.1623243063.git.public@yoctocell.xyz \
--to=public@yoctocell.xyz \
--cc=48934@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.