From: Jan T. <de...@us...> - 2002-02-05 23:07:24
|
Update of /cvsroot/net-script/netscript2/src/tools/IPdoc In directory usw-pr-cvs1:/tmp/cvs-serv17252 Modified Files: IPdoc.pm Log Message: * finished Index: IPdoc.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/tools/IPdoc/IPdoc.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IPdoc.pm 2002/02/05 00:30:37 1.2 --- IPdoc.pm 2002/02/05 23:07:21 1.3 *************** *** 42,45 **** --- 42,46 ---- $this -> { m_fileList } = \@fileList; $this -> { m_baseDirs } = \@baseDirs; + $this -> { m_title } = "IPdoc Perl Documentation"; $this; } *************** *** 53,56 **** --- 54,58 ---- # destination - the destination directory into which the # documentation should be placed + # title - (optional) the title for the documentation # @public #*/ *************** *** 58,67 **** --- 60,75 ---- my ($this, $paramRef) = @_; $this -> { m_destDir } = $paramRef -> { "destination" }; + if ( defined($paramRef -> { "title"})) { + $this -> { m_title } = $paramRef -> { "title" }; + } my @fileList = split(/,/, $paramRef -> {"files"}); + print "Loading files...\n"; for (@fileList) { $this -> loadFiles($_); } + print "Loaded ". scalar @{$this -> { m_fileList}} . " files...\n"; my %classes = (); + print "Processing files...\n"; while (@{$this -> { m_fileList }}) { my $fileName = shift @{$this -> {m_fileList}}; *************** *** 70,74 **** --- 78,84 ---- $classes{$class->name()} = $class; } + + print "Processing class hierarchy...\n"; # now create a hierarchy for ( values(%classes)) { *************** *** 89,96 **** --- 99,113 ---- } } + print "Writing documentation...\n"; # now we can render the classes to the destination directory for ( values(%classes) ) { $this -> renderClass( $_ ) ; } + + print "Writing navigation...\n"; + # now lets render some navigation + my @theClasses = values(%classes); + $this -> renderNavigation( \@theClasses ); + print "Complete.\n"; } *************** *** 105,108 **** --- 122,129 ---- my $baseDir = ""; my @fileList = (); + unless ( -e $file) { + print "File or directory \"$file\" does not exist. Skipping...\n"; + return; + } if ( -d $file ) { $baseDir = $file; *************** *** 241,245 **** --- 262,320 ---- #/** + # Renders the navigation. + # @param a list of all known classes + #*/ + sub renderNavigation { + my ($this, $listRef) = @_; + + my $dir = $this -> { m_destDir }; # this is created at this time + my $doclet = $this -> { m_doclet } -> new ($VERSION); + + # render the package list + # we need all packages + my %packages = (); + for (@{$listRef}) { + my $name = $_ -> name(); + #cut away classname + $name =~ s/::[^:]+$//; + $packages{$name} = $name; + } + #now we got all packages and sort them ASCII + my @allPackages = sort { $a cmp $b } keys %packages; + + #next is sorting all classes by their names + + my @allClasses = sort { $a -> name() cmp $b -> name() } @{$listRef}; + #now we create a html-file for each package + my $firstPackage = ""; + for ( @allPackages ) { + my $name = $_; + $name =~ s/:/_/g; + $firstPackage = "pkg_$name.html" if $firstPackage eq ""; + open (AFILE, ">$dir/pkg_$name.html"); + print AFILE $doclet -> renderPackage( \@allClasses, $_ ); + close (AFILE); + } + + #now we create the file which holds all packages + open (AFILE, ">$dir/all_packages.html"); + print AFILE $doclet -> renderPackageList( \@allPackages, "pkg_[PKNAME].html" ); + close(AFILE); + + #next is the main frame + open (AFILE, ">$dir/main.html"); + print AFILE $doclet -> renderMainPage( $this -> { m_title } ); + close( AFILE); + + #last is the frameset + open( AFILE, ">$dir/index.html" ); + print AFILE $doclet -> renderFrameset("main.html", "all_packages.html", $firstPackage); + close(AFILE); + } + + + #/** # Convenience function. Creates all subdirectories. + # @param a string holding a directory path #*/ sub mkdirs { |