Table of Contents
Haddoc is a simple tool that allows an emacs user to search the Python HTML documentation indexes and to bring a web browser to an index term page.
Important
[2009-12-03] I haven't used Haddoc in a while, and it's not in a working state at the moment. Feel free to try to scavenge bits and pieces to make it work again, but please don't expect a polished work at this point.
Even though I have the Python TexInfo documentation installed from my Emacs, somehow I always end up browsing the documentation from a web browser. Most of the time I start from either the Python Library Reference or from the index. I wanted to be able to bring up the documentation from within Emacs. This does it.
With haddoc, you invoke the elisp function haddoc-lookup (I type C-c .), enter some search terms, and the matches from the Python indexes are shown in a buffer, from which you can select to direct your external web browser to. I like to drive an external Firefox with it.
I took the simple approach and wrote a combination of Emacs-LISP and Python code to implement this:
Use the source.
Note
This will not work on Python HTML documentation before Python-2.3.3. Update your documentation if necessary (or fix the code).
Download the code and unpack it. Install it using distutils:
python setup.py install
(You may need to run this as superuser.)
Initialize the haddoc database:
haddoc-update file:///path/to/python/html
(You may need to run this as superuser.) Note that you can specify an URL to the online documentation if desired.
By default the database will be created in /var/lib/haddoc; If you would like to create it someplace else, use the appropriate option, for example:
haddoc-update -D /home/myuser/.haddoc/haddoc.db <URL>
Try running the lookup tool from the command-line:
haddoc-lookup waitpid
You should get some result lines. If this does not work, fix the problem.
Copy haddoc.el somewhere in your Emacs load-path, and add something like this to your .emacs in your Python customizations section to create a binding in python-mode:
(require 'haddoc) (define-key py-mode-map [(control c)(?.)] 'haddoc-lookup)
You may need to require 'python-mode.
Customize the elisp package browse-url.el if you don't like the way that the browser is controlled, or to select your favourite browser program.
Copyright (C) 2006 Martin Blais. All Rights Reserved.
This code is distributed under the GNU General Public License;
Martin Blais <blais@furius.ca>