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* ((meta (assoc-get 'meta (cdr x)))
65 (ifaces (assoc-get 'interfaces meta)))
69 iface->grob-table iface
71 (hashq-ref iface->grob-table iface '()))))
73 all-grob-descriptions)
75 ;; First level Interface description
76 (define (interface-doc interface)
77 (let* ((name (symbol->string (car interface)))
78 (interface-list (human-listify
82 (hashq-ref iface->grob-table
89 (interface-doc-string (cdr interface) '())
91 "This grob interface "
92 (if (equal? interface-list "none")
93 "is not used in any graphical object"
95 "is used in the following graphical object(s): "
99 (define (grob-alist->texi alist)
100 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
103 (description-list->texi
104 (map (lambda (y) (property->texi 'backend y alist))
108 (define (grob-doc description)
109 "Given a property alist DESCRIPTION, make a documentation
112 (let* ((meta (assoc-get 'meta description))
113 (name (assoc-get 'name meta))
114 ;; (bla (display name))
115 (ifaces (map lookup-interface (assoc-get 'interfaces meta)))
116 (ifacedoc (map ref-ify
120 (symbol->string (car iface))
121 (ly:error (_ "pair expected in doc ~s") name)))
125 (lambda (x) (engraver-makes-grob? name x))
127 (namestr (symbol->string name))
128 (engraver-names (map symbol->string
129 (map ly:translator-name engravers)))
130 (engraver-list (human-listify
132 (map engraver-name engraver-names)))))
139 (if (equal? engraver-list "none")
140 "are not created by any engraver"
146 "\n\nStandard settings:\n\n"
147 (grob-alist->texi description)
148 "\n\nThis object supports the following interface(s):\n"
149 (human-listify ifacedoc)
152 (define (all-grobs-doc)
154 #:name "All layout objects"
155 #:desc "Description and defaults for all graphical objects (grobs)."
157 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
159 (define interface-description-alist
161 (lambda (key val prior)
162 (cons (cons key val) prior))
163 '() (ly:all-grob-interfaces)))
165 (set! interface-description-alist
166 (sort interface-description-alist ly:alist-ci<?))
168 ;;;;;;;;;; check for dangling backend properties.
169 (define (mark-interface-properties entry)
170 (map (lambda (x) (set-object-property! x 'iface-marked #t))
171 (caddr (cdr entry))))
173 (map mark-interface-properties interface-description-alist)
175 (define (check-dangling-properties prop)
176 (if (not (object-property prop 'iface-marked))
177 (ly:error (string-append "define-grob-properties.scm: "
178 (_ "cannot find interface for property: ~S")) prop)))
180 (map check-dangling-properties all-backend-properties)
184 (define (lookup-interface name)
185 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
188 (ly:error (_ "unknown Grob interface: ~S") name))))
190 (define (all-interfaces-doc)
192 #:name "Graphical Object Interfaces"
193 #:desc "Building blocks of graphical objects."
195 (map interface-doc interface-description-alist)))
197 (define (backend-properties-doc-string lst)
198 (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
199 (descs (map (lambda (prop)
200 (property->texi 'backend (string->symbol prop) '())) ps))
201 (texi (description-list->texi descs #f)))
204 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
205 (define (backend-doc-node)
208 #:desc "Reference for the layout engine."
214 #:name "User backend properties"
215 #:desc "All tunable properties in a big list."
216 #:text (backend-properties-doc-string all-user-grob-properties))
218 #:name "Internal backend properties"
219 #:desc "All internal layout properties in a big list."
220 #:text (backend-properties-doc-string all-internal-grob-properties)))))