]> git.donarmstrong.com Git - lilypond.git/blob - scm/document-functions.scm
1e473f107ac3b61e444fa243abe41ed4927e3a41
[lilypond.git] / scm / document-functions.scm
1 ;;;; document-funcions.scm -- part of generated backend documentation
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 (use-modules
9  (ice-9 regex))
10
11 (define (dashify-underscores str)
12    (regexp-substitute/global #f "_" str 'pre "-" 'post))
13
14 (define (format-c-header c-h)
15   (regexp-substitute/global
16    #f "," 
17    (regexp-substitute/global #f "(SCM|\\)|\\() *" (dashify-underscores c-h)
18                              'pre "" 'post)
19    'pre " " 'post))
20
21 (define (document-scheme-function name c-header doc-string)
22   (string-append
23    "@defun " (symbol->string name)  " " (format-c-header c-header) "\n"
24    doc-string
25    "\n@end defun\n\n"))
26
27 (define all-scheme-functions
28    (hash-fold
29     (lambda (key val prior)
30       (cons (cons key val)  prior))
31     '() (ly:get-all-function-documentation)))
32
33 (define (all-scheme-functions-doc)
34   (let* ((fdocs (map (lambda (x)
35                        (document-scheme-function (car x) (cadr x) (cddr x)))
36                      all-scheme-functions))
37          (sfdocs (sort fdocs string<?))) 
38     (make <texi-node>
39       #:name "Scheme functions"
40       #:desc "Primitive functions exported by LilyPond."
41       #:text
42       (apply string-append sfdocs))))
43
44 ;; (dump-node (all-scheme-functions-doc)  (current-output-port) 0 )