RE: Graphing Perl Packages, updated

2005-09-25 Thread Jan Dubois
On Fri, 23 Sep 2005, Michael G Schwern wrote:
 On Fri, Sep 23, 2005 at 07:33:04PM +0200, Tels wrote:
  Not yet. Good idea. The relevant code is in parse_file() in
  gen_graph - it gets as option one .pm file and then does something
  with it.
 
  The lopp for each file is in gather_data(), under the recurse
  branch:
 
  I'll redesign the code to be more re-usable and move away from the
  file methodology. But I won't have time until mid-October.

 Ok, thanks. I'll let you know if I get any tuits to work on it
 before then.

Maybe I'm missing something, but wouldn't it make sense to use
Module::ScanDeps for this and put any additional heuristics in
there?

Cheers,
-Jan




Re: Graphing Perl Packages, updated

2005-09-25 Thread Adam Kennedy

Michael G Schwern wrote:

On Fri, Sep 23, 2005 at 05:38:32PM +0200, Tels wrote:


If you have any ideas how to make this even more usefull, please speak
now. I will have limited email reading/writing capabilities the next two
weeks, but I *will* respond to all emails/critics/praises, even though it 
may only be when I return. :)



Is the dependency detector pluggable?  The code I'm interested in graphing
requires modules indirectly through things like aliased.pm, base.pm and
Class::Autouse's superloader.  It would be nice if I could extend its dep
scanner to take these into account.


I wasn't going to mention it until I had something that actually worked, 
but I've got plans to solve this.


I'm aiming for a PPI-based module (most like called Perl::Depends at 
this point) that will be properly pluggable, so that additional 
Class::Autouse packages and the like can be supported.


I have some _very_ early framework code but nothing useful yet, it's on 
the drawing board some time after PPI 1.100 (with the caching code) and 
a few other bits and pieces are done.


Adam K


Re: Graphing Perl Packages, updated (again :)

2005-09-24 Thread Tels
-BEGIN PGP SIGNED MESSAGE-

Moin,

On Saturday 24 September 2005 00:15, Michael G Schwern wrote:
 On Fri, Sep 23, 2005 at 07:33:04PM +0200, Tels wrote:
  Not yet. Good idea. The relevant code is in parse_file() in gen_graph
  - it gets as option one .pm file and then does something with it.
 
  The lopp for each file is in gather_data(), under the recurse branch:
 
  I'll redesign the code to be more re-usable and move away from the
  file methodology. But I won't have time until mid-October.

 Ok, thanks.  I'll let you know if I get any tuits to work on it before
 then.

Ah, what the heck, I couldn't relax if I have this problem on my mind, 
anyway :)

So I whipped up Graph::Usage 0.10:

http://bloodgate.com/perl/packages/devel/

it is not on CPAN because it is still a bit rough and I have a flight to 
catch. Anyway, the logic is now in Graph::Usage, which is loaded by 
gen_graph and then simple used. You can choose which package to use for 
processing via the --use command line switch.

There is an example subclass of Graph::Usage in t/lib/Graph/Usage, and 
here is how you would use it:

perl -It/lib ./gen_graph --use=Graph::Usage::MySubClass
 --recurse=Math::BigInt --versions

I re-arranged the logic to call methods instead of fiddling some things 
directly into the graph, the relevant methods you would want to override 
are:

parse_file($file);
add_package($name,$ver);
add_link ($src,$dst,$type);
set_package_version($ver);

There also some hooks that are called on strategic points through the 
code:

sub hook_after_graph_generation
sub hook_before_colorize
sub hook_after_colorize

I hope this is usefull, but I can imagine that I missed something or that 
the existing hooks are not enough for your application.

Any feedback (preferable patches :) welcome :)

Best wishes,

Tels

- -- 
 Signed on Sat Sep 24 13:52:59 2005 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 ...pornographic images stay in the brain forever. -- Mary Anne Layden;
 That's a feature, not a bug. -- God

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQzU/aHcLPEOTuEwVAQGUagf7Bt4gpeMF3ta3eRvYRI8RKinxSqPJcys/
5DcASSg/wzrjcTteS/JxQoDVecOcnzoCM/1VaLIT/T60V2l5UNYa2dFALiOqBfXK
JAEBTr+4izVsHlfk6kjC1Fz2WNbrOnfqW+D0AZ5/1kBXcnumLTZBx0xq6RH+1zkJ
5gRJlEexZyZEtoELjRGZsUqSXFs2PTuaEW6dv1aLRSb6nS6/h8qFCueloB9knQHB
7KV9ata2LbvJvLEy4wwszgwBSB+AvHCUekxP4GC3itN4PYTPgEUH33sfS2bcF9vo
zDYfhjtuKrKmmLurMjH0jm5+xy6LWlyjoWEQU6iBhUjtGrnRpqp9Zw==
=HZaT
-END PGP SIGNATURE-


Re: Graphing Perl Packages, updated

2005-09-23 Thread Michael G Schwern
On Fri, Sep 23, 2005 at 05:38:32PM +0200, Tels wrote:
 If you have any ideas how to make this even more usefull, please speak
 now. I will have limited email reading/writing capabilities the next two
 weeks, but I *will* respond to all emails/critics/praises, even though it 
 may only be when I return. :)

Is the dependency detector pluggable?  The code I'm interested in graphing
requires modules indirectly through things like aliased.pm, base.pm and
Class::Autouse's superloader.  It would be nice if I could extend its dep
scanner to take these into account.


-- 
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
'All anyone gets in a mirror is themselves,' she said. 'But what you
gets in a good gumbo is everything.'
-- Witches Abroad by Terry Prachett


Re: Graphing Perl Packages, updated

2005-09-23 Thread Tels
-BEGIN PGP SIGNED MESSAGE-

Moin,

On Friday 23 September 2005 19:15, Michael G Schwern wrote:
 On Fri, Sep 23, 2005 at 05:38:32PM +0200, Tels wrote:
  If you have any ideas how to make this even more usefull, please
  speak now. I will have limited email reading/writing capabilities the
  next two weeks, but I *will* respond to all emails/critics/praises,
  even though it may only be when I return. :)

 Is the dependency detector pluggable?  The code I'm interested in
 graphing requires modules indirectly through things like aliased.pm,
 base.pm and Class::Autouse's superloader.  It would be nice if I could
 extend its dep scanner to take these into account.

Not yet. Good idea. The relevant code is in parse_file() in gen_graph - it 
gets as option one .pm file and then does something with it.

The lopp for each file is in gather_data(), under the recurse branch:

I'll redesign the code to be more re-usable and move away from the file 
methodology. But I won't have time until mid-October.

Best wishes,

Tels

- -- 
 Signed on Fri Sep 23 19:29:38 2005 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 If you want to travel around the world and be invited to speak at a lot
 of different places, just write a Unix operating system. -- Linus
 Torvalds

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQzQ8WHcLPEOTuEwVAQHvzQf9Fe7T0Q8gZ8Tm5x0OvgBsOflftLptABJJ
syBXXamTDtIqA2dABbdxXRCfp1wZna/V7MzZmhJoxaChFdCXAQHfCJLNHxMLZaha
wwu9HBm8edfATkDbS0pft4RmETR66gjSHHUrGyPutKBCfmuOx1Waqp/462xagAOf
lxxeyUOUp/D+qAQTqBP1uWjZ1T0RM4dGdvII9M59vKh6KRf9Sqtjnl3+CXFF2vTX
VwVyybGxG8yq4zgX7IbRrOQu+tQzn7mt+I2H9hjNIFLF+O/DccPv9IbygsCgKTRT
aLmGb2lb+OISyxDi3+t7ZZ+7xpd9me0Az0eNvCBSd2mOd65486MWRA==
=zn3o
-END PGP SIGNATURE-


Re: Graphing Perl Packages, updated

2005-09-23 Thread Michael G Schwern
On Fri, Sep 23, 2005 at 07:33:04PM +0200, Tels wrote:
 Not yet. Good idea. The relevant code is in parse_file() in gen_graph - it 
 gets as option one .pm file and then does something with it.
 
 The lopp for each file is in gather_data(), under the recurse branch:
 
 I'll redesign the code to be more re-usable and move away from the file 
 methodology. But I won't have time until mid-October.

Ok, thanks.  I'll let you know if I get any tuits to work on it before
then.

-- 
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick


Re: Graphing Perl Packages, updated

2005-09-23 Thread Michael G Schwern
On Fri, Sep 23, 2005 at 04:03:32PM -0700, Jan Dubois wrote:
  Ok, thanks. I'll let you know if I get any tuits to work on it
  before then.
 
 Maybe I'm missing something, but wouldn't it make sense to use
 Module::ScanDeps for this and put any additional heuristics in
 there?

Module::ScanDeps isn't pluggable, either.  In fact, none of the dep scanners
I've come across are. 

Some of the heuristics I need are general purpose, some are specific to my
company's code.  But they fall into two categories:

*  A module which loads another named module.  base.pm and aliased.pm are 
   examples.  For these your dep scanner needs to know the syntax of the
   loading module.  Sometime of these are on CPAN and thus of general use,
   some are not.

use base 'Foo::Bar';

use aliased 'Foo::Bar';

use aliased;
my $Customer = alias 'My::Company::Customer';


*  Loading of modules on demand, such as Class::Autouse's superloader.
   In this case your dep scanner has to find class method calls and infer
   module use from that.

use Class::Autouse qw(:superloader);

print CGI-b(Wow!);


-- 
Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern
Life is like a sewer - what you get out of it depends on what you put into it.
- Tom Lehrer