1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 (define (sort-grob-properties x)
20 ;; force 'meta to the end of each prop-list
21 (let ((meta (assoc 'meta x)))
22 (append (sort (assoc-remove! x 'meta) ly:alist-ci<?)
25 ;; properly sort all grobs, properties, and interfaces
26 ;; within the all-grob-descriptions alist
29 (let* ((props (assoc-ref all-grob-descriptions (car x)))
30 (meta (assoc-ref props 'meta))
31 (interfaces (assoc-ref meta 'interfaces)))
32 (set! all-grob-descriptions
33 (sort (assoc-set! all-grob-descriptions (car x)
35 (assoc-set! props 'meta
36 (assoc-set! meta 'interfaces
37 (sort interfaces ly:symbol-ci<?)))))
39 all-grob-descriptions)
41 (define (interface-doc-string interface grob-description)
42 (let* ((name (car interface))
43 (desc (cadr interface))
44 (props (caddr interface))
47 'backend pr grob-description)))
48 (iprops (filter (lambda (x) (object-property x 'backend-internal))
51 (lambda (x) (not (object-property x 'backend-internal)))
53 (user-propdocs (map docfunc uprops))
54 (internal-propdocs (map docfunc iprops)))
61 "\n\n@subsubheading User settable properties:\n"
62 (description-list->texi user-propdocs #t))
67 "\n\n@subsubheading Internal properties:\n"
68 (description-list->texi internal-propdocs #t))
71 (define iface->grob-table (make-hash-table 61))
72 ;; extract ifaces, and put grob into the hash table.
75 (let* ((meta (assoc-get 'meta (cdr x)))
76 (ifaces (assoc-get 'interfaces meta)))
80 iface->grob-table iface
82 (hashq-ref iface->grob-table iface '()))))
84 all-grob-descriptions)
86 ;; First level Interface description
87 (define (interface-doc interface)
88 (let* ((name (symbol->string (car interface)))
89 (interface-list (human-listify
93 (hashq-ref iface->grob-table
100 (interface-doc-string (cdr interface) '())
102 "This grob interface "
103 (if (equal? interface-list "none")
104 "is not used in any graphical object"
106 "is used in the following graphical object(s): "
110 (define (grob-alist->texi alist)
111 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
114 (description-list->texi
115 (map (lambda (y) (property->texi 'backend y alist))
119 (define (grob-doc description)
120 "Given a property alist DESCRIPTION, make a documentation
123 (let* ((meta (assoc-get 'meta description))
124 (name (assoc-get 'name meta))
125 ;; (bla (display name))
126 (ifaces (map lookup-interface (assoc-get 'interfaces meta)))
127 (ifacedoc (map ref-ify
131 (symbol->string (car iface))
132 (ly:error (_ "pair expected in doc ~s") name)))
136 (lambda (x) (engraver-makes-grob? name x))
138 (namestr (symbol->string name))
139 (engraver-names (map symbol->string
140 (map ly:translator-name engravers)))
141 (engraver-list (human-listify
143 (map engraver-name engraver-names)))))
150 (if (equal? engraver-list "none")
151 "are not created by any engraver"
157 "\n\nStandard settings:\n\n"
158 (grob-alist->texi description)
159 "\n\nThis object supports the following interface(s):\n"
160 (human-listify ifacedoc)
163 (define (all-grobs-doc)
165 #:name "All layout objects"
166 #:desc "Description and defaults for all graphical objects (grobs)."
168 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
170 (define interface-description-alist
172 (lambda (key val prior)
173 (cons (cons key val) prior))
174 '() (ly:all-grob-interfaces)))
176 (set! interface-description-alist
177 (sort interface-description-alist ly:alist-ci<?))
179 ;;;;;;;;;; check for dangling backend properties.
180 (define (mark-interface-properties entry)
181 (map (lambda (x) (set-object-property! x 'iface-marked #t))
182 (caddr (cdr entry))))
184 (map mark-interface-properties interface-description-alist)
186 (define (check-dangling-properties prop)
187 (if (not (object-property prop 'iface-marked))
188 (ly:error (string-append "define-grob-properties.scm: "
189 (_ "cannot find interface for property: ~S")) prop)))
191 (map check-dangling-properties all-backend-properties)
195 (define (lookup-interface name)
196 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
199 (ly:error (_ "unknown Grob interface: ~S") name))))
201 (define (all-interfaces-doc)
203 #:name "Graphical Object Interfaces"
204 #:desc "Building blocks of graphical objects."
206 (map interface-doc interface-description-alist)))
208 (define (backend-properties-doc-string lst)
209 (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
210 (descs (map (lambda (prop)
211 (property->texi 'backend (string->symbol prop) '())) ps))
212 (texi (description-list->texi descs #f)))
215 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
216 (define (backend-doc-node)
219 #:desc "Reference for the layout engine."
225 #:name "User backend properties"
226 #:desc "All tunable properties in a big list."
227 #:text (backend-properties-doc-string all-user-grob-properties))
229 #:name "Internal backend properties"
230 #:desc "All internal layout properties in a big list."
231 #:text (backend-properties-doc-string all-internal-grob-properties)))))