Skip to content

Commit

Permalink
Fix failing docstring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Aug 27, 2017
1 parent 30f93e3 commit e668bdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ For example, \"(some-func FOO &optional BAR)\"."
"Get the docstring for SYM."
(let (docstring)
(if callable-p
(-when-let (docstring (documentation sym))
(progn
(setq docstring (documentation sym))
(-when-let (docstring-with-usage (help-split-fundoc docstring sym))
(setq docstring (cdr docstring-with-usage))
(when docstring
Expand Down
8 changes: 4 additions & 4 deletions test/unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@
"Basic docstring fetching."
(should
(equal
(helpful--docstring #'test-foo)
(helpful--docstring #'test-foo t)
"Docstring here.")))

(ert-deftest helpful--docstring-advice ()
"Get the docstring on advised functions."
(should
(equal
(helpful--docstring #'test-foo-advised)
(helpful--docstring #'test-foo-advised t)
"Docstring here too.")))

(defun test-foo-no-docstring ()
nil)

(ert-deftest helpful--no-docstring ()
"We should not crash on a function without a docstring."
(should (null (helpful--docstring #'test-foo-no-docstring))))
(should (null (helpful--docstring #'test-foo-no-docstring t))))

(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))))
(should (null (helpful--docstring #'test-foo-usage-docstring t))))

(defun test-foo-no-properties ()
nil)
Expand Down

0 comments on commit e668bdf

Please sign in to comment.