Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Graphing Perl Packages, updated

4 views
Skip to first unread message

Tels

unread,
Sep 23, 2005, 11:38:32 AM9/23/05
to per...@perl.org
-----BEGIN PGP SIGNED MESSAGE-----

Moin,

I updated the graph-perl-usage package, to be found on my site or CPAN:

http://bloodgate.com/perl/graph/usage/
http://search.cpan.org/~tels/

(0.07 is the latest version, please use together with 0.30 of Graph::Easy)

I incorporated one idea from Randy, namely the --skip option. Give it a
regexp to skip packages matching that regexp. Example

./gen_graph --recurse=Math::BigInt --skip='^[a-z]+\z'

to skip all pragmas. (lowercase a-z package names).

There is also a new --flow option, that you can use to control the general
flow direction (up, north, left, right, down etc) of the resulting graph.

On the output side, you can now generate SVG and dot-output (to look at
it) via Graph::Easy.

And you can now pass the desired format (as file extension) to "dot",
meaning you can generate other file formats than png like:

./gen_graph --recurse=Math::BigInt --skip='^[a-z]+\z' --ext=ps

This would create a .ps file. :)

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. :)

Enjoy,

Tels

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

"Build a man a fire, and he'll be warm for a day. Set a man on fire, and
he'll be warm for the rest of his life." -- Terry Pratchett

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

iQEVAwUBQzQheHcLPEOTuEwVAQHkrgf+LcaFo8wsAh75NShFF+CE4KJBRwVanoU0
AC2v4a694BSopxG1uLuUNLy5mHVqI+suvWzBkFvnkwtuEvGQNTm9zVOM8p3LeJx+
rU7Y3CtIti/zEWR+ZGVccl6EaN9bu4i3xPnZY4UNEAhmc8DaQMvfsV8Lnxab5ojs
pSJ2KRF1/80vBY6cGXYCXiDqsGEaXQ0+r8IluY3FknXjf7I/88mQNB4Fau5PzpEd
nyxcSXNVRYhZrrGSSimeB3afmvohMzKbdi36rXfG05/+oc94q/wYnK1Yap9rs+Ht
rCbjrr9abUb+wrx4x94LcyglHMgX2DXlYP5WAA2f9pjcTM/sEbvosQ==
=ZQ93
-----END PGP SIGNATURE-----

Michael G Schwern

unread,
Sep 23, 2005, 1:15:02 PM9/23/05
to Tels, per...@perl.org
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 sch...@pobox.com 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

Tels

unread,
Sep 23, 2005, 1:33:04 PM9/23/05
to Michael G Schwern, per...@perl.org
-----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-----

Michael G Schwern

unread,
Sep 23, 2005, 6:15:27 PM9/23/05
to Tels, per...@perl.org
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.

Reality is that which, when you stop believing in it, doesn't go away.
-- Phillip K. Dick

Michael G Schwern

unread,
Sep 23, 2005, 7:50:37 PM9/23/05
to Jan Dubois, Tels, per...@perl.org
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!");

Life is like a sewer - what you get out of it depends on what you put into it.
- Tom Lehrer

Tels

unread,
Sep 24, 2005, 7:58:32 AM9/24/05
to Michael G Schwern, per...@perl.org
-----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-----

Jan Dubois

unread,
Sep 23, 2005, 7:03:32 PM9/23/05
to Michael G Schwern, Tels, per...@perl.org
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


Adam Kennedy

unread,
Sep 25, 2005, 1:17:43 AM9/25/05
to per...@perl.org, Michael G Schwern, Tels, per...@perl.org
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

0 new messages