]> git.donarmstrong.com Git - lilypond.git/blob - lily/function-documentation.cc
* lily/function-documentation.cc (ly_add_function_documentation):
[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--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include <cstring>
10
11 #include "protected-scm.hh"
12 #include "string.hh"
13
14 static Protected_scm doc_hash_table;
15
16 void ly_add_function_documentation (SCM func,
17                                     char const *fname,
18                                     char const *varlist,
19                                     char const *doc)
20 {
21   if (!strlen (doc))
22     return;
23
24   if (scm_hash_table_p (doc_hash_table) != SCM_BOOL_T)
25     doc_hash_table = scm_c_make_hash_table (59);
26
27   String s = String (" - ") + "LilyPond procedure: " + fname + " " + varlist
28     + "\n" + doc;
29
30   scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"),
31                                 scm_makfrom0str (s.to_str0 ()));
32   SCM entry = scm_cons (scm_makfrom0str (varlist), scm_makfrom0str (doc));
33   scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname), entry);
34 }
35
36 LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation",
37            0, 0, 0, (),
38            "Get a hash table with all lilypond Scheme extension functions.")
39 {
40   return doc_hash_table;
41 }