2 ;;; documentation-lib.scm -- Assorted Functions for generated documentation
4 ;;; source file of the GNU LilyPond music typesetter
6 ;;; (c) 2000 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)
18 (string<? (symbol->string (car x))
19 (symbol->string (car y))))
21 (define (processing name)
22 (display (string-append "\nProcessing " name " ... ") (current-error-port)))
24 (define (self-evaluating? x)
25 (or (number? x) (string? x) (procedure? x) (boolean? x)))
30 ;; ((x1 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
31 ;; ((x2 (regexp-substitute/global #f "\([^@]\){" x 'pre "\1@{" 'post))
32 ;; ((x3 (regexp-substitute/global #f "\([^@]\)@" x 'pre "\1@@" 'post))
39 (string-append "@code{" (texify (scm->string x)) "}")
42 (define (scm->string val)
44 (if (self-evaluating? val) "" "'")
45 (call-with-output-string (lambda (port) (display val port)))
55 (define texi-section-alist
57 ;; Hmm, texinfo doesn't have ``part''
60 (2 . "@unnumberedsec")
61 (3 . "@unnumberedsubsec")
62 (4 . "@unnumberedsubsubsec")
63 (5 . "@unnumberedsubsubsec")
66 (define (texi-section level name ref)
67 "texi sectioning command (lower LEVEL means more significant).
68 Add a ref if REF is set
72 "\n" (cdr (assoc level texi-section-alist)) " "
74 (string-append "@ref{" name "}")
79 (define (one-item->texi label-desc-pair)
80 "Document one (LABEL . DESC); return empty string if LABEL is empty string.
82 (if (eq? (car label-desc-pair) "")
84 (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair))
88 (define (description-list->texi items-alist)
89 "Document ITEMS-ALIST in a table. entries contain (item-label . string-to-use)
93 (apply string-append (map one-item->texi items-alist))
96 (define (texi-menu items-alist)
100 (map (lambda (x) (string-append "\n* " (car x) ":: " (cdr x)))
103 ;; Menus don't appear in html, so we make a list ourselves
106 (description-list->texi (map (lambda (x) (cons (reffy (car x)) (cdr x)))
112 (define (texi-node-menu name items-alist)
115 (texi-section 1 name #f)
116 (texi-menu items-alist)))
118 (define (texi-file-head name file-name top items-alist)
120 "\\input texinfo @c -*-texinfo-*-"
121 "\n@setfilename " file-name ".info"
123 "\n@dircategory GNU music project"
125 ;; prepend GNU for dir, must be unique
126 "\n* GNU " name " (" file-name "). " name "."
128 (node "Top") ",(lilypond)Development,," top
130 (texi-section 1 name #f)
131 (texi-menu items-alist)
135 (define (context-name name)
136 (string-append "Context " name))
138 (define (engraver-name name)
141 (define (grob-name name)
142 (string-append "Grob " name))
144 (define (interface-name name)
148 (string-append "@ref{" x "}"))
150 (define (human-listify l)
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)))