File Coverage

blib/lib/Autodia.pm
Criterion Covered Total %
statement 12 32 37.5
branch 0 4 0.0
condition n/a
subroutine 4 7 57.1
pod 3 3 100.0
total 19 46 41.3


line stmt bran cond sub pod time code
1             package Autodia;
2 1     1   905 use strict;
  1         2  
  1         60  
3              
4             =head1 NAME
5              
6             Autodia.pm - The configuration and Utility perl module for AutoDia.
7              
8             =head1 VERSION
9              
10             2.14
11              
12             =head1 DESCRIPTION
13              
14             AutoDia takes source files as input and using a handler parses them to create documentation through templates. The handlers allow AutoDia to parse any language by providing
15             a handler and registering in in autodia.pm. The templates allow the output to be heavily customised from Dia XML to simple HTML and seperates the logic of the application
16             from the presentation of the results.
17              
18             AutoDia is written in perl and defaults to the perl handler and file extension matching unless a language is specified using the -l switch.
19              
20             AutoDia requires Template Toolkit and Perl 5. Some handlers and templates may require additional software.
21              
22             Helpful information, links and news can be found at the autodia website - http://www.aarontrevena.co.uk/opensource/autodia/
23              
24             =head1 METHODS
25              
26             =over 4
27              
28             =item getHandlers
29             =item getPattern
30             =item setConfig
31              
32             =back
33              
34             =head1 Configuring AutoDia via Autodia.pm
35              
36             To add handlers or languages edit this file.
37              
38             =over 4
39              
40             =item To add a handler/parser
41              
42             Add the language or name of the parser and the name of the module to the %handlers hash in the getHandlers function.
43              
44             for example :
45              
46             "perl" => 'HandlerPerl',
47              
48             Documentation on writing your own handler can be found in the HandlerPerl and Handler perl modules
49              
50             =item To add a new language or file extension or file matching patter
51              
52             Add the name of the pattern and a hashreference to its properties to %patterns in the get_patterns function.
53              
54             for example :
55              
56             "perl" => \%perl,
57              
58             Create a hash of its properties that will be pointed to by the above hashref
59              
60             for example :
61              
62             my %perl = (
63             regex => '\w+\.p[ml]$',
64             wildcards => [
65             "pl", "pm",
66             ],
67             );
68              
69             =back
70              
71             =cut
72              
73             ###############################################################
74              
75             BEGIN {
76 1     1   7 use Exporter ();
  1         2  
  1         21  
77 1     1   11 use vars qw($VERSION @ISA @EXPORT);
  1         2  
  1         94  
78 1     1   2 $VERSION = "2.14";
79 1         26 @ISA = qw(Exporter);
80 1         500 @EXPORT = qw(
81             &getHandlers
82             &getPattern
83             );
84             }
85              
86             #---------------
87              
88             my %config;
89              
90             ###############################################################
91              
92             sub setConfig
93 0     0 1   { %config = %{$_[1]}; }
  0            
94              
95             sub getHandlers
96             {
97 0     0 1   my %handlers = (
98             "perl" => 'Autodia::Handler::Perl',
99             'c++' => 'Autodia::Handler::Cpp',
100             "csharp" => 'Autodia::Handler::CSharp',
101             "cpp" => 'Autodia::Handler::Cpp',
102             "php" => 'Autodia::Handler::PHP',
103             "dbi" => 'Autodia::Handler::DBI',
104             "dbi_sqlt" => 'Autodia::Handler::DBI_SQLT',
105             "dia" => 'Autodia::Handler::dia',
106             "sql" => 'Autodia::Handler::SQL',
107             "torque" => 'Autodia::Handler::Torque',
108             "python" => 'Autodia::Handler::python',
109             "umbrello" => 'Autodia::Handler::umbrello',
110             "asp" => 'Autodia::Handler::ASP',
111             "mason" => 'Autodia::Handler::Mason',
112             );
113 0 0         print "getting handlers..\n" unless ( $config{silent} );
114 0           return \%handlers;
115             }
116              
117             sub getPattern
118             {
119 0     0 1   my $language = lc($config{language});
120 0 0         print "getting pattern for $language\n" unless ( $config{silent} );
121              
122 0           my %perl = (
123             regex => '\w+\.(?:p[ml]|cgi)$',
124             wildcards => [
125             "pl", "pm", "cgi",
126             ],
127             );
128              
129 0           my %php = (
130             regex => '\w+\.php(?:3|4)?$',
131             wildcards => [
132             "php", "php3", "php4",
133             ],
134             );
135              
136 0           my %cpp = (
137             regex => '\w+\.(c|cpp|hh?)$',
138             wildcards => [
139             "c", "cpp", "h","hh"
140             ],
141             );
142              
143 0           my %csharp = (
144             regex => '\w+\.(cs)$',
145             wildcards => [
146             "cs"
147             ],
148             );
149              
150 0           my %python = (
151             regex => '\w+.py$',
152             wildcards => [ 'py', ]
153             );
154              
155 0           my %dia = ( regex => '\w+.dia',
156             wildcards => ['dia'],
157             );
158              
159 0           my %sql = ( regex => '\w+.sql',
160             wildcards => ['sql'],
161             );
162              
163              
164 0           my %umbrello = ( regex => '\w+.xmi',
165             wildcards => ['xmi'],
166             );
167              
168 0           my %asp = ( regex => '\w+.asp',
169             wildcards => ['asp'],
170             );
171              
172 0           my %mason = ( regex => '\w+(.(mas|m?html)|handler)$',
173             wildcards => ['mas', 'html', 'mhtml'],
174             );
175              
176              
177              
178 0           my %patterns = (
179             "perl" => \%perl,
180             'c++' => \%cpp,
181             "cpp" => \%cpp,
182             "csharp" => \%csharp,
183             "php" => \%php,
184             "dbi" => {},
185             "dia" => \%dia,
186             "sql" => \%sql,
187             "torque" => {},
188             "python" => \%python,
189             "umbrello" => \%umbrello,
190             "asp" => \%asp,
191             "mason" => \%mason,
192             );
193              
194 0           return \%{$patterns{$language}};
  0            
195             }
196              
197              
198             ###############################################################
199              
200             =head1 USAGE
201              
202             use the autodia.pl script to run autodia.
203              
204             =over 4
205              
206             =item autodia.pl ([-i filename [-p path] ] or [-d directory [-r] ]) [options]
207              
208             =item autodia.pl -i filename : use filename as input
209              
210             =item autodia.pl -i 'filea fileb filec' : use filea, fileb and filec as input
211              
212             =item autodia.pl -i filename -p .. : use ../filename as input file
213              
214             =item autodia.pl -d directoryname : use *.pl/pm in directoryname as input files
215              
216             =item autodia.pl -d 'foo bar quz' : use *pl/pm in directories foo, bar and quz as input files
217              
218             =item autodia.pl -d directory -r : use *pl/pm in directory and its subdirectories as input files
219              
220             =item autodia.pl -o outfile.xml : use outfile.xml as output file (otherwise uses autodial.out.xml)
221              
222             =item autodia.pl -m [file|directory] : use multiple output files split by file or directory (creates an autodia-files directory containing files)
223              
224             =item autodia.pl -O : output to stdout
225              
226             =item autodia.pl -l language : parse source as language (ie: C) and look for appropriate filename extensions if also -d
227              
228             =item autodia.pl -t templatefile : use templatefile as template (otherwise uses template.xml)
229              
230             =item autodia.pl -S : silent mode, no output to stdout except with -O
231              
232             =item autodia.pl -h : display this help message
233              
234             =back
235              
236             =head1 AUTHOR
237              
238             Aaron Trevena, Eaaron.trevena@gmail.comE
239              
240             =head1 COPYRIGHT AND LICENSE
241              
242             Copyright (C) 2001 - 2007 by Aaron Trevena
243              
244             This library is free software; you can redistribute it and/or modify
245             it under the same terms as Perl itself, either Perl version 5.8.1 or,
246             at your option, any later version of Perl 5 you may have available.
247              
248             =cut
249              
250              
251             1;