NAME

Makefile::GraphViz - Plot the Detailed Structure of Makefiles Using GraphViz

SYNOPSIS

use Makefile::GraphViz;

$parser = Makefile::GraphViz->new;
$parser->parse('Makefile');

# plot the tree rooted at the install target in Makefile:
$gv = $parser->plot('install');  # A GraphViz object returned.
$gv->as_png('install.png');

# plot the tree rooted at the default target in Makefile:
$gv = $parser->plot;
$gv->as_png('default.png');

# plot the forest consists of all the targets in Makefile:
$gv = $parser->plot_all;
$gv->as_png('default.png');

# you can also invoke all the methods inherited from the Makefile::Parser class:
@targets = $parser->targets;

DESCRIPTION

This module uses Makefile::Parser to render user's Makefiles via the amazing GraphViz module. Before I decided to write this thing, there had been already a CPAN module named GraphViz::Makefile which did the same thing. However, the pictures generated by GraphViz::Makefile is oversimplified in my opinion, So a much complex one is still needed.

IMPORTANT! This stuff is highly experimental and is currently at ALPHA stage, so production use is strongly discouraged. Anyway, I have the plan to improve this stuff unfailingly.

The Makefile::GraphViz Class

This class is a subclass inherited from Makefile::Parser. So all the methods (and hence all the functionalities) provided by Makefile::Parser are accessable here. Additionally this class also provides some more methods on its own right.

METHODS

plot($target_name)

This method is essential to the class. Users invoke this method to plot the specified Makefile target. If the argument is absent, the default target in the Makefile will be used. It will return a GraphViz object, on which you can later call the ->as_png or ->as_text method to obtain the final graphical output.

The argument can both be the target's name and a Makefile::Target object. If the given target can't be found in Makefile, the target will be plotted separately.

EXPORT

None by default.

CODE COVERAGE

I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite.

---------------------------- ------ ------ ------ ------ ------ ------ ------
File                           stmt   bran   cond    sub    pod   time  total
---------------------------- ------ ------ ------ ------ ------ ------ ------
.../lib/Makefile/GraphViz.pm  100.0   87.5   33.3  100.0  100.0  100.0   93.5
Total                         100.0   87.5   33.3  100.0  100.0  100.0   93.5
---------------------------- ------ ------ ------ ------ ------ ------ ------

SEE ALSO

Makefile::Parser, GraphViz::Makefile.

AUTHOR

Agent Zhang, <agent2002@126.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 Agent Zhang.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.