]> code.delx.au - gnu-emacs-elpa/commitdiff
fix docstring extraction for "fancy" docs
authorNoam Postavsky <npostavs@users.sourceforge.net>
Thu, 28 Nov 2013 02:34:29 +0000 (21:34 -0500)
committerNoam Postavsky <npostavs@users.sourceforge.net>
Thu, 28 Nov 2013 02:34:29 +0000 (21:34 -0500)
The docstrings for yas-expand and yas-expand-from-keymap are generated
on the fly, depending on how they are called ("context"). Add a context
argument to the synthesizing functions and pass it nil when extracting
docstrings for the manual.

doc/yas-doc-helper.el
yasnippet.el

index e4d2857cfeeffa20e54ab83956f369e05da81ab9..f9e0f694ab606c69b8d088bc31239cc6f5d35f62 100755 (executable)
            (body (or (cond ((boundp symbol)
                             (documentation-property symbol 'variable-documentation t))
                            ((fboundp symbol)
-                            (documentation symbol t))
+                            (let ((doc-synth (car-safe (get symbol 'function-documentation))))
+                              (if (functionp doc-synth)
+                                  (funcall doc-synth nil)
+                                (documentation symbol t))))
                            (t
                             (format "*WARNING*: no symbol named =%s=" symbol)))
                      (format "*WARNING*: no doc for symbol =%s=" symbol)))
index eb7afc6b4cca1e386903f3126756aae1ed0b976b..6c95978bfc7755a2223b1e665597939ba3fd769f 100644 (file)
@@ -4298,31 +4298,33 @@ When multiple expressions are found, only the last one counts."
 ;; depending on the context.
 ;;
 (put 'yas-expand  'function-documentation
-     '(yas--expand-from-trigger-key-doc))
-(defun yas--expand-from-trigger-key-doc ()
+     '(yas--expand-from-trigger-key-doc t))
+(defun yas--expand-from-trigger-key-doc (context)
   "A doc synthesizer for `yas--expand-from-trigger-key-doc'."
-  (let ((fallback-description
-         (cond ((eq yas-fallback-behavior 'call-other-command)
-                (let* ((fallback (yas--keybinding-beyond-yasnippet)))
-                  (or (and fallback
-                           (format " call command `%s'." (pp-to-string fallback)))
-                      " do nothing (`yas-expand' doesn't shadow\nanything)")))
-               ((eq yas-fallback-behavior 'return-nil)
-                ", do nothing.")
-               (t
-                ", defer to `yas-fallback-behaviour' (which see)"))))
+  (let* ((yas-fallback-behavior (and context yas-fallback-behavior))
+         (fallback-description
+          (cond ((eq yas-fallback-behavior 'call-other-command)
+                 (let* ((fallback (yas--keybinding-beyond-yasnippet)))
+                   (or (and fallback
+                            (format "call command `%s'."
+                                    (pp-to-string fallback)))
+                       "do nothing (`yas-expand' doesn't shadow\nanything).")))
+                ((eq yas-fallback-behavior 'return-nil)
+                 "do nothing.")
+                (t "defer to `yas-fallback-behaviour' (which see)."))))
     (concat "Expand a snippet before point. If no snippet
-expansion is possible,"
+expansion is possible, "
             fallback-description
             "\n\nOptional argument FIELD is for non-interactive use and is an
 object satisfying `yas--field-p' to restrict the expansion to.")))
 
-(put 'yas-expand-from-keymap  'function-documentation '(yas--expand-from-keymap-doc))
-(defun yas--expand-from-keymap-doc ()
+(put 'yas-expand-from-keymap 'function-documentation
+     '(yas--expand-from-keymap-doc t))
+(defun yas--expand-from-keymap-doc (context)
   "A doc synthesizer for `yas--expand-from-keymap-doc'."
   (add-hook 'temp-buffer-show-hook 'yas--snippet-description-finish-runonce)
   (concat "Expand/run snippets from keymaps, possibly falling back to original binding.\n"
-          (when (eq this-command 'describe-key)
+          (when (and context (eq this-command 'describe-key))
             (let* ((vec (this-single-command-keys))
                    (templates (mapcan #'(lambda (table)
                                           (yas--fetch table vec))