Tutorial: Use Coda with locally stored Django documentation

Coda is great tool for coding and offers nice feature to define your own reference books/documentation for programming languages you are using. While it is expected that you point to online versions of these it is much better to use local copies of documentation as it allows to use them while offline and it is much faster as well.

This tutorial (verified on Mac OS X Leopard) will explain how to locally store Django documentation in HTML form and how to set up Coda use it as a reference book.

1. Preparation

As Django documentation is stored as reStructuredText (reST) files you need to translate it into HTML. Therefore you should install Sphinx- Python document generation tool.

As i found on Mac OS X you may need to install few required components which will not autoinstall together with Sphinx.

a) Pygments- Python based syntax highlighter

sudo easy_install Pygments

b) Jinja2 template engine

download and extract Jinja2-2.1.1.tar.gz (you may try to easy_install it but it didn't work for me so this is another way):

cd ~/Downloads/Jinja2-2.1.1/
sudo python setup.py install

c) after that it should be easy to install Sphinx

sudo easy_install sphinx

2. Get latest Django documentation and translate it to HTML files

mkdir django
cd django
svn co http://code.djangoproject.com/svn/django/trunk/docs
cd docs
make html

Now let's move Django html documentation which resides in _build/html/ subdirectory to some more meaningful place- e.g. in docs folder under user home directory:

mv _build/html/ ~/docs/django

Doubleclick ~/docs/django/index.html in Finder and check if documentation works in web browser.

3. Add local Django documentation as a reference book in Coda

Last step is to create new book in Coda's Book section and put right parameters in book preferences. Replace [user shortname] with name of your user home.

Book URL: 
file:///Users/[user shortname]/docs/django/contents.html
Search URL:
file:///Users/[user shortname]/docs/django/search.html?q=*&check_keywords=yes&area=default
Use for mode: 
Django (If you use Django-Template Syntax Highlighting for Coda) or Python (otherwise)

From now ⌘-double-click on selected words in Django files (syntax mode in Coda should be set properly) will get you to appropriate Django documentation page. You can do the same for Django-template html files as well by defining another book with the same URLs but different mode.

And it will be fast (works offline as well).

Enjoy.

Filed under  //   coda   django   documentation   html   local   tutorial  

About