From: Nikita Karetnikov <nikita@karetnikov.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: bug-guix@gnu.org
Subject: Re: Literate programming
Date: Fri, 10 May 2013 02:21:18 +0400 [thread overview]
Message-ID: <87ppwz23s1.fsf@karetnikov.org> (raw)
In-Reply-To: <871uan35qw.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 06 Apr 2013 19:53:43 +0200")
[-- Attachment #1.1: Type: text/plain, Size: 1530 bytes --]
> I wouldn’t want to automatically extract command-line doc. First,
> because --help needs to be concise, whereas the manual can give
> additional details (compare ‘guix package --help’ and “Invoking guix
> packages”.) Second, because the manual should include cross-references
> and examples to make things more understandable.
Here is how I see the process: one creates a command-line tool and uses
Commentary to document it. Then the person should manually @include the
output of extracted and converted Commentary (e.g., 'filename.texi'),
which isn't created at this point. After that it's only necessary to
run 'make' to compile 'filename.texi' and 'guix.texi'. (Note that it's
possible to use cross-references.)
I've created a rough example. 'doc/hash-texi.scm' shows how to extract
and convert Commentary. The same thing should be done for all scripts.
So each 'file.scm' should have a corresponding 'file.texi'. Other files
in 'guix' will need a different extraction scheme because it's necessary
to get docstrings as well. I'd like to write a couple of procedures and
put them into a makefile. Still, it'll be necessary to @include files
manually.
I guess this sounds like a lot of work, but the same approach is also
used with LaTeX [1]. You have a main file, a style file, and other files
which will be included into the main file.
I'd also like to find a way to automatically create a table of contents.
[1] https://en.wikibooks.org/wiki/LaTeX/Modular_Documents
[-- Attachment #1.2: autodoc.diff --]
[-- Type: text/x-diff, Size: 5287 bytes --]
diff --git a/doc/guix.texi b/doc/guix.texi
index 9147f43..17f7e14 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1214,36 +1214,7 @@ the @code{package-derivation} procedure of the @code{(guix packages)}
module, and to the @code{build-derivations} procedure of the @code{(guix
store)} module.
-@node Invoking guix hash
-@section Invoking @command{guix hash}
-
-The @command{guix hash} command allows to check the integrity of a file.
-It is primarily a convenience tool for anyone contributing to the
-distribution: it computes the cryptographic hash of a file, which can be
-used in the definition of a package (@pxref{Defining Packages}).
-
-The general syntax is:
-
-@example
-guix hash @var{option} @var{file}
-@end example
-
-@command{guix hash} has the following option:
-
-@table @code
-
-@item --format=@var{fmt}
-@itemx -f @var{fmt}
-Write the hash in the given format.
-
-Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
-(@code{hex} and @code{hexadecimal} can be used as well).
-
-If the @option{--format} option is not specified, @command{guix hash}
-will output the hash in @code{nix-base32}. This representation is used
-in the definitions of packages.
-
-@end table
+@include hash.texi
@node Invoking guix refresh
@section Invoking @command{guix refresh}
diff --git a/doc/hash-texi.scm b/doc/hash-texi.scm
new file mode 100644
index 0000000..801f92f
--- /dev/null
+++ b/doc/hash-texi.scm
@@ -0,0 +1,29 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(use-modules (texinfo serialize)
+ (ice-9 session))
+
+;; 'string->stexi' and 'module-commentary' are used instead of
+;; 'module-stexi-documentation' because we do not want to mention 'guix-hash'
+;; and the names of sections.
+(call-with-output-file "doc/hash.texi"
+ (lambda (out)
+ (format out "~a~%"
+ (stexi->texi ((@@ (texinfo reflection) string->stexi)
+ (module-commentary '(guix scripts hash)))))))
\ No newline at end of file
diff --git a/doc/hash.texi b/doc/hash.texi
new file mode 100644
index 0000000..a6469da
--- /dev/null
+++ b/doc/hash.texi
@@ -0,0 +1,35 @@
+
+@c %start of fragment
+
+@node Invoking guix hash
+@section Invoking @command{guix hash}
+The @command{guix hash} command allows to check the integrity of a file.
+It is primarily a convenience tool for anyone contributing to the
+distribution: it computes the cryptographic hash of a file, which can be
+used in the definition of a package (@pxref{Defining Packages}).
+
+The general syntax is:
+
+@example
+ guix hash @var{option} @var{file}
+@end example
+
+@command{guix hash} has the following option:
+
+@table @code
+@item --format=@var{fmt}
+@itemx -f @var{fmt}
+Write the hash in the given format.
+
+Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
+(@code{hex} and @code{hexadecimal} can be used as well).
+
+If the @option{--format} option is not specified, @command{guix hash}
+will output the hash in @code{nix-base32}. This representation is used
+in the definitions of packages.
+
+@end table
+
+
+@c %end of fragment
+
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index deded63..41346ac 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -30,6 +30,41 @@
#:export (guix-hash))
\f
+;;; Commentary:
+;;
+;; @node Invoking guix hash
+;; @section Invoking @command{guix hash}
+;;
+;; The @command{guix hash} command allows to check the integrity of a file.
+;; It is primarily a convenience tool for anyone contributing to the
+;; distribution: it computes the cryptographic hash of a file, which can be
+;; used in the definition of a package (@pxref{Defining Packages}).
+;;
+;; The general syntax is:
+;;
+;; @example
+;; guix hash @var{option} @var{file}
+;; @end example
+;;
+;; @command{guix hash} has the following option:
+;;
+;; @table @code
+;;
+;; @item --format=@var{fmt}
+;; @itemx -f @var{fmt}
+;; Write the hash in the given format.
+;;
+;; Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
+;; (@code{hex} and @code{hexadecimal} can be used as well).
+;;
+;; If the @option{--format} option is not specified, @command{guix hash}
+;; will output the hash in @code{nix-base32}. This representation is used
+;; in the definitions of packages.
+;;
+;; @end table
+;;
+;;; Code:
+
;;;
;;; Command-line options.
;;;
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-05-09 22:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 20:30 Literate programming Nikita Karetnikov
2013-02-04 21:52 ` Ludovic Courtès
2013-04-06 1:21 ` Nikita Karetnikov
2013-04-06 13:50 ` Ludovic Courtès
2013-04-06 15:26 ` Nikita Karetnikov
2013-04-06 17:53 ` Ludovic Courtès
2013-05-09 22:21 ` Nikita Karetnikov [this message]
2013-05-11 16:14 ` Ludovic Courtès
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=87ppwz23s1.fsf@karetnikov.org \
--to=nikita@karetnikov.org \
--cc=bug-guix@gnu.org \
--cc=ludo@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.