I just installed the python-mode in Emacs and it seems to be working well. However, I could not find documentation for the package on the official site.
The package comes with a doc folder where I can see two files:
commands-python-mode.org
commands-python-mode.rst
Both files seem to be formatted for some external tool that displays the help text.
With this:
Is there a tool I can use to navigate this documentation?
Does python-mode have an online site with documentation? Any tutorials or good walk-throughs for python-mode for Emacs?
Start off with M-x describe-mode. This gives you an overview over the available key bindings. For each command use C-f name RET to see the built-in documentation. The .org file should be an org-mode file and easily readable with Emacs.
See also here
A cursory inspection of those two files and the code tells me that they're basically a listing of the docstrings found in pymacs.el and python-mode.el. That means you'll be able to access the relevant documentation through M-x apropos or C-h a and friends (specifically, search for ^py or ^pymacs to get a listing of the mode functions).
As a general rule, because elisp doesn't support namespaces, all functions/variables defined by a given mode will have a consistent prefix related to the name of the mode. That makes it fairly simple to search through the Emacs documentation.
If your a emacs user and haven't heard of org-mode before your in for treat.
Open the .org file in emacs and go to org-mode (METAxorg-mode), use TAB on the header lines. Header-lines starts with one or more *.
In addition to answers given: Try a walkthrough of the menu "Python", which appears at the head of window. It will display a short description of the commands or options.
WRT to beginnners, some introduction, examples of basic usage might be given still.
Filed a feature request:
https://bugs.launchpad.net/python-mode/+bug/1281970
Related
I'm trying to crack the URL format for Python's os module for use in PyCharm's documentation window.
My attempt so far:
https://docs.python.org/3/library/os.html#{element.qname}
but I'm having trouble displaying documentations such as:
https://docs.python.org/3/library/os.path.html#module-os.path
What's the right format?
Before addressing the URL hack, it should be mentioned that the deciding setting of how documentation is shown is the "Render external documentation for stdlib" setting. You can configure it by going to File > Settings > Python Integrated Tools > Docstrings > Render external documentation for stdlib as shown in the screenshot:
If you enable the "Render external documentation for stdlib" setting (and have internet access), the IDE will automatically retrieve standard library docs from https://docs.python.org/{python.version}/library/{module.name}.html#{element.qname}. The Python version is automatically determined from the Python interpreter configured for the Project, so that's the version of the documentation shown for the file you have opened in the editor.
See how this corresponds to the online documentation:
If you disable the "Render external documentation for stdlib" setting (or don't have internet access), the IDE will show the docstrings of its integrated stub files.
Having said that, the documentation tool window does not require configuring the URL for standard library modules (e.g. for the os, sys, etc...) contrary to how it's necessary for other libraries' External Documentation. In fact, there is no option in the IDE settings to change the address for standard library modules.
What's the right format?
The complete format would be:
https://docs.python.org/{python.version}/library/{module.name}.html#{element.qname}
crack the URL format for Python's os module for use in PyCharm's documentation window.
This can be done, but it is limited to specific modules. It can not be done for the whole standard library because the base Module Name field would have to be left empty and in that case the IDE will ignore the setting.
If you use the hack for a specific module, the IDE will show the docstrings in the documentation tool window (like in example 2) but if you click the external link it will open the browser in the address configured in the external documentation. See the screenshot:
So the hack has limited usefulness.
The hack can be used with offline docs if you download the Python HTML documentation (but it would still be limited to only showing documentation like in example 2). In that use case the correct way to write the URL would depend on OS/Shell/Browser, for Windows/CMD/Firefox you could use the below URL but there's no way to escape the hash # sign so the anchor won't work, but you'll be taken to the documentation page.
file:///C:/directory_name/library/{module.name}.html#{element.qname}
PyCharm (PY-193.6911.25, macOS 10.15.4) doesn't correctly display the OpenCV documentation.
More concretely, this is the result.
As you can see, it's a mess. Is it possible to fix this? I installed OpenCV with pip.
After googling a lot I ended up thinking there is no easy solution but... there actually is!
What i did is:
Push CTRL Q
Scroll down to the trippledot and click open source.
Push CTRL+R(replace)
replace '. ' to ''
Now docstring looks like this:
Definately not perfect, but i think it looks a bit better.
Additionally i added this as external documentation:
https://opencv-python-tutroals.readthedocs.io/en/latest/search.html?q={element.name}&check_keywords=yes&area=default
So it brings up a cv2 'tutorial'...
In PyCharm 2020.1.1 professional edition with Python 3.7, the following warning is displayed for the cv2 docstring
You need configured Python 2 SDK to render Epydoc docstrings
Epydoc is a tool for generating API documentation for Python modules, based on their docstrings.
Pycharm can't render Epydoc docstrings
The suitable interpreter is looked up among those configured in the IDE (it has to be Python 2 since Epydoc package itself hasn't been ported to Python 3 yet). In other words, you need to set up it once so that it showed up on the list at Settings | Project: ... | Project Interpreter | Show All... -- it doesn't need to be actually used in any project. Is it true in your case?
The problem is that it's not really Epytext. OpenCV uses Doxygen for documentation that we don't support and also confuse with Epytext because of the similarity of tags. There is an open issue about it.
Doxygen is confused with Epydoc and displayed as free text (not preformatted)
I'm afraid this particular feature of PyCharm is not really extensible at the moment. Besides, displaying of documentation, injecting references to symbols inside it, completion of available tags and generation of documentation stubs -- everything is tied very closely to the fact that in Python code documentation is normally provided via designated string literals, not comments. The highest level API you can plug into to provide custom documentation source for Quick Documentation popup/tool window is com.intellij.lang.documentation.DocumentationProvider if you register yours before the default one with ID pythonDocumentationProvider. But it will cover only rendering, everything else will need to be written from scratch.
The official resolution is we don't support that
In python I can get some rudimentary documentation for any object using help(<object>). But to be able to search the documentation, I have to go online. This isn't really helpful if I'm somewhere where the internet isn't accessible.
In R, there is a handy double question mark feature (??<topic>) that allows me to search through the documentation of all installed libraries for any function that includes <topic> in its name or documentation string. Is there anything similar for python? Perhaps even just for loaded objects?
pydoc comes with python and can do searches but only in the synopsis lines of available modules. Quoting pydoc --help:
pydoc -k
Search for a keyword in the synopsis lines of all available modules.
Note that into pydoc you can perform searches using "/".
Look in the python folder in the folder: Doc. This folder has the entire downloaded documentation of the python docs from python.org. I know this is a VERY late answer, but it brings up an easy solution.
This was mentioned in the comments already: Zeal
is similar to Dash but for Windows/Linux. It uses the same sources as Dash. It's built using Qt and is available in the repositories for several distros, for Ubuntu there is a PPA. Download it here.
Zeal is a simple offline API documentation browser inspired by Dash (OS X app), available for Linux and Windows.
Quickly search documentation using Alt+Space (or customised) hotkey to display Zeal from any place in your workspace.
Search in multiple sets of documentation at once.
Don't be dependent on your internet connection.
Integrate Zeal with Emacs, Sublime Text, or Vim. See Usage » Editor plugins for details.
It is open source (GPL), development happens on GitHub. Zeal uses the same stylesheets/HTML as the online docs, so everything should look familiar.
An in-browser alternative is devdocs.io. You can access the website even if you are offline, provided that you've marked them for local offline storage. You'll need to enable the Python 2 docs, and then mark them for offline storage here. However, as a longtime user of the online Python docs, I find the custom stylesheet that DevDocs uses a bit distracting.
Just to add another option for offline access of python docs (mostly core):
I don't have access to a linux computer at the moment, but on windows, you can navigate to your_python_dist_folder/doc to find some help files. Particularly python275.chm for instance.
If there's no doc folder on your linux machine, you can download the file here and google for a linux chm viewer:
https://www.google.com/search?q=linux+chm+viewer
::Note:
Some distributions also include docs for other packages in there... might be worth a check. Other than that, help(module) usually returns good information.
Edit:
You could get something that might be a little closer to what you want by using pydoc. E.g. you are looking for something about sin in the math module:
import math
import pydoc
[i for i in dir(math) if 'sin' in pydoc.getdoc(getattr(math,i))]
This would return the methods whose docstrings include sin:
['acos', 'acosh', 'asin', 'asinh', 'cos', 'cosh', 'isinf', 'sin', 'sinh']
for which you then could run the help() function
In case your working in a Mac there is Dash, which allows you to download docsets and then explore/search offline. Despite its documentation functionality, Dash is also a Snippet Manager.
Windows Idle - F1 from shell window or editing window gets you a windows help file of all the docs. I think it's better than the online version - it's easier to find stuff.
Although there are certainly better documentations built into your computer than help() like windows idle, another option for some of the more common topics would just be to save some of the online documentation to your computer. For the modules you use a lot and want to access offline, you could just download a text file version of the official online python documentation, which is the best place to get documentation. (file > save page as > select .txt file format)
This may not have been available at the time the question asked and answered, but python.org now makes all the documentation available online as an archive of HTML files which can be navigated and searched offline: https://docs.python.org/2/download.html
(The link directs to docs for the latest version of 2.x, but you can choose 3.x and older 2.x versions from that page)
You should try ipython.
object_name? will print all sorts of details about any object,
including docstrings, function definition lines (for call arguments)
and constructor details for classes.
The magic commands %pdoc, %pdef, %psource and %pfile will respectively print the docstring, function definition line, full source code and the complete file for any object (when they can be found). If automagic is on (it is by default), you don’t need to type the ‘%’ explicitly.
I am turning to Python from .NET world. And Visual Studio was something a great tool i used.
In python world we do have basic IDLE and another one is VIM. I have seen that a lot of developers have configured VIM to a great IDE. Using basic VIM in Windows 7 seems of less use.
So i want to moderate my VIM to a level which has file explorer, syntax highlighting, search, error highlighting etc. So that it gives feel of Visual Studio and more productive.
But all hacks/tips available are for Linux/Ubuntu users mostly, which i may use later but as of now i need to make my VIM in Windows more productive, visual.
Please Suggest some Tips/Hacks/Resources to look around for VIM configuration?
Thanks
This question addresses your low level issue: coding Python with an IDE that is not VS.
There are a few popular blog posts addressing your high level issue: setting up Vim for Python development. They are a quick google away…
I feel the need to point out that Vim is not an IDE. You can customize it a lot and end up with something that looks like an IDE but you won't get an IDE. Only an over-customized text editor.
Anyway, here are a few tips for starting out with Vim:
Do $ vimtutor as many times as needed to feel comfortable with the basics.
Get familiar with Vim's buit-in documentation: the answers to most of your questions are somewhere inside. :help gets you to the front page, :help 'option' shows the documentation for option, :help :command shows the documentation for command… Hit <C-]> on a colored word to jump to its definition.
Don't use Janus or SPF13 or whatever pre-packaged set of plugins. You'll only grow bad habits. Similarly, don't copy other people's vimrc wholesale.
Ctags is an external code indexer that is used by Vim to "jump to definition" with <C-]>. cscope is another option, it's more powerful but also a little more complex. See :help tags.
Related to ctags, TagList and TagBar are two popular plugins used to display more or less the equivalent of the Object Browser in VS.
NERDTree is another popular plugin that mimicks the file tree found in many IDEs/editors. But Vim comes with netrw (:Ex) by default, try it before installing NERDTree.
Read :help motion.txt as soon as possible.
Watch Drew Neil's laser-guided vimcasts.
Don't rush it.
you can use vim plugins on windows, http://www.vim.org/scripts/index.php, typing "vim {your feature here}" into google will come up with lots of results.
popular file explorer is nerdtree,
syntax highlighting can be turned on with
syntax on in your vimrc
searching open file is easy to do using reg exes . Initialize search with /.
Searching directory is easy to do using grep.
I don't develop on windows but i have read that Cygwin might be worth installing for some linux tools if not already installed.
I am in no way an evangelist of any Editor/IDE.
But, if you are a newbie to Python I would suggest trying out Sublime Text 2 http://www.sublimetext.com/ . It is a very light weight yet powerful editor with a great following and it has a free evaluation version with no deadline.
But, if you intend to work using frameworks such as Django/ GAE then I would suggest using PyCharm from JetBrains
http://www.jetbrains.com/pycharm/
Finally, these tools are all just personal choices until you get comfortable with one or two of them.
Thanks,
-Hari
One possible compromise is to use your favorite IDE with a vim emulator plugin. For example, in Eclipse you can use Vrapper, PyCharm has IdeaVim and so forth. Lighttable also has vim key-bindings. The plug-ins (or key-binding options) give you some of the benefits of editing in Vim while still having the powerful debugging / navigation features, etc. of a full-blown IDE. BTW, Vrapper works with PyDev.
Using an emulator in an IDE allows you to gain the "muscle-memory" necessary for effective vim editing, without getting bogged down in "configuration hell" associated with turning an editor into an IDE (which auto-complete plugin do I use?..etc.?). Once you have mastered the vim keystrokes for normal and visual mode, used along with insert mode, you may decide to continue on into pure Vim and face those issues.
I wouldn't recommend to learn VIM in 2012 (despite it being a great editor). If you must, this blog post will get you started.
But VIM isn't an IDE, it's a text editor.
If you really want a powerful IDE, try IntelliJ IDEA or Eclipse. Both have great plugins to turn them into Python IDEs (along with code completion and all the other nice time savers). For Eclipse, try PyDev. For IntelliJ, search for Python in the plugin preferences pages.
I'm looking for a suite of plugins that can help me finally switch over to vim full-time.
Right now I'm using Komodo with some good success, but their vim bindings have enough little errors that I'm tired of it.
What I do love in Komodo, though, is the code completion. So, here's what I'm looking for (ordered by importance).
Code completion, meaning: the ability to code complete modules/functions/etc. in any module that's on the pythonpath, not just system modules. Bonus points for showing docstrings when completing.
Jump-to a class definition. I'm guessing CTAGS will do this, so how do you all manage automatically updating your tags files?
Project type management for managing buffers: ideally the ability to grep for a filename in a directory structure to open it. Bonus for showing an index of class definitions while a buffer is open.
Bzr integration. Not super important, since most of it I can just drop to the shell to do.
Here you can find some info about this.
It covers code completion, having a list of classes and functions in open files. I haven't got around to do a full configuration for vim, since I don't use Python primarily, but I have the same interests in transforming vim in a better Python IDE.
Edit: The original site is down, so found it saved on the web archive.
And I write another plugin: https://github.com/klen/python-mode
Old (now its more powerful) screencast here: https://www.youtube.com/watch?v=67OZNp9Z0CQ
Old question, but I typed all this up for a misread question...
General plugin recommendations: LookupFile and a plugin for your source control system (I like Git and Git-Vim).
Python plugin recommendations: If you're using Linux, I'd recommend ipython and ipy.py (a better interactive interpreter). Improved syntax highlighting, snippets, pydoc, and for refactoring support bicyclerepairman. I got started with this post.
You may want to try looking through someone's vimfiles. Mine are on github.
For refactoring: ropevim
Here is some info on Bazaar integration if you're interested:
https://launchpad.net/bzr-vim-commands
I use pydoc.vim (I actually wrote it) a lot, try it and tell me what you think. Another one that I think is quite useful is the updated syntax file with all it's extensions that you can enable, which you can find here.
I use Pydiction (http://www.vim.org/scripts/script.php?script_id=850) it's a plugin for vim that lets you Tab-complete python modules/methods/attributes/keywords, including 3rd party stuff like Pygame, wxPython, Twisted, and literally everything. It works more accurately than other things i've tried and it doesn't even require that python support be compiled into your Vim.
Code completion: PySmell looks promising. It's work-in-progress, but alredy useful.
I personally thinkJedi Vim is the best, but it is incompatible with python-mode.