]> git.donarmstrong.com Git - lilypond.git/blob - scm/document-music.scm
use split-list-by-separator
[lilypond.git] / scm / document-music.scm
1 ;;;; document-markup.scm -- part of generated backend documentation
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 (define (music-props-doc)
9   (make <texi-node>
10     #:name "Music properties"
11     #:desc "All music properties, including descriptions"
12     #:text
13     (let* ((ps (sort (map symbol->string all-music-properties) string<?))
14            (descs (map (lambda (prop)
15                          (property->texi 'music (string->symbol prop)))
16                        ps))
17            (texi (description-list->texi descs)))
18       texi)))
19
20 (define music-types->names (make-vector 61 '()))
21 (filter-map (lambda (entry)
22               (let* ((class (ly:camel-case->lisp-identifier (car entry)))
23                      (classes (ly:make-event-class class)))
24                 (if classes
25                     (map (lambda (cl)
26                            (hashq-set! music-types->names cl
27                                        (cons (car entry)
28                                              (hashq-ref music-types->names cl '()))))
29                          classes)
30                     #f)))
31             
32             music-descriptions)
33
34 (define (strip-description x)
35   (cons (symbol->string (car x))
36         ""))
37
38 (define (music-type-doc entry)
39   (make <texi-node>
40     #:name  (symbol->string (car entry))
41     #:text 
42     (string-append
43      "\nMusic event type @code{"
44      (symbol->string (car entry))
45      "} is in Music objects of type "
46      (human-listify
47       (sort
48        (map (lambda (x) (ref-ify (symbol->string x)))
49             (cdr entry)) string<?))
50
51      "\n\nAccepted by: "
52      (human-listify
53       (map ref-ify
54            (map symbol->string
55                 (map ly:translator-name
56                      (filter
57                       (lambda (x) (engraver-accepts-music-type? (car entry) x)) all-engravers-list)))))
58      "\n\n")))
59
60 (define (music-types-doc)
61   (make <texi-node>
62     #:name "Music classes"
63     #:children 
64     (map music-type-doc
65          (sort
66           (hash-table->alist music-types->names) alist<?))))
67
68 (define (music-doc-str obj)
69   (let* ((namesym  (car obj))
70          (props (cdr obj))
71          (class (ly:camel-case->lisp-identifier namesym))
72          (classes (ly:make-event-class class))
73          (event-texi (if classes
74                          (string-append
75                           "\n\nEvent classes:\n"
76                           (human-listify (map ref-ify (map symbol->string classes)))
77                           "\n\n"
78                           "\n\nAccepted by: "
79                           (human-listify
80                            (map ref-ify
81                                 (map symbol->string (map ly:translator-name
82                                                          (filter
83                                                           (lambda (x) (engraver-accepts-music-types? classes x)) all-engravers-list))))))
84                          "")))
85
86     (string-append
87      (object-property namesym 'music-description)
88      event-texi
89      "\n\nProperties: \n"
90      (description-list->texi
91       (map
92        (lambda (x) (property->texi 'music  x props))
93        (map car props))))))
94
95 (define (music-object-doc obj)
96   (make <texi-node>
97     #:name (symbol->string (car obj))
98     #:text (music-doc-str obj)))
99
100 (define (music-expressions-doc)
101   (make <texi-node>
102     #:name "Music expressions"
103     #:desc "Objects that represent music."
104     #:children
105     (map music-object-doc music-descriptions)))
106
107 (define (music-doc-node)
108   (make <texi-node>
109     #:name "Music definitions"
110     #:desc "Definition of the Input data structures"
111     #:children
112     (list
113      (music-expressions-doc)
114      (music-types-doc)
115      (music-props-doc))))