Graph::Usage - graph usage patterns from Perl packages


Graph-Usage documentation  | view source Contained in the Graph-Usage distribution.

Index


NAME

Top

Graph::Usage - graph usage patterns from Perl packages

SYNOPSIS

Top

	./gen_graph --inc=lib/ --format=graphviz --output=usage_graph
	./gen_graph --nocolor --inc=lib --format=ascii
	./gen_graph --recurse=Graph::Easy
	./gen_graph --recurse=Graph::Easy --format=graphviz --ext=svg
	./gen_graph --recurse=var --format=graphviz --ext=jpg
	./gen_graph --recurse=Math::BigInt --skip='^[a-z]+\z'
	./gen_graph --use=Graph::Usage::MySubClass --recurse=Math::BigInt

Options:

	--color=X		0: uncolored output
				1: default, colorize nodes on how much packages they use
				2: colorize nodes on how much packages use them
	--nocolor		Sets color to 0 (like --color=0, no color at all)

	--inc=path[,path2,..]	Path to source tree or a single file
				if not specified, @INC from Perl will be used
	--recurse=p[,p2,..]	recursively track all packages from package "p"
	--skip=regexp		Skip packages that match the given regexp. Example:
				  -skip='^[a-z]+\z'		skip all pragmas
				  -skip='^Math::BigInt\z'	skip only Math::BigInt
				  -skip='^Math'			skip all Math packages

	--output		Base-name of the output file, default "usage".
	--format		The output format, default "graphviz", valid are:
				  ascii (via Graph::Easy)
				  html (via Graph::Easy)
				  svg (via Graph:Easy)
				  dot (via Graph:Easy)
				  graphviz (see --generator below)
	--generator		Feed the graphviz output to this program, default "dot".
				It must be installed and in your path.
	--extension		Extension of the output file. For "graphviz" it will
				change the format of the output to produce the appr.
				file type.  For all other formats it will merely set
				the filename extension. It defaults to:
				  Format	Extension
				  ascii		txt
				  html		html
				  svg		svg
				  dot		dot
				  graphviz	png
	--flow			The output flows into this direction. Default "south".
				Possible are:
				  north
				  west
				  east
				  south
	--versions		include package version number in graph nodes.

	--debug			print some timing and statistics info.

	--use=Package		Use this package instead of Graph::Usage to do
				the work behind the scenes. See SUBCLASSING.

Help and version:

	--help			print this help and exit
	--version		print version and exit




DESCRIPTION

Top

This script traces the usage of Perl packages by other Perl packages from use and require statements and plots the result as a graph.

Due to the nature of the parsing it might miss a few connections, or even generate wrong positives. However, the goal is to provide a map of what packages your module/package really uses. This can be quite different from what the dependency-tree in Makefile.PL states.

graph require perl package

EXPORTS

Top

Exports nothing by default, but can export:

	LINK_USE
	LINK_REQUIRE

SUBCLASSING

Top

You can subclass this module to fine-tune the graphing process.

Here is an overview of the general code flow:

	new()
	generate_graph()
		create Graph::Easy object
		call hook_after_graph_generation()
		process files, calling:
			parse_file()
			add_package()
			add_link
		call hook_before_colorize()
		optional: call colorize()
		call hook_after_colorize()
	statistic()
	output_file()

METHODS

Top

new()

output()

generate_graph()

parse_file()

statistic()

colorize()

color_mapping()

add_package()

find_file()

	my $path = $self->find_file($package, @inc);

Take a package name and a list of include directories and try to find the file there. Returns the path if the file exists, otherwise undef.

output_file()

	$self->output_file();

Generate the output file containing the graph.

hook_after_graph_generation()

hook_before_colorize()

hook_after_colorize()

set_package_version()

TODO

Top

Output formats

Formats rendered via Graph::Easy (HTML, ASCII and SVG) have a few limitations and only work good for small to medium sized graphs.

The output format graphviz is rendered via dot or other programs and can have arbitrary large graphs.

However, for entire source trees like the complete Perl source, the output becomes unlegible and cramped even when using dot.

I hope I can improve this in time.

SEE ALSO

Top

Graph::Easy and http://bloodgate.com/perl/graph/usage.

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms of the GPL version 2. See the LICENSE file for information.

license gpl

AUTHOR

Top

(c) 2005-2006 by Tels bloodgate.com.

author tels


Graph-Usage documentation  | view source Contained in the Graph-Usage distribution.