From: David Kastrup Date: Sat, 20 Sep 2014 17:57:38 +0000 (+0200) Subject: Issue 4121/1: Store music function argument list names in docstring X-Git-Tag: release/2.19.15-1~12 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8aa5e3c7392cc29515c55d57a0bf0e6da8dc03ce;p=lilypond.git Issue 4121/1: Store music function argument list names in docstring For one thing, the doc string does not make a lot of sense without the argument list and it cannot reliably be deduced from the doc string itself. For another, GUILEv2 does not do us the favor of storing the original argument list anywhere where it could be retrieved with a useful amount of labor. While it would be nice to put the types of the arguments into the doc string as well, the signature's actual predicates are only evaluated after macro expansion and that is too late for generating the doc string. So we just stick the argument list (after uncurrying) as a line at the top. --- diff --git a/scm/document-identifiers.scm b/scm/document-identifiers.scm index 2a2e0ce074..217851e785 100644 --- a/scm/document-identifiers.scm +++ b/scm/document-identifiers.scm @@ -22,10 +22,12 @@ ((name-sym (car music-func-pair)) (music-func (cdr music-func-pair)) (func (ly:music-function-extract music-func)) - (arg-names - (map symbol->string - (cddr (cadr (procedure-source func))))) - (doc (procedure-documentation func)) + (full-doc (procedure-documentation func)) + (match-args (and full-doc (string-match "^\\([^)]*\\)\n" full-doc))) + (arg-names (if match-args + (with-input-from-string (match:string match-args) read) + (circular-list "arg"))) + (doc (if match-args (match:suffix match-args) full-doc)) (sign (ly:music-function-signature music-func)) (type-names (map (lambda (pred) (if (pair? pred) @@ -44,7 +46,7 @@ name-sym (car type-names) (if (string-null? signature-str) "" " - ") signature-str name-sym - (if doc + (if (and doc (not (string-null? doc))) doc (begin (ly:warning "music function `~a' not documented." name-sym) diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 0c8e7b7cab..ea174a6a69 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -1076,9 +1076,9 @@ result." (pair? (car args))) (currying-lambda (car args) doc-string? `((lambda ,(cdr args) ,@body))) - (if doc-string? - `(lambda ,args ,doc-string? ,@body) - `(lambda ,args ,@body)))) + `(lambda ,args + ,(format #f "~a\n~a" (cddr args) (or doc-string? "")) + ,@body))) (set! signature (map (lambda (pred) (if (pair? pred)