1 ;;; backend-documentation-lib.scm -- Functions for backend documentation
3 ;;; source file of the GNU LilyPond music typesetter
5 ;;; (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; This file generates documentation for the backend of lilypond.
11 ;; alist of property descriptions
14 (define (backend-property->texi sym)
15 (let* ((name (symbol->string sym))
16 (type (object-property sym 'backend-type?))
17 (typename (type-name type))
18 (desc (object-property sym 'backend-doc)))
20 (cons (string-append "@code{" name "} "
24 ; index gets too messy
25 ; "@vindex " name "\n"
31 (define (document-grob-property sym grob-description )
32 (let* ((handle (assoc sym grob-description))
33 (defval (if (eq? handle #f)
35 (scm->texi (cdr handle))))
36 (propdoc (backend-property->texi sym)))
38 (cons (car propdoc) (string-append (cdr propdoc)
42 (define (document-interface where interface grob-description)
43 (let* ((level (if (eq? where 'grob) 3 2))
44 (name (car interface))
45 (desc (cadr interface))
46 (props (caddr interface))
48 (document-grob-property
49 x grob-description )))
50 (docs (map docfunc props)))
54 (string-append (interface-name (symbol->string name)))
55 (eq? where 'grob)) ;gur.
57 (description-list->texi docs))))
59 ;; First level Interface description
60 (define (document-separate-interface interface)
61 (let ((name (symbol->string (car interface))))
64 (node (interface-name name))
65 (document-interface 'self interface '()))))
67 ;; First level grob description
68 (define (document-grob iname description)
70 (let* ((metah (assoc 'meta description))
72 (meta (if (pair? metah)
74 '((properties . ()) (name . "huh?"))
77 (name (cdr (assoc 'name meta)))
78 (ifaces (cdr (assoc 'interface-descriptions meta)))
79 (ifacedoc (map (lambda (x)
80 (document-interface 'grob x description))
84 (node (grob-name name))
85 (texi-section 2 (grob-name name) #f)
87 (let* ((grob (string->symbol name))
88 (engravers (filter-list
89 (lambda (x) (engraver-makes-grob? name x)) all-engravers-list))
90 (engraver-names (map Translator::name engravers))
94 name " grobs are created by: "
95 (human-listify (map ref-ify
96 (map engraver-name engraver-names)))))
98 (apply string-append ifacedoc))))
100 (define (engraver-makes-grob? name grav)
101 (memq name (assoc 'grobs-created (Translator::description grav)))
104 (define (document-all-grobs name)
105 (let* ((doc (apply string-append
107 (document-grob (symbol->string (car x)) (cdr x)))
108 all-grob-descriptions)))
109 (names (map symbol->string (map car all-grob-descriptions))))
112 (texi-node-menu name (map (lambda (x) (cons (grob-name x) ""))
116 ;; ugh, this works standalone, but not anymore with lily
117 (if (not (defined? 'standalone))
120 (debug-enable 'backtrace)
122 (load "standalone.scm")
124 (define (number-pair? x)
125 (and (pair? x) (number? (car x)) (number? (cdr x))))
127 (define (ly-grob? x) #f)
128 (define (ly-input-location? x) #f)
130 (define (moment? x) #f)
133 (use-modules (ice-9 string-fun))
137 (display "(define (list-interface-names) '")
138 (write (ugh-standalone-list-interface-names))
143 (define interface-description-alist
144 (map (lambda (x) (cons (string->symbol x) (eval-string x)))
147 (set! interface-description-alist (sort interface-description-alist alist<?))
149 (define (document-all-interfaces name)
151 (texi-node-menu name (map (lambda (x)
152 (cons (interface-name (symbol->string x)) ""))
153 (map cadr interface-description-alist)))
155 (map document-separate-interface
156 (map cdr interface-description-alist)))))
158 (define (document-all-backend-properties name)
161 (ps (sort (map symbol->string all-backend-properties) string<?))
162 (descs (map (lambda (prop)
163 (backend-property->texi (string->symbol prop)))
165 (texi (description-list->texi descs))
170 (texi-section 1 name #f)