1 ;;;; backend-documentation-lib.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
82 (hashq-ref iface->grob-table
88 (interface-doc-string (cdr interface) '())
90 "This grob interface "
91 (if (equal? interface-list "none")
92 "is not used in any graphical object"
94 "is used in the following graphical object(s): "
98 (define (grob-alist->texi alist)
99 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
102 (description-list->texi
103 (map (lambda (y) (property->texi 'backend y alist))
107 (define (grob-doc description)
108 "Given a property alist DESCRIPTION, make a documentation
111 (let* ((metah (assoc 'meta description))
113 (name (cdr (assoc 'name meta)))
114 ;; (bla (display name))
115 (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
116 (ifacedoc (map (lambda (iface)
118 (ref-ify (symbol->string (car iface)))
119 (ly:error (_ "pair expected in doc ~s") name)))
122 (lambda (x) (engraver-makes-grob? name x))
124 (namestr (symbol->string name))
125 (engraver-names (map symbol->string
126 (map ly:translator-name engravers)))
127 (engraver-list (human-listify
129 (map engraver-name engraver-names)))))
136 (if (equal? engraver-list "none")
137 "are not created by any engraver"
143 "\n\nStandard settings:\n\n"
144 (grob-alist->texi description)
145 "\n\nThis object supports the following interface(s):\n"
146 (human-listify ifacedoc)
149 (define (all-grobs-doc)
151 #:name "All layout objects"
152 #:desc "Description and defaults for all graphical objects (grobs)."
154 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
156 (define interface-description-alist
158 (lambda (key val prior)
159 (cons (cons key val) prior))
160 '() (ly:all-grob-interfaces)))
162 ;;;;;;;;;; check for dangling backend properties.
163 (define (mark-interface-properties entry)
164 (map (lambda (x) (set-object-property! x 'iface-marked #t))
165 (caddr (cdr entry))))
167 (map mark-interface-properties interface-description-alist)
169 (define (check-dangling-properties prop)
170 (if (not (object-property prop 'iface-marked))
171 (ly:error (string-append "define-grob-properties.scm: "
172 (_ "cannot find interface for property: ~S")) prop)))
174 (map check-dangling-properties all-backend-properties)
178 (define (lookup-interface name)
179 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
182 (ly:error (_ "unknown Grob interface: ~S") name))))
184 (define (all-interfaces-doc)
186 #:name "Graphical Object Interfaces"
187 #:desc "Building blocks of graphical objects."
189 (map interface-doc interface-description-alist)))
191 (define (backend-properties-doc-string lst)
192 (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
193 (descs (map (lambda (prop)
194 (property->texi 'backend (string->symbol prop) '())) ps))
195 (texi (description-list->texi descs #f)))
198 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
199 (define (backend-doc-node)
202 #:desc "Reference for the layout engine."
208 #:name "User backend properties"
209 #:desc "All tunable properties in a big list."
210 #:text (backend-properties-doc-string all-user-grob-properties))
212 #:name "Internal backend properties"
213 #:desc "All internal layout properties in a big list."
214 #:text (backend-properties-doc-string all-internal-grob-properties)))))