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)) "}")
32 ;; don't confuse users with #<procedure .. > syntax.
34 (define (scm->string val)
35 (if (and (procedure? val) (symbol? (procedure-name val)))
36 (symbol->string (procedure-name val))
38 (if (self-evaluating? val) "" "'")
39 (call-with-output-string (lambda (port) (display val port)))
49 (define texi-section-alist
51 ;; Hmm, texinfo doesn't have ``part''
54 (2 . "@unnumberedsec")
55 (3 . "@unnumberedsubsec")
56 (4 . "@unnumberedsubsubsec")
57 (5 . "@unnumberedsubsubsec")
60 (define (texi-section level name ref)
61 "texi sectioning command (lower LEVEL means more significant).
62 Add a ref if REF is set
66 "\n" (cdr (assoc level texi-section-alist)) " "
73 (define (one-item->texi label-desc-pair)
74 "Document one (LABEL . DESC); return empty string if LABEL is empty string.
76 (if (eq? (car label-desc-pair) "")
78 (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair))
82 (define (description-list->texi items-alist)
83 "Document ITEMS-ALIST in a table. entries contain (item-label . string-to-use)
87 (apply string-append (map one-item->texi items-alist))
90 (define (texi-menu items-alist)
93 (maxwid (apply max (map (lambda (x) (string-length (car x)))
105 (string-append "\n* " (car x) ":: ")
112 ;; Menus don't appear in html, so we make a list ourselves
115 (description-list->texi (map (lambda (x) (cons (ref-ify (car x)) (cdr x)))
121 (define (texi-node-menu name items-alist)
124 (texi-section 1 name #f)
125 (texi-menu items-alist)))
129 (define (texi-file-head name file-name top items-alist)
133 "\\input texinfo @c -*-texinfo-*-"
134 "\n@setfilename " file-name ".info"
136 "\n@dircategory GNU music project"
138 ;; prepend GNU for dir, must be unique
139 "\n* GNU " name ": (" file-name "). " name "."
141 ;; ugh, prev and next should be settable, of course
142 (node "Top") ",(lilypond)Index,(lilypond)Full Grob interface list," top
144 (texi-section 1 name #f)
145 (texi-menu items-alist)
149 (define (itexi-file-head name file-name top items-alist)
152 (node name) ",,," top
153 (texi-section 1 name #f)
154 (texi-menu items-alist)
159 (define (context-name name)
162 (define (engraver-name name)
165 (define (grob-name name)
167 (symbol->string name)
170 (define (interface-name name)
174 (string-append "@ref{" x "}"))
176 (define (human-listify l)
177 "Produce a textual enumeration from L, a list of strings"
181 ((null? (cdr l)) (car l))
182 ((null? (cddr l)) (string-append (car l) " and " (cadr l)))
183 (else (string-append (car l) ", " (human-listify (cdr l))))
186 (define (writing-wip x)
187 (display (string-append "\nWriting " x " ... ") (current-error-port)))