1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2000--2015 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 props)
20 ;; force 'meta to the end of each prop-list
21 (let ((meta (assoc 'meta props)))
22 (append (sort (assoc-remove! props 'meta) ly:alist-ci<?)
25 ;; properly sort all properties and interfaces
26 ;; within the all-grob-descriptions alist
27 (set! all-grob-descriptions
29 (lambda (grob-description)
30 (let* ((grob-key (car grob-description))
31 (props (assoc-ref all-grob-descriptions grob-key))
32 (meta (assoc-ref props 'meta))
33 (interfaces (assoc-ref meta 'interfaces))
34 (sorted-ifaces (sort interfaces ly:symbol-ci<?))
35 (new-meta (assoc-set! meta 'interfaces sorted-ifaces))
36 (new-props (assoc-set! props 'meta new-meta))
37 (sorted-props (sort-grob-properties new-props)))
38 (cons grob-key sorted-props)))
39 all-grob-descriptions))
41 ;; sort all grobs in the all-grob-descriptions alist
42 (set! all-grob-descriptions (sort all-grob-descriptions ly:alist-ci<?))
44 (define (interface-doc-string interface grob-description)
45 (let* ((name (car interface))
46 (desc (cadr interface))
47 (props (caddr interface))
50 'backend pr grob-description)))
51 (iprops (filter (lambda (x) (object-property x 'backend-internal))
54 (lambda (x) (not (object-property x 'backend-internal)))
56 (user-propdocs (map docfunc uprops))
57 (internal-propdocs (map docfunc iprops)))
64 "\n\n@subsubheading User settable properties:\n"
65 (description-list->texi user-propdocs #t))
70 "\n\n@subsubheading Internal properties:\n"
71 (description-list->texi internal-propdocs #t))
74 (define iface->grob-table (make-hash-table 61))
75 ;; extract ifaces, and put grob into the hash table.
78 (let* ((meta (assoc-get 'meta (cdr x)))
79 (ifaces (assoc-get 'interfaces meta)))
81 (for-each (lambda (iface)
83 iface->grob-table iface
85 (hashq-ref iface->grob-table iface '()))))
87 all-grob-descriptions)
89 ;; First level Interface description
90 (define (interface-doc interface)
91 (let* ((name (symbol->string (car interface)))
92 (interface-list (human-listify
96 (hashq-ref iface->grob-table
102 #:text (string-append
103 (interface-doc-string (cdr interface) '())
105 "This grob interface "
106 (if (equal? interface-list "none")
107 "is not used in any graphical object"
109 "is used in the following graphical object(s): "
113 (define (grob-alist->texi alist)
114 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
117 (description-list->texi
118 (map (lambda (y) (property->texi 'backend y alist))
122 (define (grob-doc description)
123 "Given a property alist DESCRIPTION, make a documentation
126 (let* ((meta (assoc-get 'meta description))
127 (name (assoc-get 'name meta))
128 ;; (bla (display name))
129 (ifaces (map lookup-interface (assoc-get 'interfaces meta)))
130 (ifacedoc (map ref-ify
134 (symbol->string (car iface))
135 (ly:error (_ "pair expected in doc ~s") name)))
139 (lambda (x) (engraver-makes-grob? name x))
141 (namestr (symbol->string name))
142 (engraver-names (map symbol->string
143 (map ly:translator-name engravers)))
144 (engraver-list (human-listify
146 (map engraver-name engraver-names)))))
153 (if (equal? engraver-list "none")
154 "are not created by any engraver"
160 "\n\nStandard settings:\n"
161 (grob-alist->texi description)
162 "\n\nThis object supports the following interface(s):\n"
163 (human-listify ifacedoc)
166 (define (all-grobs-doc)
168 #:name "All layout objects"
169 #:desc "Description and defaults for all graphical objects (grobs)."
171 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
173 (define interface-description-alist
175 (lambda (key val prior)
176 (cons (cons key val) prior))
177 '() (ly:all-grob-interfaces)))
179 ;; sort user-settable and internal props within each grob-interface
180 (set! interface-description-alist
181 (map! (lambda (iface-desc)
182 (let* ((key-name-docstr (list-head iface-desc 3))
183 (props (list-tail iface-desc 3))
184 (sorted-props (list (sort (car props) ly:symbol-ci<?))))
185 (append key-name-docstr sorted-props)))
186 interface-description-alist))
188 ;; sort list of grob interfaces
189 (set! interface-description-alist
190 (sort interface-description-alist ly:alist-ci<?))
192 ;;;;;;;;;; check for dangling backend properties.
193 (define (mark-interface-properties entry)
194 (for-each (lambda (x) (set-object-property! x 'iface-marked #t))
195 (caddr (cdr entry))))
197 (for-each mark-interface-properties interface-description-alist)
199 (define (check-dangling-properties prop)
200 (if (not (object-property prop 'iface-marked))
201 (ly:error (string-append "define-grob-properties.scm: "
202 (_ "cannot find interface for property: ~S")) prop)))
204 (for-each check-dangling-properties all-backend-properties)
208 (define (lookup-interface name)
209 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
212 (ly:error (_ "unknown Grob interface: ~S") name))))
214 (define (all-interfaces-doc)
216 #:name "Graphical Object Interfaces"
217 #:desc "Building blocks of graphical objects."
219 (map interface-doc interface-description-alist)))
221 (define (backend-properties-doc-string lst)
222 (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
223 (descs (map (lambda (prop)
224 (property->texi 'backend (string->symbol prop) '())) ps))
225 (texi (description-list->texi descs #f)))
228 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
229 (define (backend-doc-node)
232 #:desc "Reference for the layout engine."
238 #:name "User backend properties"
239 #:desc "All tunable properties in a big list."
240 #:text (backend-properties-doc-string all-user-grob-properties))
242 #:name "Internal backend properties"
243 #:desc "All internal layout properties in a big list."
244 #:text (backend-properties-doc-string all-internal-grob-properties)))))