]> git.donarmstrong.com Git - lilypond.git/blob - lily/function-documentation.cc
uniformize C++ <-> scheme name mappings.
[lilypond.git] / lily / function-documentation.cc
1 /*
2   function-documentation.cc -- Scheme doc strings.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include <cstring>
10 using namespace std;
11
12 #include "std-string.hh"
13 #include "lily-guile.hh"
14 #include "warn.hh"
15
16 static SCM doc_hash_table;
17
18 void
19 ly_check_name (string cxx, string scm_name)
20 {
21   string mangle = mangle_cxx_identifier (cxx);
22   if (mangle != scm_name)
23     {
24       programming_error ("wrong cxx name: " + mangle + ", " + cxx +  ", " + scm_name);
25     }
26 }
27
28
29 void
30 ly_add_function_documentation (SCM func,
31                                     string fname,
32                                     string varlist,
33                                     string doc)
34 {
35   if (doc == "")
36     return;
37
38   if (!doc_hash_table)
39     doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59));
40
41   string s = string (" - ") + "LilyPond procedure: " + fname + " " + varlist
42     + "\n" + doc;
43
44   scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
45                                 ly_string2scm (s));
46   SCM entry = scm_cons (ly_string2scm (varlist), ly_string2scm (doc));
47   scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname.c_str()), entry);
48 }
49
50 LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
51            0, 0, 0, (),
52            "Get a hash table with all lilypond Scheme extension functions.")
53 {
54   return doc_hash_table;
55 }