statmobile / pydoc Goto Github PK
View Code? Open in Web Editor NEWEmacs mode for navigating Python documentation through pydoc.
License: GNU General Public License v3.0
Emacs mode for navigating Python documentation through pydoc.
License: GNU General Public License v3.0
On Windows, pydoc-browse suffers from non-availability of a "pydoc" executable, as here. Elsewhere pydoc uses pydoc-command
instead of "pydoc" and that may be better here too.
Also, "-b" is not a recognized argument for pydoc in Python 2.
I will try to submit a fix.
Overall, thanks for a very useful project.
When I run pydoc-at-point, in buffer *pydoc*
it reports:
Traceback (most recent call last):
File "/var/folders/3h/s9r7m0xn1s5gp0s8_jrjnv6h0000gn/T/py-504JjY", line 17, in
script_modules = gd[0]._evaluator.modules
AttributeError: 'Evaluator' object has no attribute 'modules'
In modeline, it show error message:
Invalid regexp: "Unmatched [ or [^"
My python script is:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import threading
def fun1():
pass
if __name__ == '__main__':
t1 = threading.Thread(target=fun1)
t1.start()
My cursor is under threading
keyword in line 10.
My system env:
$ python --version
Python 3.6.5
$ uname
Darwin
Let me begin by thanking the authors and maintainers of this package for such a useful tool. What follows is just a comment/question that I have concerning the way in which the documentation is gathered when using pydoc-at-point
, and possibly a suggestion to improve it.
I don't know if this is due to my installation (and configuration) but, for instance, when using pydoc-at-point
for the matplotlib.pyplot.plot
function, I get a docstring that is different (much sparser, just one line) from the one I get if I do pydoc "matplotlib.pyplot.plot"
. Does anyone else get this behavior? It's also worth noting that I do get the same docstrings for functions inside NumPy and SciPy, for instance.
Reading the code, I see that it uses Jedi to get the docstrings when invoking pydoc-at-point
, whereas for the rest it uses pydoc
(the command line tool). Could it be possible to reduce the use of Jedi in the code just for getting the inference of the full name of the function at point, and then pass that to pydoc
? I guess doing that would lead to a more consistent output throughout the package, as using (pydoc "matplotlib.pyplot.plot")
would be (literally) the same as using pydoc-at-point
over the plot
part.
Probably the use of Jedi to get the docstring (instead of using pydoc
as I suggest above) for pydoc-at-point
has its advantages and was therefore a conscious design choice (for reasons I fail to see as I'm a noob in `elisp), in which case I apologize for the noise.
Thanks for reading!
For example, in the file
import functools as ft
s.find('\n') == -1:
whitespace = '\n'
def f(f):
@ft.wraps(f)
when the cursor is over the '.' following the '@ft' when one runs pydoc-at-point, the pydoc buffer shown contains a backtrace instead of useful information.
I have found that this problem is caused by the escaped newlines (i.e., '\n's). I have found a fix and will submit a pull request shortly.
It seems a bit weird that pydoc asks for a buffer when hitting the q
key within the pydoc buffer.
May be you could consider using bury-buffer
or quit-window
instead of kill-buffer
.
M-x pydoc
fails
Debugger entered--Lisp error: (wrong-type-argument sequencep Traceback)
mapcar(symbol-name Traceback)
(if (executable-find "pip") (mapcar 'symbol-name (read (shell-command-to-string "python -c \"import pip; mods = sorted([i.key for i in pip.get_installed_distributions()]); print('({})'.format(' '.join(['\"{}\"'.format(x) for x in mods]))) \""))) (message "pip not found. No user-installed modules found.") 'nil)
pydoc-user-modules()
(append (pydoc-topics) (pydoc-keywords) (pydoc-builtin-modules) (pydoc-user-modules) (pydoc-pkg-modules))
(sort (append (pydoc-topics) (pydoc-keywords) (pydoc-builtin-modules) (pydoc-user-modules) (pydoc-pkg-modules)) 'string<)
(setq *pydoc-all-modules* (sort (append (pydoc-topics) (pydoc-keywords) (pydoc-builtin-modules) (pydoc-user-modules) (pydoc-pkg-modules)) 'string<))
(if (and (not reload) *pydoc-all-modules*) *pydoc-all-modules* (setq *pydoc-all-modules* (sort (append (pydoc-topics) (pydoc-keywords) (pydoc-builtin-modules) (pydoc-user-modules) (pydoc-pkg-modules)) 'string<)))
pydoc-all-modules(nil)
(completing-read "Name of function or module: " (pydoc-all-modules current-prefix-arg))
(list (completing-read "Name of function or module: " (pydoc-all-modules current-prefix-arg)))
call-interactively(pydoc record nil)
command-execute(pydoc record)
helm-M-x(nil "pydoc")
funcall-interactively(helm-M-x nil "pydoc")
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
it is because pip 10 no longer provides get_installed_distributions
bash-4.4$ python -m pip --version
pip 10.0.0 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
bash-4.4$ python -c "import pip; mods = sorted([i.key for i in pip.get_installed_distributions()]); print('({})'.format(' '.join(['"{}"'.format(x) for x in mods]))) "
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'pip' has no attribute 'get_installed_distributions'
bash-4.4$
the following change fixes the issue for me, but I guess it should require a relatively new version of pip.
diff --git a/pydoc.el b/pydoc.el
index 467487e..3651971 100644
--- a/pydoc.el
+++ b/pydoc.el
@@ -466,10 +466,10 @@ Adapted from `help-make-xrefs'."
"Return a list of strings for user-installed modules."
(if (executable-find "pip")
(mapcar
- 'symbol-name
- (read
- (shell-command-to-string
- "python -c \"import pip; mods = sorted([i.key for i in pip.get_installed_distributions()]); print('({})'.format(' '.join(['\"{}\"'.format(x) for x in mods]))) \"")))
+ (lambda (alist)
+ (alist-get 'name alist))
+ (json-read-from-string
+ (shell-command-to-string "pip list --format=json")))
(message "pip not found. No user-installed modules found.")
'()))
I have jedi 0.17.2 installed and when I call pydoc-at-point
I get the following output. (point was at UUID
function):
/tmp/py-KvISWP:2: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
s = jedi.Script("""from uuid import UUID
/tmp/py-KvISWP:2: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
s = jedi.Script("""from uuid import UUID
/tmp/py-KvISWP:81: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).infer instead.
gd = s.goto_definitions()
Traceback (most recent call last):
File "/tmp/py-KvISWP", line 89, in <module>
script_modules = list(gd[0]._evaluator.module_cache.iterate_modules_with_names())
AttributeError: 'Name' object has no attribute '_evaluator'
Hi are there any plans to make a new release?
The last release is from 2016.
See pypa/pip#5243. pip.get_installed_modules()
is used in the function pydoc-user-modules
at pydoc.el:466
. As detailed in the link, the correct way to access this functionality is to use pkg_resources
instead of pip
and then access pkg_resources.working_set
. If I have time I'll make a pull request soon.
Hello and thank you for your wonderful package!
I would love to use your package, but I don't want to include MELPA into my package list. I would be delighted if you could upload your package to MELPA-stable. This is usually as easy as tagging your code with the current version number.
Thank you very much!
Versions:
When I run M-x pydoc and hit enter, I immediately get this error message:
pydoc-user-modules: Wrong type argument: sequencep, Traceback
I am not prompted for the python module/function name.
I have determined that this happened because I did not have pip installed globally, I tend to use pip exclusively in virtualenvs.
Is it implicit that one's emacs must be virtualenv-aware to use this? Or would it be a good idea to specify in the readme that a pip needs to be accessible, either globally or through virtualenv-awareness in emacs?
pydoc uses some functionality from dash but does not require it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.