Hi list,
Here's something which I think will be useful to Schemers.
Public functions written in Scheme aren't documented (except in the
source). (The list of "Scheme functions" in the Internals Reference
consists of functions defined in C++ which are available in Scheme.) The
attached will produce a list of all such functions, giving useful
information including a documentation string where provided. Markup
functions (which are documented elsewhere in their Lily syntax -- i.e.,
\rest for rest-markup -- can be omitted.) You can also list the contents
of other modules.
It would be nice to include the source-file in the output, in case someone
wants to see the code. How could I get at that info?
Also, "pure-unpure-containers" aren't caught at this point. How can I get
their docstrings?
Hope this proves useful!
David
\version "2.19.17"
#(define (get-binding-list iface)
(let* ((iface (resolve-module iface))
(bindings (struct-ref iface 0)))
(hash-map->list cons bindings)))
#(define (symbol-closure-list iface)
(let* ((bindings (get-binding-list iface))
(bindings
(map
(lambda (b) (cons (car b) (variable-ref (cdr b))))
bindings))
(closures
(filter
(lambda (b) (closure? (cdr b)))
bindings))
(closures
(sort closures
(lambda (x y) (symbol<? (car x) (car y))))))
closures))
#(define (omit-markup-functions lst)
(remove
(lambda (elt)
(string-contains (symbol->string (car elt)) "markup"))
lst))
#(define (symbol-closure-doc-list iface omit-markups?)
(let* ((closures (symbol-closure-list iface))
(closures (if omit-markups?
(omit-markup-functions closures)
closures)))
(map (lambda (c)
(list
(car c)
(cdr c)
(let ((doc (procedure-documentation (cdr c))))
(if doc doc "DOCME"))))
closures)))
% UNCOMMENT THE FOLLOWING TO SEND TO A FILE:
%#(set-current-output-port (open-output-file "closures.txt"))
%% boolean determines whether markup commands (which are documented
%% in their Lily syntax) are included.
#(format #t "~:{~a~%~a~%~3t~s~%__________~%~%~}" (symbol-closure-doc-list '(lily) #t))
%#(format #t "~:{~a~%~a~%~3t~s~%__________~%~%~}" (symbol-closure-doc-list '(srfi srfi-1) #f))
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user