1 ;;; backend-documentation-lib.scm -- Functions for backend documentation
3 ;;; source file of the GNU LilyPond music typesetter
5 ;;; (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; This file generates documentation for the backend of lilypond.
11 ;; alist of property descriptions
14 (define (backend-property->texi sym)
16 (name (symbol->string sym))
17 (type (object-property sym 'backend-type?))
18 (typename (type-name type))
19 (desc (object-property sym 'backend-doc))
22 (cons (string-append "@code{" name "} "
28 (define (document-grob-property sym grob-description only-doc-if-set)
31 (handle (assoc sym grob-description))
32 (defval (if (eq? handle #f)
34 (scm->texi (cdr handle))
36 (propdoc (backend-property->texi sym))
39 (if (and only-doc-if-set (eq? handle #f) )
41 (cons (car propdoc) (string-append (cdr propdoc)
46 (define (document-interface where interface grob-description)
50 (let* ((level (if (eq? where 'grob) 3 2))
51 (name (car interface))
52 (desc (cadr interface))
53 (props (caddr interface))
55 (document-grob-property
56 x grob-description (eq? where 'grob))))
57 (docs (map docfunc props))
61 (texi-section level (string-append (interface-name (symbol->string name))) (eq? where 'grob)) ;gur.
64 (description-list->texi docs)
67 ;; First level Interface description
68 (define (document-separate-interface interface)
69 (let ((name (car interface)))
72 (node (interface-name name))
73 (document-interface 'self interface '()))))
75 ;; First level grob description
76 (define (document-grob iname description)
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 'grob x description))
91 (node (grob-name name))
92 (texi-section 2 (grob-name name) #f)
95 (let* ((grob (string->symbol name))
99 (let ((engraver (car x))
101 (if (member grob objs)
104 engraver-description-alist))))
106 name " grobs are created by: "
107 (human-listify (map reffy (map engraver-name engravers)))))
109 (apply string-append ifacedoc))))
112 (define (document-all-grobs name)
113 (let* ((doc (apply string-append
114 (map (lambda (x) (document-grob (car x) (cdr x)))
115 all-grob-descriptions)))
116 (names (map car all-grob-descriptions)))
119 (texi-node-menu name (map (lambda (x) (cons (grob-name x) ""))
123 ;; ugh, this works standalone, but not anymore with lily
124 (if (not (defined? 'standalone))
127 (debug-enable 'backtrace)
129 (load "standalone.scm")
131 (define (number-pair? x)
132 (and (pair? x) (number? (car x)) (number? (cdr x))))
134 (define (ly-grob? x) #f)
135 (define (ly-input-location? x) #f)
137 (define (moment? x) #f)
140 (use-modules (ice-9 string-fun))
142 (define interface-file-str (string-append (ly-gulp-file "interface-description.scm") "\n(define "))
144 ;;(define (list-interface-names)
145 (define (ugh-standalone-list-interface-names)
146 (let* ((text interface-file-str)
147 (t1 (regexp-substitute/global #f "\n" text 'pre 'post))
148 (t (regexp-substitute/global #f "[^\t ]*[ \t]([a-z-]+interface)"
150 (ugh (regexp-substitute/global #f " .*" t 'pre 'post))
151 (l (separate-fields-discarding-char #\ ugh list)))
152 (reverse (cdr (reverse l)))))
156 (display "(define (list-interface-names) '")
157 (write (ugh-standalone-list-interface-names))
162 ;; This list is generated manually, by doing:
164 ;; guile> (load "backend-documentation-lib.scm")
165 ;; For some reason, this can't be generated when lilypond is loaded;
166 ;; the regexp stuff behaves weird.
167 (define (list-interface-names) '("general-grob-interface" "general-grob-interface" "beam-interface" "clef-interface" "axis-group-interface" "note-column-interface" "stem-interface" "slur-interface" "side-position-interface" "accidentals-interface" "line-of-score-interface" "note-head-interface" "note-name-interface" "rhythmic-head-interface" "rest-interface" "tuplet-bracket-interface" "align-interface" "aligned-interface" "align-interface" "break-aligned-interface" "chord-name-interface" "time-signature-interface" "bar-line-interface" "hairpin-interface" "arpeggio-interface" "note-collision-interface" "custos-interface" "dot-interface" "font-interface" "text-interface" "dot-column-interface" "dynamic-interface" "finger-interface" "separation-spanner-interface" "text-script-interface" "grace-alignment-interface" "hara-kiri-group-interface" "line-spanner-interface" "lyric-hyphen-interface" "key-signature-interface" "lyric-extender-interface" "lyric-syllable-interface" "mark-interface" "multi-measure-rest-interface" "font-interface" "paper-column-interface" "spaceable-element-interface" "rest-collision-interface" "script-interface" "script-column-interface" "spacing-spanner-interface" "staff-symbol-interface" "stem-tremolo-interface" "separation-item-interface" "sustain-pedal-interface" "system-start-delimiter-interface" "text-spanner-interface" "tie-interface" "tie-column-interface" "volta-bracket-interface"))
169 (eval-string (ly-gulp-file "interface-description.scm"))
171 (define interface-description-alist
172 (map (lambda (x) (cons (string->symbol x) (eval-string x)))
173 (list-interface-names)))
175 (set! interface-description-alist (sort interface-description-alist alist<?))
177 (define (document-all-interfaces name)
179 (texi-node-menu name (map (lambda (x) (cons (interface-name x) ""))
180 (map cadr interface-description-alist)))
182 (map document-separate-interface
183 (map cdr interface-description-alist)))))
185 (define (document-all-backend-properties name)
188 (ps (sort (map symbol->string all-backend-properties) string<?))
189 (descs (map (lambda (prop)
190 (backend-property->texi (string->symbol prop)))
192 (texi (description-list->texi descs))
197 (texi-section 1 name #f)