2 ;;;; documentation-lib.scm -- Assorted Functions for generated documentation
4 ;;;; source file of the GNU LilyPond music typesetter
6 ;;;; (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 (use-modules (oop goops)
14 (define-class <texi-node> ()
15 (children #:init-value '() #:accessor node-children #:init-keyword #:children)
16 (text #:init-value "" #:accessor node-text #:init-keyword #:text)
17 (name #:init-value "" #:accessor node-name #:init-keyword #:name)
18 (description #:init-value "" #:accessor node-desc #:init-keyword #:desc)
21 (define (menu-entry x)
27 (define (dump-node node port level)
33 (texi-section-command level) " "
38 (if (pair? (node-children node))
40 (map (lambda (x) (menu-entry x) )
41 (node-children node)))
44 (map (lambda (x) (dump-node x port (+ 1 level)))
48 (define (processing name)
49 (display (string-append "\nProcessing " name " ... ") (current-error-port)))
51 (define (self-evaluating? x)
52 (or (number? x) (string? x) (procedure? x) (boolean? x)))
58 (string-append "@code{" (texify (scm->string x)) "}")
63 ;; don't confuse users with #<procedure .. > syntax.
65 (define (scm->string val)
66 (if (and (procedure? val) (symbol? (procedure-name val)))
67 (symbol->string (procedure-name val))
69 (if (self-evaluating? val) "" "'")
70 (call-with-output-string (lambda (port) (display val port)))
74 (define (texi-section-command level)
76 ;; Hmm, texinfo doesn't have ``part''
79 (2 . "@unnumberedsec")
80 (3 . "@unnumberedsubsec")
81 (4 . "@unnumberedsubsubsec")
82 (5 . "@unnumberedsubsubsec")
85 (define (one-item->texi label-desc-pair)
86 "Document one (LABEL . DESC); return empty string if LABEL is empty string.
88 (if (eq? (car label-desc-pair) "")
90 (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair))
94 (define (description-list->texi items-alist)
95 "Document ITEMS-ALIST in a table. entries contain (item-label
100 (apply string-append (map one-item->texi items-alist))
103 (define (texi-menu items-alist)
104 "Generate what is between @menu and @end menu."
107 (maxwid (apply max (map (lambda (x) (string-length (car x)))
119 (string-append "\n* " (car x) ":: ")
126 ;; Menus don't appear in html, so we make a list ourselves
129 (description-list->texi (map (lambda (x) (cons (ref-ify (car x)) (cdr x)))
137 (define (texi-file-head name file-name top)
139 "\\input texinfo @c -*-texinfo-*-"
140 "\n@setfilename " file-name ".info"
142 "\n@dircategory GNU music project"
144 ;; prepend GNU for dir, must be unique
145 "\n* GNU " name ": (" file-name "). " name "."
150 (define (context-name name)
153 (define (engraver-name name)
156 (define (grob-name name)
158 (symbol->string name)
161 (define (interface-name name)
166 (string-append "@ref{" x "}"))
168 (define (human-listify l)
169 "Produce a textual enumeration from L, a list of strings"
173 ((null? (cdr l)) (car l))
174 ((null? (cddr l)) (string-append (car l) " and " (cadr l)))
175 (else (string-append (car l) ", " (human-listify (cdr l))))
178 (define (writing-wip x)
179 (display (string-append "\nWriting " x " ... ") (current-error-port)))
182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
185 (define (property->texi where sym . rest)
186 "Document SYM for WHERE (which can be translation, backend, music),
187 with init values from ALIST (1st optional argument)
189 (let* ((name (symbol->string sym))
190 (alist (if (pair? rest) (car rest) '()))
191 (type?-name (string->symbol
192 (string-append (symbol->string where) "-type?")))
193 (doc-name (string->symbol
194 (string-append (symbol->string where) "-doc")))
195 (type (object-property sym type?-name))
196 (typename (type-name type))
197 (desc (object-property sym doc-name))
198 (handle (assoc sym alist))
202 (error "No description for property ~S" sym))
205 (string-append "@code{" name "} "
210 (scm->texi (cdr handle))