]> git.donarmstrong.com Git - lilypond.git/blob - scm/document-identifiers.scm
Run grand-replace (issue 3765)
[lilypond.git] / scm / document-identifiers.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2006--2014 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 (ly:music-function-signature music-func))
30        (type-names (map (lambda (pred)
31                           (if (pair? pred)
32                               (format #f "[~a]" (type-name (car pred)))
33                               (format #f "(~a)" (type-name pred))))
34                         sign))
35        (signature-str
36         (string-join
37          (map (lambda (arg type) (format #f "@var{~a} ~a" arg type))
38               arg-names (cdr type-names)))))
39     (format #f
40             "@item @code{~a} ~a ~a~a
41 @funindex ~a
42 ~a
43 "
44             name-sym (car type-names)
45             (if (string-null? signature-str) "" " - ") signature-str
46             name-sym
47             (if doc
48                 doc
49                 (begin
50                   (ly:warning "music function `~a' not documented." name-sym)
51                   "(undocumented; fixme)")))))
52
53
54 (define (document-object obj-pair)
55   (and (ly:music-function? (cdr obj-pair))
56        (document-music-function obj-pair)))
57
58 (define-public (identifiers-doc-string)
59   (format #f
60           "@table @asis
61 ~a
62 @end table
63 "
64           (string-join
65            (filter-map
66             document-object
67             (sort
68              (ly:module->alist (current-module))
69              identifier<?)))
70           ""))