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 (uniqued-alist alist acc)
11 (if (assoc (caar alist) acc)
12 (uniqued-alist (cdr alist) acc)
13 (uniqued-alist (cdr alist) (cons (car alist) acc)
16 (define (uniq-list list)
18 (if (null? (cdr list))
20 (if (equal? (car list) (cadr list))
21 (uniq-list (cdr list))
22 (cons (car list) (uniq-list (cdr list)))
27 (string<? (symbol->string (car x))
28 (symbol->string (car y))))
30 (define (processing name)
31 (display (string-append "\nProcessing " name " ... ") (current-error-port)))
33 (define (self-evaluating? x)
34 (or (number? x) (string? x) (procedure? x) (boolean? x)))
39 ;; ((x1 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
40 ;; ((x2 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
41 ;; ((x3 (regexp-substitute/global #f "\([^@]\)@" x 'pre "\1@@" 'post))
48 (string-append "@code{" (texify (scm->string x)) "}")
51 (define (scm->string val)
53 (if (self-evaluating? val) "" "'")
54 (call-with-output-string (lambda (port) (display val port)))
64 (define texi-section-alist
66 ;; Hmm, texinfo doesn't have ``part''
69 (2 . "@unnumberedsec")
70 (3 . "@unnumberedsubsec")
71 (4 . "@unnumberedsubsubsec")
72 (5 . "@unnumberedsubsubsec")
75 (define (texi-section level name ref)
76 "texi sectioning command (lower LEVEL means more significant).
77 Add a ref if REF is set
81 "\n" (cdr (assoc level texi-section-alist)) " "
88 (define (one-item->texi label-desc-pair)
89 "Document one (LABEL . DESC); return empty string if LABEL is empty string.
91 (if (eq? (car label-desc-pair) "")
93 (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair))
97 (define (description-list->texi items-alist)
98 "Document ITEMS-ALIST in a table. entries contain (item-label . string-to-use)
102 (apply string-append (map one-item->texi items-alist))
105 (define (texi-menu items-alist)
109 (map (lambda (x) (string-append "\n* " (car x) ":: " (cdr 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)))
127 (define (texi-file-head name file-name top items-alist)
129 "\\input texinfo @c -*-texinfo-*-"
130 "\n@setfilename " file-name ".info"
132 "\n@dircategory GNU music project"
134 ;; prepend GNU for dir, must be unique
135 "\n* GNU " name " (" file-name "). " name "."
137 (node "Top") ",(lilypond)Index,(lilypond)Development," top
139 (texi-section 1 name #f)
140 (texi-menu items-alist)
144 (define (context-name name)
147 (define (engraver-name name)
150 (define (grob-name name)
153 (define (interface-name name)
157 (string-append "@ref{" x "}"))
159 (define (human-listify l)
160 "Produce a textual enumeration from L, a list of strings"
164 ((null? (cdr l)) (car l))
165 ((null? (cddr l)) (string-append (car l) " and " (cadr l)))
166 (else (string-append (car l) ", " (human-listify (cdr l))))
169 (define (writing-wip x)
170 (display (string-append "\nWriting " x " ... ") (current-error-port)))