Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Tuesday November 11, 2003
08:09 AM

Perl class browser

[ #15700 ]

I had 12 hours of desk time the other night, so I tarted fooling around with my idea for a Perl class browser. As I was looking through the Tk stuff, I found Tk::Browser, which looks like a class browser that didn't get off of the ground.

It really sucks that I cannot upload anything, so you have to satisify yourself with mere commentary.

I started fooling around with Tk::HList which displays a tree structure file-manager type view. With a little programming, I got the tree to show and hide various parts of itself. I will turn that into a subclass of Tk::HList since I think that that behaviour is probably what most people want with the widget.

After I can show the various modules in the widget, I can select them and have their POD and other info show up in other widgets. I display the version number, and want to work on fetching the most recent version from CPAN too (remember, I have CPAN on my laptop).

I'm dubious about other features, like showing variables and whatnot. Other languages make this easily because most things are known, but with Perl features like AUTOLOAD, code analysis is not better than documentation necessarily.

My thoughts also bring me back to a side effect of AutoSplit. The documentation for a routine does not stay with the routine. It is no big deal because we're not supposed to be mucking around in the auto directories anyway. However, I really like the method browser in Squeak (Smalltalk) and how the documentation is part of the method. We could do this in Perl:

sub foo {
=item foo
Docs go here, inside the sub

This is cheating really, because it is just a trick of text placement, and we still have to analyze the text to get the docs. I do not have a solution, and even if I did, no one would really care because it would be such a pain in the ass to do right.

So, the method browser feature of a Perl code browser probably is not worth the effort.

And, looking at things like lexicals and the symbol table is probably peeking at places we should not be.

What's left? What else do I do when I want to explore what's on my box? I mainly care about class heirarchy, documentation, and versions.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • A couple ideas (Score:3, Interesting)

    by samtregar (2699) on 2003.11.11 10:45 (#25660) Homepage Journal
    Here's a few things I might like to see at a glance in a class browser:

    • Inheritence
    • Module usage
    • Line Count
    • Does it 'use strict'?


    • Ooooh, inheritance trees. That could be fun to play with.

      Some sort of happy face icon for strict and whatnot, perhaps?

      Module use,hmmm, maybe. I have it set up so that the browser only looks in the currently installed modules, so any module it needs should already be there. It should be easy to add though.

      I think for a lot of this stuff I am going to have to write a program to walk the module directories and create data files. If I do too many things, the time to select a module and then see its conten
    • You might want to check out CPANXR and/or Module::CPANTS, both heavily under development (well CPANTS not so mucht right now, but I'll have some time soon!)
  • Rocco Caputo and I were working on a method dumper not to long ago. Give a dump subroutine an object reference and it will dump the method .and if any methods are inherited it will let you know what package they were inherited from.

    I don't think its entirely finished but it may save you a bit of work if you decide to do a method browser.

    Also it handles AUTOLOAD just by letting you know that its being used by the object and from which package it came from.