]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4121/1: Store music function argument list names in docstring
authorDavid Kastrup <dak@gnu.org>
Sat, 20 Sep 2014 17:57:38 +0000 (19:57 +0200)
committerDavid Kastrup <dak@gnu.org>
Wed, 24 Sep 2014 13:45:39 +0000 (15:45 +0200)
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.

scm/document-identifiers.scm
scm/music-functions.scm

index 2a2e0ce074b620a28217cd8f9b1a078b4efa440b..217851e7853d0f8a50a15c6f8ed6f5c7bf6a71b7 100644 (file)
       ((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)
index 0c8e7b7cab10c6d5fba17e0a1e6bc30460a611d5..ea174a6a69cbed76248a2fccdb0b1444ccef5348 100644 (file)
@@ -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)