1 ;;;; backend-documentation-lib.scm -- Functions for backend documentation
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2006 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@unnumberedsubsubsec User settable properties:\n"
29 (description-list->texi user-propdocs))
34 "\n\n@unnumberedsubsubsec Internal properties: \n"
35 (description-list->texi internal-propdocs))
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))))
60 (interface-doc-string (cdr interface) '())
62 "This grob interface is used in the following graphical objects: "
68 (hashq-ref iface->grob-table (car interface) '()))
71 (define (grob-alist->texi alist)
72 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
75 (description-list->texi
76 (map (lambda (y) (property->texi 'backend y alist))
79 (define (grob-doc description)
80 "Given a property alist DESCRIPTION, make a documentation
83 (let* ((metah (assoc 'meta description))
85 (name (cdr (assoc 'name meta)))
86 ;; (bla (display name))
87 (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
88 (ifacedoc (map (lambda (iface)
90 (ref-ify (symbol->string (car iface)))
91 (ly:error (_ "pair expected in doc ~s") name)))
94 (lambda (x) (engraver-makes-grob? name x)) all-engravers-list))
95 (namestr (symbol->string name))
96 (engraver-names (map symbol->string (map ly:translator-name engravers))))
102 namestr " objects are created by: "
103 (human-listify (map ref-ify
104 (map engraver-name engraver-names)))
105 "\n\nStandard settings: \n\n"
106 (grob-alist->texi description)
107 "\n\nThis object supports the following interfaces: \n"
108 (human-listify ifacedoc)))))
110 (define (all-grobs-doc)
112 #:name "All layout objects"
113 #:desc "Description and defaults for all Grobs"
115 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
117 (define interface-description-alist
119 (lambda (key val prior)
120 (cons (cons key val) prior))
121 '() (ly:all-grob-interfaces)))
123 (set! interface-description-alist (sort interface-description-alist alist<?))
125 ;;;;;;;;;; check for dangling backend properties.
126 (define (mark-interface-properties entry)
127 (map (lambda (x) (set-object-property! x 'iface-marked #t))
128 (caddr (cdr entry))))
130 (map mark-interface-properties interface-description-alist)
132 (define (check-dangling-properties prop)
133 (if (not (object-property prop 'iface-marked))
134 (ly:error (string-append "define-grob-properties.scm: "
135 (_ "cannot find interface for property: ~S")) prop)))
137 (map check-dangling-properties all-backend-properties)
141 (define (lookup-interface name)
142 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name #f)))
145 (ly:error (_ "unknown Grob interface: ~S") name))))
147 (define (all-interfaces-doc)
149 #:name "Graphical Object Interfaces"
150 #:desc "Building blocks of graphical objects"
152 (map interface-doc interface-description-alist)))
154 (define (backend-properties-doc-string lst)
155 (let* ((ps (sort (map symbol->string lst) string<?))
156 (descs (map (lambda (prop)
157 (property->texi 'backend (string->symbol prop) '())) ps))
158 (texi (description-list->texi descs)))
161 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
162 (define (backend-doc-node)
165 #:desc "Reference for the layout engine"
171 #:name "User backend properties"
172 #:desc "All tunable properties in a big list"
173 #:text (backend-properties-doc-string all-user-grob-properties))
175 #:name "Internal backend properties"
176 #:desc "All internal layout properties in a big list"
177 #:text (backend-properties-doc-string all-internal-grob-properties)))))