From 73d668988bb0ee6d4ed0d27064b0616f8d58adfd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 3 Apr 2021 08:34:07 -0700 Subject: lib: new function for documentation lookup. * genman.txr: dump contents of symhash into a doc-syms.tl library file, as a defvarl form. * lisplib.c (doc_instantiate, doc_set_entries): New static functions. (lisplib_init): Register autoload for doc-lookup module to symbols doc and *doc-url*. * share/txr/stdlib/doc-lookup.tl: New file. * share/txr/stdlib/doc-syms.tl: Likewise. * txr.1: Documented. --- lisplib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lisplib.c') diff --git a/lisplib.c b/lisplib.c index a425d95b..c37cb4a5 100644 --- a/lisplib.c +++ b/lisplib.c @@ -891,6 +891,23 @@ static val match_set_entries(val dlt, val fun) return nil; } +static val doc_instantiate(val set_fun) +{ + funcall1(set_fun, nil); + load(scat2(stdlib_path, lit("doc-lookup"))); + return nil; +} + +static val doc_set_entries(val dlt, val fun) +{ + val name[] = { + lit("doc"), lit("*doc-url*"), + nil + }; + set_dlt_entries(dlt, name, fun); + return nil; +} + val dlt_register(val dlt, val (*instantiate)(val), val (*set_entries)(val, val)) @@ -946,6 +963,7 @@ void lisplib_init(void) dlt_register(dl_table, each_prod_instantiate, each_prod_set_entries); dlt_register(dl_table, quips_instantiate, quips_set_entries); dlt_register(dl_table, match_instantiate, match_set_entries); + dlt_register(dl_table, doc_instantiate, doc_set_entries); reg_fun(intern(lit("try-load"), system_package), func_n1(lisplib_try_load)); } -- cgit v1.2.3