blob: b72390b895c124592416f5d562fa9694e1094d44 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
;;; -*- mode: scheme; coding: utf-8; -*-
;;;
;;; Copyright (C) 2013 Free Software Foundation, Inc.
;;;
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public
;;; License as published by the Free Software Foundation; either
;;; version 3 of the License, or (at your option) any later version.
;;;
;;; This library 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
;;; Lesser General Public License for more details.
;;;
;;; You should have received a copy of the GNU Lesser General Public
;;; License along with this library; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;;;
;;; Read Texinfo fragments from stdin (docstrings of Guile's primitives
;;; in the format of `guile-procedures.texi'), and write to stdout a
;;; textual rendering thereof. The output preserves page breaks (^L)
;;; found in the input, as per the Guile Documentation Format
;;; version 2---see (ice-9 documentation).
;;;
(use-modules (texinfo)
(texinfo plain-text)
(srfi srfi-1)
(ice-9 match)
(rnrs io ports))
(define (docstring-fragments->strings str)
"Return the list resulting from the split of STR at each page
break (^L)"
(string-tokenize str (char-set-complement (char-set #\page))))
(match (command-line)
((_ texi-file)
(let* ((fragments (remove (compose string-null? string-trim-both)
(call-with-input-file texi-file
(compose docstring-fragments->strings
get-string-all))))
(stexi (map texi-fragment->stexi fragments)))
(format #t "Produced by GNU Guile ~a from `~a'.~%~%"
(version) texi-file)
(for-each (lambda (stexi)
(display #\page)
(display (stexi->plain-text stexi)))
stexi)))
((command args ...)
(format (current-error-port) "invalid arguments: ~s~%" args)
(format (current-error-port) "Usage: ~a TEXINFO-FILE~%" command)
(exit 1)))
|