]> git.donarmstrong.com Git - lilypond.git/blob - lily/function-documentation.cc
*** empty log message ***
[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--2006 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
15 static SCM doc_hash_table;
16
17 void ly_add_function_documentation (SCM func,
18                                     char const *fname,
19                                     char const *varlist,
20                                     char const *doc)
21 {
22   if (!strlen (doc))
23     return;
24
25   if (!doc_hash_table)
26     doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59));
27
28   std::string s = std::string (" - ") + "LilyPond procedure: " + fname + " " + varlist
29     + "\n" + doc;
30
31   scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
32                                 scm_makfrom0str (s.c_str ()));
33   SCM entry = scm_cons (scm_makfrom0str (varlist), scm_makfrom0str (doc));
34   scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry);
35 }
36
37 LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
38            0, 0, 0, (),
39            "Get a hash table with all lilypond Scheme extension functions.")
40 {
41   return doc_hash_table;
42 }