Debian Codegraph @

lib/Analizo/Command/files_graph.pm

raw
1 package Analizo::Command::files_graph;
2 use Analizo -command;
3 use parent qw(Analizo::Command);
4 use strict;
5 use warnings;
6 use Analizo::Extractor;
7 use Graph::Writer::Dot;
8 use File::Basename;
9
10 # ABSTRACT: dependency graph generator among files
11
12 =head1 NAME
13
14 analizo-files-graph - dependency graph generator among files
15
16 =head1 USAGE
17
18 analizo files-graph [OPTIONS] <input> [<input> [<input> ...]]
19
20 =cut
21
22 sub usage_desc { "%c files-graph %o <input> [<input> [<input> ...]]" }
23
24 sub command_names { qw/files-graph/ }
25
26 sub opt_spec {
27 return (
28 [ 'output|o=s', 'output file name' ],
29 );
30 }
31
32 sub validate {
33 my ($self, $opt, $args) = @_;
34 $self->usage_error("No input files!") unless @$args;
35 my @unreadable = grep { ! -r $_ || ! -e $_ } @$args;
36 if (@unreadable) {
37 foreach my $file (@unreadable) {
38 $self->usage_error("$file is not readable");
39 }
40 }
41 if ($opt->output && ! -w dirname($opt->output)) {
42 $self->usage_error("No such file or directory");
43 }
44 }
45
46 sub execute {
47 my ($self, $opt, $args) = @_;
48 my $extractor = Analizo::Extractor->load('Doxyparse');
49 $extractor->process(@$args);
50 my $graph = $extractor->model->files_graph;
51 if ($opt->output) {
52 open STDOUT, '>', $opt->output or die "$!";
53 }
54 my $stdout = \*STDOUT;
55 my $graph_writer = Graph::Writer::Dot->new;
56 $graph_writer->write_graph($graph, $stdout);
57 close STDOUT;
58 }
59
60 =head1 DESCRIPTION
61
62 analizo files-graph reads the dependency information from one or more source code
63 directories passed as arguments, and produces as output the graph of
64 dependencies between the files of the software in the graphviz(1) format.
65
66 analizo files-graph is part of the analizo suite and was implemented to
67 represent the old analizo dsm output tool in a textual format, as the dsm tool
68 is going to be removed from analizo suite. The dependency graph includes
69 relationships among files including function calls, inheritances and attribute
70 use.
71
72 analizo files-graph is part of the analizo suite.
73
74 =head1 REQUIRED ARGUMENTS
75
76 =over
77
78 =item <input>...
79
80 The input directories (or files) with source code to be processed.
81
82 Although you can pass individual files as input, this tool is more useful if
83 you pass entire source directories.
84
85 =back
86
87 =head1 OPTIONS
88
89 =over
90
91 =item --output <file>, -o <file>
92
93 Use a file as output
94
95 =back
96
97 =head1 VIEWING THE GRAPH
98
99 See B<analizo-graph(1)>.
100
101 =head1 READING THE GRAPH
102
103 See B<analizo-graph(1)>.
104
105 =head1 SEE ALSO
106
107 B<dotty(1)>, B<dot(1)>, B<neato(1)>, B<analizo(1)>
108
109 =head1 COPYRIGHT AND AUTHORS
110
111 See B<analizo(1)>.
112
113 =cut
114
115 1;