]> git.donarmstrong.com Git - lilypond.git/blob - scm/document-identifiers.scm
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / scm / document-identifiers.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
4 ;;;;
5 ;;;; LilyPond is free software: you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version.
9 ;;;;
10 ;;;; LilyPond is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ;;;; GNU General Public License for more details.
14 ;;;;
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
17
18 (use-modules (ice-9 format))
19
20 (define (document-music-function music-func-pair)
21   (let*
22       ((name-sym (car music-func-pair))
23        (music-func (cdr music-func-pair))
24        (func (ly:music-function-extract music-func))
25        (arg-names
26         (map symbol->string
27              (cddr (cadr (procedure-source func)))))
28        (doc (procedure-documentation func))
29        (sign (object-property func 'music-function-signature))
30        (type-names (map type-name sign))
31
32        (signature-str
33         (string-join
34          (map (lambda (x) (format #f "@var{~a} (~a)"
35                                   (car x)
36                                   (cadr x)))
37               (zip arg-names type-names)))))
38     (format #f
39      "@item @code{~a}~a~a
40 @findex ~a
41 ~a
42 "
43      name-sym (if (equal? "" signature-str) "" " - ") signature-str
44      name-sym
45      (if doc doc "(undocumented; fixme)"))))
46
47
48 (define (document-object obj-pair)
49   (cond
50    ((ly:music-function? (cdr obj-pair))
51     (document-music-function obj-pair))
52    (else
53     #f)))
54
55 (define-public (identifiers-doc-string)
56   (format #f
57    "@table @asis
58 ~a
59 @end table
60 "
61    (string-join
62     (filter
63      identity
64      (map
65       document-object
66       (sort
67        (ly:module->alist (current-module))
68        identifier<?)))
69     "")))