unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 47741@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#47741] [PATCH 2/3] services: configuration: Add syntactic sugar to easily generate documentation.
Date: Tue, 13 Apr 2021 00:17:09 -0400	[thread overview]
Message-ID: <20210413041710.1708-2-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20210413041710.1708-1-maxim.cournoyer@gmail.com>

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





  reply	other threads:[~2021-04-13  4:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  4:14 [bug#47741] [PATCH 0/3] Add a service for OpenDHT Maxim Cournoyer
2021-04-13  4:17 ` [bug#47741] [PATCH 1/3] gnu: opendht: Add Python bindings, tools Maxim Cournoyer
2021-04-13  4:17   ` Maxim Cournoyer [this message]
2021-04-13  4:17   ` [bug#47741] [PATCH 3/3] services: Add opendht Maxim Cournoyer
2021-05-18  3:59     ` bug#47741: [PATCH 0/3] Add a service for OpenDHT 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210413041710.1708-2-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=47741@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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).