Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,20 @@ unescaping too."
((s-contains-p "\\[" contents)
(delete-region start-pos end-pos)
(insert (helpful--format-commands contents keymap)))
;; Implicit Info node references like `(elisp)Foo Bar'.
;; These appear in docstrings and should be rendered as
;; clickable links, matching describe-function behavior.
((string-match
(rx string-start
"(" (group (one-or-more (not (any ")")))) ")"
(group (one-or-more anything))
string-end)
contents)
(delete-region start-pos end-pos)
(insert (helpful--button
contents
'helpful-info-button
'info-node contents)))
;; Highlight a normal `foo', extracting the surrounding
;; text so we can detect e.g. "function `foo'".
(t
Expand Down
15 changes: 15 additions & 0 deletions test/helpful-unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ bar")

bar")))

(ert-deftest helpful--docstring-info-node ()
"Implicit Info node references should become buttons."
;; A backtick-quoted Info node reference like `(elisp)Foo Bar'
;; should be rendered as a clickable button.
(let* ((formatted (helpful--format-docstring "`(elisp)Foo Bar'")))
(should (equal formatted "(elisp)Foo Bar"))
(should (get-text-property 0 'button formatted)))
;; A reference with a different manual should also work.
(let* ((formatted (helpful--format-docstring "`(cl)Loop Facility'")))
(should (equal formatted "(cl)Loop Facility"))
(should (get-text-property 0 'button formatted)))
;; Regular symbol references should not be affected.
(let* ((formatted (helpful--format-docstring "`message'")))
(should (equal formatted "message"))))

(ert-deftest helpful--docstring-advice ()
"Get the docstring on advised functions."
(should
Expand Down