1 ;;;; backend-documentation-lib.scm -- Functions for backend documentation
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.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) ) props))
16 (uprops (filter (lambda (x) (not (object-property x 'backend-internal)) ) props))
17 (user-propdocs (map docfunc uprops))
18 (internal-propdocs (map docfunc iprops)))
25 "\n\n@unnumberedsubsubsec User settable properties:\n"
26 (description-list->texi user-propdocs))
31 "\n\n@unnumberedsubsubsec Internal properties: \n"
32 (description-list->texi internal-propdocs))
35 (define iface->grob-table (make-vector 61 '()))
36 ;; extract ifaces, and put grob into the hash table.
39 (let* ((metah (assoc 'meta (cdr x)))
41 (ifaces (cdr (assoc 'interfaces meta))))
45 iface->grob-table iface
47 (hashq-ref iface->grob-table iface '()))))
49 all-grob-descriptions)
51 ;; First level Interface description
52 (define (interface-doc interface)
53 (let ((name (symbol->string (car interface))))
57 (interface-doc-string (cdr interface) '())
59 "This grob interface is used in the following graphical objects: "
65 (hashq-ref iface->grob-table (car interface) '() ))
68 (define (grob-alist->texi alist)
69 (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
72 (description-list->texi
73 (map (lambda (y) (property->texi 'backend y alist))
76 (define (grob-doc description)
77 "Given a property alist DESCRIPTION, make a documentation
80 (let* ((metah (assoc 'meta description))
82 (name (cdr (assoc 'name meta)))
83 ;; (bla (display name))
84 (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
85 (ifacedoc (map (lambda (iface)
87 (ref-ify (symbol->string (car iface)))
88 (error (format "Error making doc of ~s" name))))
91 (lambda (x) (engraver-makes-grob? name x)) all-engravers-list))
92 (namestr (symbol->string name))
93 (engraver-names (map symbol->string (map ly:translator-name engravers))))
99 namestr " objects are created by: "
100 (human-listify (map ref-ify
101 (map engraver-name engraver-names)))
102 "\n\nStandard settings: \n\n"
103 (grob-alist->texi description)
104 "\n\nThis object supports the following interfaces: \n"
105 (human-listify ifacedoc)))))
107 (define (all-grobs-doc)
109 #:name "All layout objects"
110 #:desc "Description and defaults for all Grobs"
112 (map (lambda (x) (grob-doc (cdr x))) all-grob-descriptions)))
114 (define interface-description-alist
116 (lambda (key val prior)
117 (cons (cons key val) prior))
118 '() (ly:all-grob-interfaces)))
120 (set! interface-description-alist (sort interface-description-alist alist<?))
122 ;;;;;;;;;; check for dangling backend properties.
123 (define (mark-interface-properties entry)
124 (map (lambda (x) (set-object-property! x 'iface-marked #t)) (caddr (cdr entry))))
126 (map mark-interface-properties interface-description-alist)
128 (define (check-dangling-properties prop)
129 (if (not (object-property prop 'iface-marked))
130 (error "\ndefine-grob-properties.scm: Can't find interface for property:" prop)))
132 (map check-dangling-properties all-backend-properties)
136 (define (lookup-interface name)
137 (let* ((entry (hashq-ref (ly:all-grob-interfaces) name '() )))
138 (if (equal? entry #f)
139 (error "Unknown interface" name))
142 (define (all-interfaces-doc)
144 #:name "Graphical Object Interfaces"
145 #:desc "Building blocks of graphical objects"
147 (map interface-doc interface-description-alist)))
149 (define (backend-properties-doc-string lst)
150 (let* ((ps (sort (map symbol->string lst) string<?))
151 (descs (map (lambda (prop)
152 (property->texi 'backend (string->symbol prop) '())) ps))
153 (texi (description-list->texi descs)))
156 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
157 (define (backend-doc-node)
160 #:desc "Reference for the layout engine"
166 #:name "User backend properties"
167 #:desc "All tunable properties in a big list"
168 #:text (backend-properties-doc-string all-user-grob-properties))
170 #:name "Internal backend properties"
171 #:desc "All internal layout properties in a big list"
172 #:text (backend-properties-doc-string all-internal-grob-properties)))))