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) (boolean? x))
29 ((x1 (regexp-substitute/global #f ">" x 'pre ">" 'post))
30 (x2 (regexp-substitute/global #f "<" x1 'pre "<" 'post))
34 (define (scm->string val)
36 (if (self-evaluating? val) "" "'")
38 (call-with-output-string (lambda (port) (display val port))))
41 (define (document-property prop desc)
42 (let ((handle (assoc (car prop) desc)))
44 "\n<li><code>" (symbol->string (car prop)) "</code> (" (type-name (cadr prop)) ") -- "
46 "<br>default value: <code>"
48 (scm->string (cdr handle))
55 (define (document-interface interface elt-description)
56 (let* ((name (car interface))
57 (desc (cadr interface))
58 (props (caddr interface))
59 (docs (map (lambda (x) (document-property x elt-description))
65 "<h2>Interface: " (symbol->string name) "</h2>\n"
68 (apply string-append docs)
74 ; generate HTML, return filename.
76 (define (document-element iname description)
77 (display (string-append "Processing " iname " ... ") (current-error-port))
78 (let* ((metah (assoc 'meta description))
80 (meta (if (pair? metah)
82 '((properties . ()) (name . "huh?"))
85 (name (cdr (assoc 'name meta)))
86 (ifaces (cdr (assoc 'interface-descriptions meta)))
87 (ifacedoc (map (lambda (x) (document-interface x description))
89 (outname (string-append name ".html"))
90 (out (open-output-file outname))
94 (string-append "<title>LilyPond Element " name " </title>"
96 (apply string-append ifacedoc))
102 (define (document-elements elts)
103 (let* ((files (map (lambda (x) (document-element (car x) (cdr x)))
105 (names (map car elts))
106 (outname (string-append "backend.html"))
107 (out (open-output-file outname))
108 (l (map (lambda (x) (string-append "<li>"
111 (writing-wip outname)
114 "<title>LilyPond backend documentation</title>"
115 "<h1>LilyPond backend documentation</h1>"
117 (apply string-append l)
124 ; (display (document-interface stem-interface '()))
125 ; (define b (cdr (assoc 'Dyna all-element-descriptions)))
128 ;(document-element b)
130 (document-elements all-element-descriptions)