1 ;;;; backend-documentation-lib.scm -- Functions for backend documentation
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
8 (define (interface-doc-string interface grob-description)
9 (let* ((name (car interface))
10 (desc (cadr interface))
11 (props (sort (caddr interface) symbol<?))
14 'backend pr grob-description)))
15 (iprops (filter (lambda (x) (object-property x 'backend-internal))
18 (lambda (x) (not (object-property x 'backend-internal)))
20 (user-propdocs (map docfunc uprops))
21 (internal-propdocs (map docfunc iprops)))
28 "\n\n@subsubheading User settable properties:\n"
29 (description-list->texi user-propdocs #t))
34 "\n\n@subsubheading Internal properties:\n"
35 (description-list->texi internal-propdocs #t))
38 (define iface->grob-table (make-vector 61 '()))
39 ;; extract ifaces, and put grob into the hash table.
42 (let* ((metah (assoc 'meta (cdr x)))
44 (ifaces (cdr (assoc 'interfaces meta))))
48 iface->grob-table iface
50 (hashq-ref iface->grob-table iface '()))))
52 all-grob-descriptions)
54 ;; First level Interface description
55 (define (interface-doc interface)
56 (let* ((name (symbol->string (car interface)))
57 (interface-list (human-listify
61 (hashq-ref iface->grob-table
68 (interface-doc-string (cdr interface) '())
70 "This grob interface "
71 (if (equal? interface-list "none")
72 "is not used in any graphical object"
74 "is used in the following graphical object(s): "
78 (define (grob-alist->texi alist)
79 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
82 (description-list->texi
83 (map (lambda (y) (property->texi 'backend y alist))
87 (define (grob-doc description)
88 "Given a property alist DESCRIPTION, make a documentation
91 (let* ((metah (assoc 'meta description))
93 (name (cdr (assoc 'name meta)))
94 ;; (bla (display name))
95 (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
96 (ifacedoc (map (lambda (iface)
98 (ref-ify (symbol->string (car iface)))
99 (ly:error (_ "pair expected in doc ~s") name)))
102 (lambda (x) (engraver-makes-grob? name x))
104 (namestr (symbol->string name))
105 (engraver-names (map symbol->string
106 (map ly:translator-name engravers)))
107 (engraver-list (human-listify
109 (map engraver-name engraver-names)))))
116 (if (equal? engraver-list "none")
117 "are not created by any engraver"
123 "\n\nStandard settings:\n\n"
124 (grob-alist->texi description)
125 "\n\nThis object supports the following interface(s):\n"
126 (human-listify ifacedoc)
129 (define (all-grobs-doc)
131 #:name "All layout objects"
132 #:desc "Description and defaults for all graphical objects (grobs)."
134 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
136 (define interface-description-alist
138 (lambda (key val prior)
139 (cons (cons key val) prior))
140 '() (ly:all-grob-interfaces)))
142 (set! interface-description-alist (sort interface-description-alist alist<?))
144 ;;;;;;;;;; check for dangling backend properties.
145 (define (mark-interface-properties entry)
146 (map (lambda (x) (set-object-property! x 'iface-marked #t))
147 (caddr (cdr entry))))
149 (map mark-interface-properties interface-description-alist)
151 (define (check-dangling-properties prop)
152 (if (not (object-property prop 'iface-marked))
153 (ly:error (string-append "define-grob-properties.scm: "
154 (_ "cannot find interface for property: ~S")) prop)))
156 (map check-dangling-properties all-backend-properties)
160 (define (lookup-interface name)
161 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
164 (ly:error (_ "unknown Grob interface: ~S") name))))
166 (define (all-interfaces-doc)
168 #:name "Graphical Object Interfaces"
169 #:desc "Building blocks of graphical objects."
171 (map interface-doc interface-description-alist)))
173 (define (backend-properties-doc-string lst)
174 (let* ((ps (sort (map symbol->string lst) string<?))
175 (descs (map (lambda (prop)
176 (property->texi 'backend (string->symbol prop) '())) ps))
177 (texi (description-list->texi descs #f)))
180 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
181 (define (backend-doc-node)
184 #:desc "Reference for the layout engine."
190 #:name "User backend properties"
191 #:desc "All tunable properties in a big list."
192 #:text (backend-properties-doc-string all-user-grob-properties))
194 #:name "Internal backend properties"
195 #:desc "All internal layout properties in a big list."
196 #:text (backend-properties-doc-string all-internal-grob-properties)))))