Skip to content

Commit

Permalink
Avoid displaying docstring of basic builtin types
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Mar 26, 2020
1 parent 19ec419 commit d02f4da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
8 changes: 7 additions & 1 deletion elpy/jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ def rpc_get_docstring(self, filename, source, offset):
source=source, line=line, column=column,
path=filename, encoding='utf-8',
environment=self.environment)
if locations and locations[-1].docstring():
if not locations:
return None
# Filter uninteresting things
if locations[-1].name in ["str", "int", "float", "bool", "tuple",
"list", "dict"]:
return None
if locations[-1].docstring():
return ('Documentation for {0}:\n\n'.format(
locations[-1].full_name) + locations[-1].docstring())
else:
Expand Down
39 changes: 20 additions & 19 deletions test/elpy-doc-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,30 @@
(should (re-search-forward "This module provides access")))))

;; Does not work with jedi 16.0. Jedi sometimes consider parenthesis as strings
;; (ert-deftest elpy-doc-should-find-documentation-from-inside-arguments ()
;; (elpy-testcase ()
;; (elpy-enable)
;; (python-mode)
;; (insert "import socket\n"
;; "socket.getaddrinfo(socket.gethostname(")
;; (save-excursion
;; (insert "))\n"))
(ert-deftest elpy-doc-should-find-documentation-from-inside-arguments ()
(elpy-testcase ()
(elpy-enable)
(python-mode)
(insert "import socket\n"
"socket.getaddrinfo(socket.gethostname(")
(save-excursion
(insert "))\n"))

;; (elpy-doc)
(elpy-doc)

;; (with-current-buffer "*Python Doc*"
;; (should (re-search-forward "gethostname")))
(with-current-buffer "*Python Doc*"
(message "(buffer-string): %s" (buffer-string))
(should (re-search-forward "gethostname")))

;; (erase-buffer)
(erase-buffer)


;; (insert "import socket\n"
;; "socket.getaddrinfo(socket.gethostname(), ")
;; (save-excursion
;; (insert ")\n"))
(insert "import socket\n"
"socket.getaddrinfo(socket.gethostname(), ")
(save-excursion
(insert ")\n"))

;; (elpy-doc)
(elpy-doc)

;; (with-current-buffer "*Python Doc*"
;; (should (re-search-forward "getaddrinfo")))))
(with-current-buffer "*Python Doc*"
(should (re-search-forward "getaddrinfo")))))

0 comments on commit d02f4da

Please sign in to comment.