]> git.donarmstrong.com Git - lilypond.git/blob - scm/document-backend.scm
Fix internalsrefs
[lilypond.git] / scm / document-backend.scm
1 ;;;; backend-documentation-lib.scm -- Functions for backend documentation
2 ;;;;
3 ;;;; source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c)  2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
7
8 (define (interface-doc-string interface grob-description)
9   (let* ((name (car interface))
10          (desc (cadr interface))
11          (props (sort (caddr interface) symbol<?))
12          (docfunc (lambda (pr)
13                     (property->texi
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)))
19
20     (string-append
21      desc
22
23      (if (pair? uprops)
24          (string-append
25           "\n\n@unnumberedsubsubsec User settable properties:\n"
26           (description-list->texi user-propdocs))
27          "")
28
29      (if (pair? iprops)
30          (string-append
31           "\n\n@unnumberedsubsubsec Internal properties: \n"
32           (description-list->texi internal-propdocs))
33          ""))))
34
35 (define iface->grob-table (make-vector 61 '()))
36 ;; extract ifaces, and put grob into the hash table.
37 (map
38  (lambda (x)
39    (let* ((metah (assoc 'meta (cdr x)))
40           (meta (cdr metah))
41           (ifaces (cdr (assoc 'interfaces meta))))
42
43      (map (lambda (iface)
44             (hashq-set!
45              iface->grob-table iface
46              (cons (car x)
47                    (hashq-ref iface->grob-table iface '()))))
48           ifaces)))
49  all-grob-descriptions)
50
51 ;; First level Interface description
52 (define (interface-doc interface)
53   (let ((name (symbol->string (car interface))))
54     (make <texi-node>
55       #:name name
56       #:text (string-append
57               (interface-doc-string (cdr interface) '())
58               "\n\n"
59               "This grob interface is used in the following graphical objects: "
60
61               (human-listify
62                (map ref-ify
63                     (sort 
64                      (map symbol->string
65                           (hashq-ref iface->grob-table (car interface) '() ))
66                      string<?)))))))
67
68 (define (grob-alist->texi alist)
69   (let* ((uprops (filter (lambda (x) (not (object-property x 'backend-internal)))
70                          (map car alist))))
71
72     (description-list->texi
73      (map (lambda (y) (property->texi 'backend y alist))
74           uprops))))
75
76 (define (grob-doc description)
77   "Given a property alist DESCRIPTION, make a documentation
78 node."
79
80   (let* ((metah (assoc 'meta description))
81          (meta (cdr metah))
82          (name (cdr (assoc 'name meta)))
83          ;;       (bla (display name))
84          (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
85          (ifacedoc (map (lambda (iface)
86                           (if (pair? iface)
87                               (ref-ify (symbol->string (car iface)))
88                               (error (format "Error making doc of ~s" name))))
89                         (reverse ifaces)))
90          (engravers (filter
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))))
94
95     (make <texi-node>
96       #:name namestr
97       #:text
98       (string-append
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)))))
106
107 (define (all-grobs-doc)
108   (make <texi-node>
109     #:name "All layout objects"
110     #:desc "Description and defaults for all Grobs"
111     #:children
112     (map (lambda (x) (grob-doc (cdr x)))  all-grob-descriptions)))
113
114 (define interface-description-alist
115   (hash-fold
116    (lambda (key val prior)
117      (cons (cons key val)  prior))
118    '() (ly:all-grob-interfaces)))
119
120 (set! interface-description-alist (sort interface-description-alist alist<?))
121
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))))
125
126 (map mark-interface-properties interface-description-alist)
127
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)))
131
132 (map check-dangling-properties all-backend-properties)
133
134 ;;;;;;;;;;;;;;;;
135
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))
140     entry))
141
142 (define (all-interfaces-doc)
143   (make <texi-node>
144     #:name "Graphical Object Interfaces"
145     #:desc "Building blocks of graphical objects"
146     #:children
147     (map interface-doc interface-description-alist)))
148
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)))
154     texi))
155
156 ;;(dump-node (grob-doc (cdadr all-grob-descriptions)) (current-output-port) 0 )
157 (define (backend-doc-node)
158   (make <texi-node>
159     #:name "Backend"
160     #:desc "Reference for the layout engine"
161     #:children
162     (list
163      (all-grobs-doc)
164      (all-interfaces-doc)
165      (make <texi-node>
166        #:name "User backend properties"
167        #:desc "All tunable properties in a big list"
168        #:text (backend-properties-doc-string all-user-grob-properties))
169      (make <texi-node>
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)))))