commit 4631d00026dbad5a376462ddf76d90354b6f430c
parent a360236394503a3794d8dd7ac528d8a58f5da3ef
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Sun, 2 Apr 2017 13:36:20 +0100
Handle compiled functions, or functions with only usage specified.
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/helpful.el b/helpful.el
@@ -144,10 +144,11 @@ state of the current symbol."
(-when-let (docstring (documentation sym))
(-when-let (docstring-with-usage (help-split-fundoc docstring sym))
(setq docstring (cdr docstring-with-usage))
- ;; Advice mutates the docstring, see
- ;; `advice--make-docstring'. Undo that.
- ;; TODO: Only do this if the function is advised.
- (setq docstring (helpful--skip-advice docstring)))
+ (when docstring
+ ;; Advice mutates the docstring, see
+ ;; `advice--make-docstring'. Undo that.
+ ;; TODO: Only do this if the function is advised.
+ (setq docstring (helpful--skip-advice docstring))))
docstring))
(defun helpful (symbol)
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -37,3 +37,12 @@
(ert-deftest helpful--no-docstring ()
"We should not crash on a function without a docstring."
(should (null (helpful--docstring #'test-foo-no-docstring))))
+
+(defun test-foo-usage-docstring ()
+ "\n\n(fn &rest ARGS)"
+ nil)
+
+(ert-deftest helpful--usage-docstring ()
+ "If a function docstring only has usage, do not return it."
+ (should (null (helpful--docstring #'test-foo-usage-docstring))))
+