4 ; This file generates documentation for the backend of lilypond.
9 (define (uniqued-alist alist acc)
11 (if (assoc (caar alist) acc)
12 (uniqued-alist (cdr alist) acc)
13 (uniqued-alist (cdr alist) (cons (car alist) acc)
18 (define (wordwrap string)
22 (define (self-evaluating? x)
23 (or (number? x) (string? x) (procedure? x))
26 (define (type-name predicate)
28 ((eq? predicate dir?) "direction")
29 ((eq? predicate ly-element?) "graphic element")
30 ((eq? predicate pair?) "pair")
31 ((eq? predicate integer?) "integer")
32 ((eq? predicate list?) "list")
33 ((eq? predicate symbol?) "symbol")
34 ((eq? predicate string?) "string")
35 ((eq? predicate boolean?) "string")
36 ((eq? predicate number?) "number")
37 ((eq? predicate char?) "char")
38 ((eq? predicate input-port?) "input port")
39 ((eq? predicate output-port?) "output port")
40 ((eq? predicate vector?) "vector")
41 ((eq? predicate procedure?) "procedure")
47 ((x1 (regexp-substitute/global #f ">" x 'pre ">" 'post))
48 (x2 (regexp-substitute/global #f "<" x1 'pre "<" 'post))
52 (define (scm->string val)
54 (if (self-evaluating? val) "" "'")
56 (call-with-output-string (lambda (port) (display val port))))
59 (define (document-property prop desc)
60 (let ((handle (assoc (car prop) desc)))
62 "\n<li><code>" (symbol->string (car prop)) "</code> (" (type-name (cadr prop)) ") -- "
64 "<br>default value: <code>"
66 (scm->string (cdr handle))
73 (define (document-interface interface elt-description)
74 (let* ((name (car interface))
75 (desc (cadr interface))
76 (props (caddr interface))
77 (docs (map (lambda (x) (document-property x elt-description))
83 "<h2>Interface: " (symbol->string name) "</h2>\n"
86 (apply string-append docs)
92 ; generate HTML, return filename.
94 (define (document-element description)
95 (let* ((metah (assoc 'meta description))
96 (meta (if (pair? metah)
98 '((properties . ()) (name . "huh?"))
101 (name (cdr (assoc 'name meta)))
102 (ifaces (cdr (assoc 'interface-descriptions meta)))
103 (ifacedoc (map (lambda (x) (document-interface x description))
105 (outname (string-append name ".html"))
106 (out (open-output-file outname))
108 (display (string-append "Writing " outname " ... \n") (current-error-port))
110 (string-append "<title>LilyPond Element " name " </title>"
112 (apply string-append ifacedoc))
118 (define (document-elements elts)
119 (let* ((files (map (lambda (x) (document-element (cdr x)))
121 (outname (string-append "backend.html"))
122 (out (open-output-file outname))
123 (l (map (lambda (x) (string-append
124 "<li><a href=" x ">" x "</a>\n"))
130 "<title>LilyPond backend documentation</title>"
131 "<h1>LilyPond backend documentation</h1>"
133 (apply string-append l)
140 ; (display (document-interface stem-interface '()))
141 ; (define b (cdr (assoc 'Beam all-element-descriptions)))
144 ;(document-element b)
146 (document-elements all-element-descriptions)