1 ;;;; document-backend.scm -- Functions for backend documentation
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
8 (define (sort-grob-properties x)
9 ;; force 'meta to the end of each prop-list
10 (let ((meta (assoc 'meta x)))
11 (append (sort (assoc-remove! x 'meta) ly:alist-ci<?)
14 ;; properly sort all grobs, properties, and interfaces
15 ;; within the all-grob-descriptions alist
18 (let* ((props (assoc-ref all-grob-descriptions (car x)))
19 (meta (assoc-ref props 'meta))
20 (interfaces (assoc-ref meta 'interfaces)))
21 (set! all-grob-descriptions
22 (sort (assoc-set! all-grob-descriptions (car x)
24 (assoc-set! props 'meta
25 (assoc-set! meta 'interfaces
26 (sort interfaces ly:symbol-ci<?)))))
28 all-grob-descriptions)
30 (define (interface-doc-string interface grob-description)
31 (let* ((name (car interface))
32 (desc (cadr interface))
33 (props (caddr interface))
36 'backend pr grob-description)))
37 (iprops (filter (lambda (x) (object-property x 'backend-internal))
40 (lambda (x) (not (object-property x 'backend-internal)))
42 (user-propdocs (map docfunc uprops))
43 (internal-propdocs (map docfunc iprops)))
50 "\n\n@subsubheading User settable properties:\n"
51 (description-list->texi user-propdocs #t))
56 "\n\n@subsubheading Internal properties:\n"
57 (description-list->texi internal-propdocs #t))
60 (define iface->grob-table (make-vector 61 '()))
61 ;; extract ifaces, and put grob into the hash table.
64 (let* ((metah (assoc 'meta (cdr x)))
66 (ifaces (cdr (assoc 'interfaces meta))))
70 iface->grob-table iface
72 (hashq-ref iface->grob-table iface '()))))
74 all-grob-descriptions)
76 ;; First level Interface description
77 (define (interface-doc interface)
78 (let* ((name (symbol->string (car interface)))
79 (interface-list (human-listify
83 (hashq-ref iface->grob-table
90 (interface-doc-string (cdr interface) '())
92 "This grob interface "
93 (if (equal? interface-list "none")
94 "is not used in any graphical object"
96 "is used in the following graphical object(s): "
100 (define (grob-alist->texi alist)
101 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
104 (description-list->texi
105 (map (lambda (y) (property->texi 'backend y alist))
109 (define (grob-doc description)
110 "Given a property alist DESCRIPTION, make a documentation
113 (let* ((metah (assoc 'meta description))
115 (name (cdr (assoc 'name meta)))
116 ;; (bla (display name))
117 (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
118 (ifacedoc (map ref-ify
122 (symbol->string (car iface))
123 (ly:error (_ "pair expected in doc ~s") name)))
127 (lambda (x) (engraver-makes-grob? name x))
129 (namestr (symbol->string name))
130 (engraver-names (map symbol->string
131 (map ly:translator-name engravers)))
132 (engraver-list (human-listify
134 (map engraver-name engraver-names)))))
141 (if (equal? engraver-list "none")
142 "are not created by any engraver"
148 "\n\nStandard settings:\n\n"
149 (grob-alist->texi description)
150 "\n\nThis object supports the following interface(s):\n"
151 (human-listify ifacedoc)
154 (define (all-grobs-doc)
156 #:name "All layout objects"
157 #:desc "Description and defaults for all graphical objects (grobs)."
159 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
161 (define interface-description-alist
163 (lambda (key val prior)
164 (cons (cons key val) prior))
165 '() (ly:all-grob-interfaces)))
167 (set! interface-description-alist
168 (sort interface-description-alist ly:alist-ci<?))
170 ;;;;;;;;;; check for dangling backend properties.
171 (define (mark-interface-properties entry)
172 (map (lambda (x) (set-object-property! x 'iface-marked #t))
173 (caddr (cdr entry))))
175 (map mark-interface-properties interface-description-alist)
177 (define (check-dangling-properties prop)
178 (if (not (object-property prop 'iface-marked))
179 (ly:error (string-append "define-grob-properties.scm: "
180 (_ "cannot find interface for property: ~S")) prop)))
182 (map check-dangling-properties all-backend-properties)
186 (define (lookup-interface name)
187 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
190 (ly:error (_ "unknown Grob interface: ~S") name))))
192 (define (all-interfaces-doc)
194 #:name "Graphical Object Interfaces"
195 #:desc "Building blocks of graphical objects."
197 (map interface-doc interface-description-alist)))
199 (define (backend-properties-doc-string lst)
200 (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
201 (descs (map (lambda (prop)
202 (property->texi 'backend (string->symbol prop) '())) ps))
203 (texi (description-list->texi descs #f)))
206 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
207 (define (backend-doc-node)
210 #:desc "Reference for the layout engine."
216 #:name "User backend properties"
217 #:desc "All tunable properties in a big list."
218 #:text (backend-properties-doc-string all-user-grob-properties))
220 #:name "Internal backend properties"
221 #:desc "All internal layout properties in a big list."
222 #:text (backend-properties-doc-string all-internal-grob-properties)))))