guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extract documentation from (define ...


From: Jan Nieuwenhuizen
Subject: Re: extract documentation from (define ...
Date: Mon, 02 Sep 2019 19:50:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Vladimir Zhbanov writes:

>> For Emacsy[0] I have used a guild doc-snarf but am now switching to doc
>> strings using.  See the `wip-doc' branch and esp.
>> 
>>     
>> https://git.savannah.nongnu.org/cgit/emacsy.git/tree/scripts/document-module.scm?h=wip-doc
>> 
>> You may want to look at the Makefile.am as well for how it's used.
>
> Cool, thanks!
>
> The only issue i see is no docstrings found for C code
> SCM_DEFINE'd Scheme procedures.

You'll have to modify SCM_DEFINE, its last argument is the docstring.
For another project, I am doing something like

--8<---------------cut here---------------start------------->8---
#undef SCM_DEFINE
#define SCM_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING)  \
SCM_SNARF_HERE(                                                         \
SCM_UNUSED static const char s_ ## FNAME [] = PRIMNAME;                 \
static SCM FNAME ARGLIST                                                \
)                                                                       \
SCM_SNARF_INIT(                                                         \
scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR,                         \
                    (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME);              \
scm_c_set_procedure_properties (PRIMNAME, __FILE__, __LINE__,  DOCSTRING);\
)                                                                       \
SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING)

void
scm_c_set_procedure_properties (char const* name, char const* file_name, int 
line, char const* doc_string)
{
  SCM proc = scm_variable_ref (scm_c_lookup (name));
  scm_set_source_property_x (proc,
                             scm_from_utf8_string ("documentation"),
                             scm_from_utf8_string (doc_string));
  scm_set_source_property_x (proc,
                             scm_from_utf8_symbol ("location"),
                             scm_list_2 (scm_cons (scm_from_utf8_string 
("file-name"),
                                                   scm_from_utf8_string 
(file_name)),
                                         scm_cons (scm_from_utf8_string 
("line"),
                                                   scm_from_int (line))));
}
--8<---------------cut here---------------end--------------->8---


The scm_c_set_procedure_properties could be more standard compliant,
hopefully.

HTH,
janneke

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]