I mostly spend time on Python/Django and Objective-C/CocoaTouch and js/jQuery in the course of my daily work.
My editor of choice is vim
for Python/Django and js/jQuery and xcode
for Objective-C/CocoaTouch.
One of the bottlenecks on my development speed is the pace at which I read existing code, particularly open source libraries which I use.
In Python/Django for example, when I encounter some new features introduced by django developers, I get curious and begin exploring the code base manually. For example, when class-based views were introduced from django 1.3 onwards, reference - https://docs.djangoproject.com/en/dev/topics/class-based-views/ - I will check out the example code shown:
from django.views.generic import TemplateView
class AboutView(TemplateView):
template_name = "about.html"
And try it out on one of my projects. More importantly, I am curious about what goes on behind the scenes, so I will dig into the source code -
# django/views/generic/__init__.py file
from django.views.generic.base import View, TemplateView, RedirectView
from django.views.generic.dates import (ArchiveIndexView, YearArchiveView, MonthArchiveView,
WeekArchiveView, DayArchiveView, TodayArchiveView,
DateDetailView)
from django.views.generic.detail import DetailView
from django.views.generic.edit import FormView, CreateView, UpdateView, DeleteView
from django.views.generic.list import ListView
class GenericViewError(Exception):
"""A problem in a generic view."""
pass
From here, I will trace it backwards to the django/views/generic/base.py file and find out exactly what TemplateView
class does:-
class TemplateView(TemplateResponseMixin, View):
"""
A view that renders a template.
"""
def get_context_data(self, **kwargs):
return {
'params': kwargs
}
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
return self.render_to_response(context)
And here's it shows that TemplateView
class inherits from TemplateResponseMixin
and View
classes... and I continue digging further... and so on...
The problem is, this is an extremely inefficient and slow process (to "follow" class hierachies manually and opening up each file along the way).
So the question is - is there an easy way/UI tool (or other visual solution) that parses Python code in a particular project and visualize class hierarchies which I can then inspect easily by "clicking" on a specific class I am interested to read about?
Note that I am aware of IPython shell but that doesn't seem as user-friendly as a visual display tool.
For example, there's F-Script
in the world of Objective-C/iOS/Mac programming, which not only provides a shell (much like python or IPython shell), but provides a visual way for developers to introspect class hierachies.
Reference screenshot:-
So is there a class-hierarchy visualization tool (for Python specifically, but even better if it's generic and can be used for different languages)??? What are your methods of getting up to speed efficiently when reading open source source code???
UPDATED
Per advice below, I tried out ctags
and vim plugin taglist
and I was able to use :TlistOpen
to open up a side buffer in vim like this:-
This looks really cool as :TlistOpen
now essentially shows me all the classes and functions that are available on my currently open buffer.
My problem now is that when I attempt to do Ctrl] while my cursor is on TemplateView
, I get the following error:-
What am I doing wrong? Is it because my django source code is in a virtualenv
? Or is there something specific I have to do to make ctags
/taglist
"aware" of the django source code?