2 ;;; documentation-lib.scm -- Assorted Functions for generated documentation
4 ;;; source file of the GNU LilyPond music typesetter
6 ;;; (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 ;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 (define (processing name)
10 (display (string-append "\nProcessing " name " ... ") (current-error-port)))
12 (define (self-evaluating? x)
13 (or (number? x) (string? x) (procedure? x) (boolean? x)))
18 ;; ((x1 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
19 ;; ((x2 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
20 ;; ((x3 (regexp-substitute/global #f "\([^@]\)@" x 'pre "\1@@" 'post))
27 (string-append "@code{" (texify (scm->string x)) "}")
30 (define (scm->string val)
32 (if (self-evaluating? val) "" "'")
33 (call-with-output-string (lambda (port) (display val port)))
43 (define texi-section-alist
45 ;; Hmm, texinfo doesn't have ``part''
48 (2 . "@unnumberedsec")
49 (3 . "@unnumberedsubsec")
50 (4 . "@unnumberedsubsubsec")
51 (5 . "@unnumberedsubsubsec")
54 (define (texi-section level name ref)
55 "texi sectioning command (lower LEVEL means more significant).
56 Add a ref if REF is set
60 "\n" (cdr (assoc level texi-section-alist)) " "
67 (define (one-item->texi label-desc-pair)
68 "Document one (LABEL . DESC); return empty string if LABEL is empty string.
70 (if (eq? (car label-desc-pair) "")
72 (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair))
76 (define (description-list->texi items-alist)
77 "Document ITEMS-ALIST in a table. entries contain (item-label . string-to-use)
81 (apply string-append (map one-item->texi items-alist))
84 (define (texi-menu items-alist)
88 (map (lambda (x) (string-append "\n* " (car x) ":: " (cdr x)))
91 ;; Menus don't appear in html, so we make a list ourselves
94 (description-list->texi (map (lambda (x) (cons (ref-ify (car x)) (cdr x)))
100 (define (texi-node-menu name items-alist)
103 (texi-section 1 name #f)
104 (texi-menu items-alist)))
106 (define (texi-file-head name file-name top items-alist)
108 "\\input texinfo @c -*-texinfo-*-"
109 "\n@setfilename " file-name ".info"
111 "\n@dircategory GNU music project"
113 ;; prepend GNU for dir, must be unique
114 "\n* GNU " name ": (" file-name "). " name "."
116 ;; ugh, prev and next should be settable, of course
117 (node "Top") ",(lilypond)Index,(lilypond)Full Grob interface list," top
119 (texi-section 1 name #f)
120 (texi-menu items-alist)
124 (define (itexi-file-head name file-name top items-alist)
127 (node name) ",,," top
128 (texi-section 1 name #f)
129 (texi-menu items-alist)
133 (define (context-name name)
136 (define (engraver-name name)
139 (define (grob-name name)
142 (define (interface-name name)
146 (string-append "@ref{" x "}"))
148 (define (human-listify l)
149 "Produce a textual enumeration from L, a list of strings"
153 ((null? (cdr l)) (car l))
154 ((null? (cddr l)) (string-append (car l) " and " (cadr l)))
155 (else (string-append (car l) ", " (human-listify (cdr l))))
158 (define (writing-wip x)
159 (display (string-append "\nWriting " x " ... ") (current-error-port)))