1 ;;;; document-translation.scm -- Functions for engraver documentation
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 (define (engraver-makes-grob? name-symbol grav)
10 (memq name-symbol (assoc 'grobs-created (ly:translator-description grav)))
13 (define (engraver-accepts-music-type? name-symbol grav)
14 (memq name-symbol (assoc 'events-accepted (ly:translator-description grav)))
18 (define (engraver-accepts-music-types? types grav)
22 (engraver-accepts-music-type? (car types) grav)
23 (engraver-accepts-music-types? (cdr types) grav)))
26 (define (engraver-doc-string engraver in-which-contexts)
28 (propsr (cdr (assoc 'properties-read (ly:translator-description engraver))))
29 (propsw (cdr (assoc 'properties-written (ly:translator-description engraver))))
30 (accepted (cdr (assoc 'events-accepted (ly:translator-description engraver))))
31 (name-sym (ly:translator-name engraver))
32 (name-str (symbol->string name-sym))
33 (desc (cdr (assoc 'description (ly:translator-description engraver))))
34 (grobs (engraver-grobs engraver))
42 "Music types accepted:\n\n"
55 (description-list->texi
56 (map (lambda (x) (property->texi 'translation x '())) propsr)))
63 (description-list->texi
64 (map (lambda (x) (property->texi 'translation x '())) propsw))))
68 "This engraver creates the following grobs: \n "
69 (human-listify (map ref-ify (uniq-list (sort grobs string<? ))))
77 ((paper-alist (My_lily_parser::paper_description))
78 (context-description-alist (map cdr paper-alist))
84 ((context (cdr (assoc 'context-name x)))
85 (group (assq-ref x 'group-type))
90 (cdr (assoc 'consists x))
95 (if (member name-sym consists)
98 context-description-alist))))
100 name-str " is part of contexts: "
101 (human-listify (map ref-ify (map symbol->string contexts)))))
108 ;; First level Engraver description
109 (define (engraver-doc grav)
111 #:name (symbol->string (ly:translator-name grav))
112 #:text (engraver-doc-string grav #t)
115 ;; Second level, part of Context description
117 (define name->engraver-table (make-vector 61 '()))
120 (hash-set! name->engraver-table (ly:translator-name x) x))
121 (ly:get-all-translators))
123 (define (find-engraver-by-name name)
125 (hash-ref name->engraver-table name #f))
127 (define (document-engraver-by-name name)
131 (eg (find-engraver-by-name name ))
134 (cons (symbol->string name )
135 (engraver-doc-string eg #f)
139 (define (document-property-operation op)
150 (if (null? (cddr body))
154 "grob-property @code{"
155 (symbol->string (cadr body))
156 "} in @ref{" (symbol->string sym)
158 (if (not (null? (cddr body)))
159 (string-append " to @code{" (scm->texi (cadr (cdr body))) "}" )
165 ((equal? (object-property sym 'is-grob?) #t) "")
166 ((equal? (car op) 'assign)
168 "@item Set translator property @code{"
169 (symbol->string (car body))
171 (scm->texi (cadr body))
179 (define (context-doc context-desc)
182 (name-sym (cdr (assoc 'context-name context-desc)))
183 (name (symbol->string name-sym))
184 (aliases (map symbol->string (cdr (assoc 'aliases context-desc))))
185 (desc-handle (assoc 'description context-desc))
186 (desc (if (and (pair? desc-handle) (string? (cdr desc-handle)))
187 (cdr desc-handle) "(not documented)"))
189 (accepts (cdr (assoc 'accepts context-desc)))
190 (group (assq-ref context-desc 'group-type))
193 (if group (list group)
195 (cdr (assoc 'consists context-desc))
197 (props (cdr (assoc 'property-ops context-desc)))
198 (grobs (context-grobs context-desc))
199 (grob-refs (map (lambda (x) (ref-ify x)) grobs)) )
206 "\n\n This context is also known as: \n\n"
207 (human-listify aliases)
208 "\n\nThis context creates the following grobs: \n\n"
209 (human-listify (uniq-list (sort grob-refs string<? )))
213 "\n\nThis context sets the following properties:\n"
215 (apply string-append (map document-property-operation props))
222 "\n\nThis context is a `bottom' context; it can not contain other contexts."
225 name " can contain \n"
226 (human-listify (map ref-ify (map symbol->string accepts)))))
228 "\n\nThis context is built from the following engravers: "
229 (description-list->texi
230 (map document-engraver-by-name consists))
233 (define (engraver-grobs grav)
234 (let* ((eg (if (symbol? grav)
235 (find-engraver-by-name grav)
239 (map symbol->string (cdr (assoc 'grobs-created (ly:translator-description eg)))))
242 (define (context-grobs context-desc)
244 (group (assq-ref context-desc 'group-type))
249 (cdr (assoc 'consists context-desc))
252 (map engraver-grobs consists))
259 (define (all-contexts-doc)
262 (sort (My_lily_parser::paper_description)
263 (lambda (x y) (symbol<? (car x) (car y)))))
264 (names (sort (map symbol->string (map car paper-alist)) string<?))
265 (contexts (map cdr paper-alist))
270 #:desc "Complete descriptions of all contexts"
272 (map context-doc contexts)
277 (define all-engravers-list (ly:get-all-translators))
278 (set! all-engravers-list
279 (sort all-engravers-list
280 (lambda (a b) (string<? (symbol->string (ly:translator-name a))
281 (symbol->string (ly:translator-name b))))))
283 (define (all-engravers-doc)
286 #:desc "All separate engravers"
288 (map engraver-doc all-engravers-list)))
290 (define (translation-properties-doc-string lst)
292 ((ps (sort (map symbol->string lst) string<?))
293 (sortedsyms (map string->symbol ps))
296 (lambda (x) (property->texi 'translation x '()))
298 (texi (description-list->texi propdescs)))
303 (define (translation-doc-node)
306 #:desc "From music to layout"
312 #:name "Tunable context properties"
313 #:desc "All tunable context properties"
314 #:text (translation-properties-doc-string
315 all-user-translation-properties))
318 #:name "Internal context properties"
319 #:desc "All internal context properties"
320 #:text (translation-properties-doc-string
321 all-internal-translation-properties))