[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#47741] [PATCH 2/3] services: configuration: Add syntactic sugar to
From: |
Maxim Cournoyer |
Subject: |
[bug#47741] [PATCH 2/3] services: configuration: Add syntactic sugar to easily generate documentation. |
Date: |
Tue, 13 Apr 2021 00:17:09 -0400 |
I found the original (undocumented) interface difficult to understand, which
was the rationale for adding a simpler one on top of it.
* gnu/services/configuration.scm (configuration->documentation): New procedure.
---
gnu/services/configuration.scm | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gnu/services/configuration.scm b/gnu/services/configuration.scm
index 90f12a8d39..750535342d 100644
--- a/gnu/services/configuration.scm
+++ b/gnu/services/configuration.scm
@@ -43,6 +43,7 @@
define-configuration
validate-configuration
generate-documentation
+ configuration->documentation
serialize-package))
;;; Commentary:
@@ -188,3 +189,15 @@
(or (assq-ref sub-documentation field-name) '())))))
fields)))))
(stexi->texi `(*fragment* . ,(generate documentation-name))))
+
+(define (configuration->documentation configuration-symbol)
+ "Takes CONFIGURATION-SYMBOL, the symbol used when defining a configuration
+record with DEFINE-CONFIGURATION, and outputs the Texinfo documentation of its
+fields."
+ ;; This is syntax sugar for a simple, straight-forward application of
+ ;; GENERATE-DOCUMENTATION.
+ (let ((fields-getter (module-ref (current-module)
+ (symbol-append configuration-symbol
+ '-fields))))
+ (format #t (generate-documentation `((,configuration-symbol
,fields-getter))
+ configuration-symbol))))
--
2.31.1