File: document-module.scm

package info (click to toggle)
guile-lib 0.2.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,940 kB
  • sloc: lisp: 7,099; sh: 4,177; makefile: 190
file content (62 lines) | stat: -rwxr-xr-x 2,038 bytes parent folder | download | duplicates (6)
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
56
57
58
59
60
61
62
#! /usr/bin/guile -s
!#

;; document-module.scm -- document a set of scheme modules as HTML
;; Copyright (C) 2004,2009  Andy Wingo <wingo at pobox dot com>

;; This program 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.
;;
;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

(read-set! keywords 'prefix)

(use-modules (srfi srfi-13)
             (srfi srfi-1)
             (sxml simple)
             (texinfo reflection)
             (texinfo html)
             (texinfo serialize)
             (texinfo plain-text))

(define output-format 'text)
(define module-name #f)

(define (usage)
  (format #t "Usage: document-module.scm {--html,--texinfo,--text} MODULE-NAME\n")
  (exit 1))

(case (length (program-arguments))
  ((2)
   (set! module-name
         (call-with-input-string (cadr (program-arguments)) read)))
  ((3)
   (let ((sformat (cadr (program-arguments))))
     (cond
      ((string=? sformat "--html") (set! output-format 'html))
      ((string=? sformat "--texinfo") (set! output-format 'texinfo))
      ((string=? sformat "--text") (set! output-format 'text))
      (else (usage)))
     (set! module-name
           (call-with-input-string (caddr (program-arguments)) read))))
  (else (usage)))

(define module-docs (module-stexi-documentation module-name))

(case output-format
  ((text)
   (display (stexi->plain-text module-docs)))
  ((html)
   (sxml->xml (stexi->shtml module-docs)))
  ((texinfo)
   (display (stexi->texi module-docs))))

;;; arch-tag: 0529d121-eeb0-4f8c-8046-12f2020763ab