home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.rsa.com
/
2014.05.ftp.rsa.com.tar
/
ftp.rsa.com
/
pub
/
dsg
/
public
/
doxygen
/
doxytmpl.pl
< prev
next >
Wrap
Perl Script
|
2014-05-02
|
14KB
|
627 lines
#!/usr/local/bin/perl
#
# $Id: doxytmpl.pl,v 1.54 2002/11/24 22:07:33 jleiseboer Exp $
#
#/**
# * @file
# *
# * This file handles the generation of doxygen templates.
# *
# * There is a standard set of doxygen options that make sense to have
# * in all projects. doxytmpl sets up those settings as changes from the
# * default doxygen configuration file.
# *
# * @see doxytmpl.pl, doxyfilt.pl
# *
# */
#
use Cwd;
use File::Basename;
# progname = lowercase program name without the .pl removed
$progname = $0;
$progname =~ s/\\/\//g;
# figure out a nice user friendly name for the program
$program = $progname;
$program =~ s/\.pl$//;
$program = lc $program;
$program = &basename($program);
# debug - output trace messages in script
$debug=0;
$internal=0;
$review=0;
$todo=0;
$VARS{"DOXYGEN"}="doxygen";
$VARS{"DOXYFILT"}="doxyfilt.pl";
# dot is used for diagrams
$dot="dot";
# inputlist - the filename from -inputlist=file which contains the
# list of files to process (rather than recursive from
# current directory)
$inputlist="";
#
# The path we search to find templates - which we handle
# differently depending on Win32 or Unix environments
#
if ($^O =~ /Win/)
{
$VARS{"PATH_SEP"}=";";
$VARS{"TEMPLATE_PATH"}="c:/bin;c:/bin/doxygen";
$VARS{"TEMPLATE_PATH"}.=";c:/lib;c:/lib/doxygen";
$VARS{"TEMPLATE_PATH"}.=";c:/usr/local/bin;c:/usr/local/bin/doxygen";
$VARS{"TEMPLATE_PATH"}.=";c:/usr/local/lib;c:/usr/local/lib/doxygen";
$VARS{"LOCAL_BIN"}="c:/bin;c:/usr/local/bin";
$VARS{"LOCAL_BIN"}.=";".$ENV{"HOME"}."/bin";
$VARS{"LOCAL_BIN"}.=";".$ENV{"PATH"};
$VARS{"DIR_SEP"}='\\';
}
else
{
$VARS{"PATH_SEP"}=":";
$VARS{"TEMPLATE_PATH"}="/usr/local/lib/doxygen";
$VARS{"LOCAL_BIN"}="/usr/local/bin";
$VARS{"LOCAL_BIN"}.=":".$ENV{"HOME"}."/bin";
$VARS{"LOCAL_BIN"}.=":".$ENV{"PATH"};
$VARS{"DIR_SEP"}='/';
}
#
# If we have a $HOME/doxygen directory it is used in preference to
# anything (other than the DOXYGEN_TEMPLATE env var)
#
if ($ENV{"HOME"})
{
if (-d $ENV{"HOME"}."/doxygen")
{
$VARS{"TEMPLATE_PATH"}=$ENV{"HOME"}."/doxygen".$VARS{"PATH_SEP"}.
$VARS{"TEMPLATE_PATH"};
}
}
#
# If we have a DOXYGEN_TEMPLATE environment variable then it is used
# in preference to anything else
#
if ($ENV{"DOXYGEN_TEMPLATE"})
{
$VARS{"TEMPLATE_PATH"}=$ENV{"DOXYGEN_TEMPLATE"}.$VARS{"PATH_SEP"}.
$VARS{"TEMPLATE_PATH"};
}
#
# Process args
#
foreach (@ARGV)
{
if (/^-internal$/)
{
$internal=1;
}
elsif (/^-review$/)
{
$review=1;
}
elsif (/^-inputlist=(.*)$/)
{
$inputlist=$1;
}
elsif (/^-d$/)
{
$debug++;
}
elsif (/^([^=]*)=(.*)$/)
{
$VARS{$1}=$2;
}
else
{
&do_help("$prog: ERROR: Unknown option $_",1);
}
}
&get_date();
$doxygen=$VARS{"DOXYGEN"};
$doxyfilt=$VARS{"DOXYFILT"};
$path_sep=$VARS{"PATH_SEP"};
#
# dump out a list of var=value if we are debugging things
#
if ($debug)
{
local($var);
foreach $var (sort keys %VARS)
{
print STDERR "$var=" . $VARS{"$var"} . "\n";
}
}
#
# locate doxygen in the path
#
$doxygen="";
$doxyfilt="";
$dot_path="";
if (-f $VARS{"DOXYGEN"} || -f $VARS{"DOXYGEN"}.".exe" )
{
$doxygen=$VARS{"DOXYGEN"};
}
if (-f $VARS{"DOXYFILT"} || -f $VARS{"DOXYFILT"}.".exe" )
{
$doxyfilt=$VARS{"DOXYFILT"};
}
if (-f $dot || -f "${dot}.exe")
{
$dot_path=$dot;
}
#
# - second search the provided path list
#
foreach $dir (split(/$path_sep/,$VARS{"LOCAL_BIN"}))
{
if (!$doxygen)
{
if (-f "$dir/".$VARS{"DOXYGEN"} || -f "$dir/".$VARS{"DOXYGEN"}.".exe" )
{
$doxygen="$dir/".$VARS{"DOXYGEN"};
}
}
if (!$doxyfilt)
{
if (-f "$dir/".$VARS{"DOXYFILT"})
{
$doxyfilt="$dir/".$VARS{"DOXYFILT"};
}
}
if (!$dot_path)
{
if (-f "$dir/$dot" || -f "$dir/${dot}.exe")
{
$dot_path="$dir";
}
}
if($doxygen && $doxyfilt)
{
last;
}
}
if (!$doxygen)
{
print STDERR "unable to locate doxygen executable\n";
exit(1);
}
if (!$doxyfilt)
{
print STDERR "unable to locate doxyfilt script\n";
exit(1);
}
if (!$dot_path)
{
print STDERR "\nWARNING: unable to locate dot in path - no diagrams\n\n";
sleep(2);
}
else
{
$dot_path=~s/[\\\/]/$VARS{"DIR_SEP"}/g;
##$VARS{"HAVE_DOT"}="YES";
$VARS{"DOT_PATH"}="$dot_path";
}
%defaults = (
'PROJECT_NAME', "$basename",
'DETAIL_SECTION_FIRST', "YES",
'OUTPUT_DIRECTORY', "doc",
'HIDE_UNDOC_MEMBERS', "YES",
'HIDE_UNDOC_CLASSES', "YES",
'INTERNAL_DOCS', "NO",
'INVARIANT_DOCS',"NO",
'CLASS_DIAGRAMS', "NO",
'SOURCE_BROWSER', "YES",
'DEFINED_AT_RELATION', "NO",
'REFERENCED_BY_RELATION', "NO",
'REFERENCES_RELATION', "NO",
'STRIP_CODE_COMMENTS', "YES",
'CASE_SENSE_NAMES', "YES",
'JAVADOC_AUTOBRIEF', "YES",
'GENERATE_TODOLIST', "NO",
'GENERATE_TESTLIST', "NO",
'GENERATE_BUGLIST', "NO",
'MAX_INITIALIZER_LINES', "0",
'OPTIMIZE_OUTPUT_FOR_C', "YES",
'SHOW_USED_FILES', "NO",
'WARNINGS', "YES",
'WARN_IF_UNDOCUMENTED', "YES",
'INPUT', ".",
#
# file patterns should include all scripts
#
# 'FILE_PATTERNS', "*.h *.c *.s *.asm *.cpp";
#
'FILE_PATTERNS', "*.h *.c *.s *.asm *.cpp *.bat *.sh *.pl *.dox *.bas *.cls *.vbs *.txt",
'RECURSIVE', "YES",
'EXCLUDE', "tmp out outinc",
'INPUT_FILTER', "\"perl -S $doxyfilt\"",
'FILTER_SOURCE_FILES', "NO",
'ALPHABETICAL_INDEX', "NO",
'GENERATE_HTML', "YES",
'HTML_ALIGN_MEMBERS', "YES",
'TOC_EXPAND', "NO",
'GENERATE_TREEVIEW', "YES",
'DISABLE_INDEX', "YES",
'ENUM_VALUES_PER_LINE', "4",
'GENERATE_TREEVIEW', "YES",
'TREEVIEW_WIDTH', "275",
'GENERATE_LATEX', "NO",
'GENERATE_RTF', "NO",
'GENERATE_MAN', "NO",
'ENABLE_PREPROCESSING', "YES",
'PREDEFINED', "NO_SPLIT",
'HAVE_DOT', "NO",
'SEARCHENGINE', "NO",
'EXTRACT_LOCAL_CLASSES', "NO",
'TOC_EXCLUDE_PATTERNS', "*.c *.cpp *.dox *.txt",
'HIDE_SCOPE_NAMES', "YES",
'EXAMPLE_PATH', "docsrc",
'EXAMPLE_PATTERNS', "*.c *.h *.cpp *.dox *.txt",
'EXAMPLE_RECURSIVE', "YES",
'IMAGE_PATH', "docsrc/images",
'OUTPUT_TYPEDEFS', "YES",
#'TOC_STYLE', "original,extracrispy",
'TOC_STYLE', "spicy",
'COLS_IN_ALPHA_INDEX', "3",
'ALIASES', '"eg=\par Example:\n<br>" "br=@code @endcode\n"',
'INLINE_CLASS_DECL', "YES",
);
%internal_defaults = (
'EXTRACT_ALL', "YES",
'EXTRACT_PRIVATE', "YES",
'EXTRACT_STATIC', "YES",
'HIDE_UNDOC_MEMBERS', "NO",
'INTERNAL_DOCS', "YES",
'INVARIANT_DOCS', "YES",
'CLASS_DIAGRAMS', "YES",
'DEFINED_AT_RELATION', "YES",
'REFERENCED_BY_RELATION', "YES",
'REFERENCES_RELATION', "YES",
'STRIP_CODE_COMMENTS', "NO",
'ENABLED_SECTIONS', "internal todo",
'GENERATE_TODOLIST', "YES",
'GENERATE_TESTLIST', "YES",
'GENERATE_BUGLIST', "YES",
'CLASS_GRAPH', "YES",
'COLLABORATION_GRAPH', "YES",
'INCLUDE_GRAPH', "YES",
'GRAPHICAL_HIERARCHY', "YES",
'EXTRACT_LOCAL_CLASSES', "YES",
'TOC_EXCLUDE_PATTERNS', "",
);
%review_defaults = (
'EXTRACT_ALL', "YES",
'EXTRACT_PRIVATE', "YES",
'EXTRACT_STATIC', "YES",
'HIDE_UNDOC_MEMBERS', "NO",
'INTERNAL_DOCS', "YES",
'INVARIANT_DOCS', "YES",
'CLASS_DIAGRAMS', "YES",
'INLINE_SOURCES', "YES",
'STRIP_CODE_COMMENTS', "NO",
'ENABLED_SECTIONS', "internal todo",
'DEFINED_AT_RELATION', "YES",
'GENERATE_TODOLIST', "YES",
'GENERATE_TESTLIST', "YES",
'GENERATE_BUGLIST', "YES",
'CLASS_GRAPH', "YES",
'COLLABORATION_GRAPH', "YES",
'INCLUDE_GRAPH', "YES",
'GRAPHICAL_HIERARCHY', "YES",
'EXTRACT_LOCAL_CLASSES', "YES",
'TOC_EXCLUDE_PATTERNS', "",
);
#
# do_help - report usage
#
sub do_help
{
local($message,$exit_value)=@_;
#
# the help needs expanded - but this is all there is for the moment
#
print <<"EOF";
$message
$prog - generate doxygen template
options:
-d - switch on debug (for the script)
VAR=VALUE - set the value of VAR
vars:
DOXYGEN=program - name of doxygen executable
DOXYFILT=perl_program - name of perl doxyfilt.pl program
doxygen_config_var=value - set doxygen config variable to
value (overrides other settings)
EOF
exit($exit_value);
}
#
# Each template file has a separate variable and if the user
# has not supplied a value then we search the template path to
# see if there is an override
#
%template_vars = (
'HTML_HEADER', 'header.html',
'HTML_FOOTER', 'footer.html',
'HTML_STYLESHEET', 'rsa.css',
'HTML_EXTRA_FILES', 'rsa.gif',
'LATEX_HEADER', 'header.tex',
'RTF_STYLESHEET_FILE', 'stylesheet.rtf',
);
foreach $template (keys %template_vars)
{
local($found)=0;
#
# if we have no setting then we use the defaults we have in the
# table above
#
if (!defined($VARS{$template}))
{
$VARS{$template}=$template_vars{$template};
}
#
# now try and locate the file - first as a direct value and
# then using the template path
#
if ( -f $VARS{$template} )
{
$found=1;
}
else
{
DIR:
foreach $dir (split(/$path_sep/,$VARS{"TEMPLATE_PATH"}))
{
if ( -f "$dir/".$VARS{$template} )
{
$VARS{$template}="$dir/".$VARS{$template};
$found=1;
last DIR;
}
}
}
if (!$found)
{
undef $VARS{$template};
}
if ($debug)
{
print STDERR "TEMPLATE $template = " . $VARS{$template} . "\n";
}
}
#
# we need to know the current directory - as we add that into the
# configuration file
#
$currentdir=&cwd();
$basename=&basename($currentdir);
$dirname=&dirname($currentdir);
#
# If we have not had a doxyfile (the doxygen configuration file)
# specified then we use the basename of the directory with .doxy
# appended
#
if (!$VARS{"DOXYFILE"})
{
$VARS{"DOXYFILE"}="${basename}.doxy";
}
$outfile=$VARS{"DOXYFILE"};
if ($debug)
{
print STDERR "prog: $progname pdir=$pdir dir=$dirname base=$basename\n";
}
#
# Write out a simple header so it is clear what generated this
# configuration file (and when it was generated) and the settings
# (command line args) that were used.
#
$output="#\n# generated by $progname - $date\n#\n";
$output.="# " . join(" ",@ARGV) . "\n";
$output.="#\n";
$doxygen=~s/[\\\/]/$VARS{"DIR_SEP"}/g;
# if we have an input list then we need to load that in now
if ($inputlist && !$VARS{"INPUT"} && !$VARS{"INPUT_FILE"})
{
$VARS{"RECURSIVE"}="NO";
$VARS{"INPUT"}=" \\\n";
open(INPUT,"<$inputlist") || die "Unable to open $inputlist - $!\n";
while(<INPUT>)
{
# ignore comments
next if /^#/;
chop;
$VARS{"INPUT"}.="\t\t$_ \\\n";
}
$VARS{"INPUT"}.="\n";
close(INPUT);
}
#
# Handling loading patterns from files ...
#
foreach $var (keys %VARS)
{
if ($var =~ m/(.*_PATTERNS)_FILE$/ || $var =~ m/^(INPUT_FILE)$/)
{
$pattern_var=$1;
if ($pattern_var eq "INPUT_FILE")
{
$pattern_var = "INPUT";
}
$value=$VARS{$var};
if ($debug)
{
print STDERR "PATTERN FILE VAR $pattern_var\n";
}
if (open(PATTERN,"<$value"))
{
$VARS{"$pattern_var"}=" \\\n";
while(<PATTERN>)
{
# ignore comments
next if /^#/;
chop;
$VARS{"$pattern_var"}.="\t\t$_ \\\n";
}
close(PATTERN);
$VARS{"$pattern_var"}.="\n";
}
else
{
print STDERR "Warning - unable to open $var file - $!\n";
}
}
}
$exec="$doxygen -g- |";
if ($debug)
{
print STDERR "EXECUTE: \"$exec\"\n";
}
open(DOXYGEN,"$exec") || die "unable to run $doxygen - $!\n";
while(<DOXYGEN>)
{
local($changed);
chop;
if ( /^([A-Z0-9_]+)\s*=\s*(.*)/ )
{
$var=$1;
$value=$2;
$changed=0;
if ($debug)
{
print STDERR "$var $value\n";
}
#
# if we have a default value for a variable we use it
#
if (defined $defaults{"$var"})
{
$value=$defaults{"$var"};
$changed=1;
}
#
# if we are generating internal documentation then if we match
# an internal variable we use its value
#
if ($internal && defined $internal_defaults{"$var"})
{
$value=$internal_defaults{"$var"};
$changed=1;
}
#
# if we are generating review documentation then if we match
# an internal variable we use its value
#
if ($review && defined $review_defaults{"$var"})
{
$value=$review_defaults{"$var"};
$changed=1;
}
#
# if we got a doxygen config variable value on the command line
# then we use it - this provides a generic mechanism for just
# updating values so that hand-editing of doxygen config files
# should not be necessary
#
if (defined $VARS{"$var"})
{
$value=$VARS{"$var"};
$changed=1;
}
#
# Now simply write out the value (which may be what was there
# originally or may have been changed by any of the conditions
# above)
#
if ($changed && $debug)
{
print STDERR "*** $var $value\n";
}
$output.="$var = $value\n";
}
else
{
#
# If it isn't VAR=value then we simply output it intact
#
$output.="$_\n";
}
}
close(DOXYGEN);
#
# Write the output to the configuration file
#
open(OUT,">$outfile") || die "unable to create $outfile - $!\n";
print OUT "$output";
close(OUT);
print "$program: created doxygen config file $outfile\n";
exit(0);
sub get_date
{
local(@month,@a);
@month=('Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec');
@a=localtime(time());
$date=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900);
return($date);
}