changeset 278:042ee9410f80 octave-forge

Summary of the current directory if not run from the root
author pkienzle
date Wed, 10 Apr 2002 16:27:07 +0000
parents dd29263fe829
children b1f96506fd9c
files admin/make_index
diffstat 1 files changed, 38 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/admin/make_index	Wed Apr 10 12:15:24 2002 +0000
+++ b/admin/make_index	Wed Apr 10 16:27:07 2002 +0000
@@ -21,8 +21,8 @@
 			    # beside octave-forge if they are somewhere else
 			    # or modify this script
 my $CVSTREE = "cvs-tree.html";
-die "Cannot read $CVSTREE  -- edit $script and define the\n",
-    ".html file which was produced by the cvs-tree script\n" unless -r $CVSTREE;
+#die "Cannot read $CVSTREE  -- edit $script and define the\n",
+#    ".html file which was produced by the cvs-tree script\n" unless -r $CVSTREE;
 
 # initialize the indexing variables
 my %index_by_TB_cat   = (); # i_TB_cat{toolbox}{category} = list of functions
@@ -45,19 +45,16 @@
 	       \%index_by_function);
 }
 
-my $location = `pwd`;
-my $PATH     = "";
-if ($location =~ m\^(.*)/admin$\) {
-    chdir "..";
-    $PATH = "$1/";
-}
+die "No INDEX in current directory" if !-e "INDEX";
+my $summary = !-e "admin/make_index";  # if not in the root, just summarize
+my $include_octave = !$summary;        # only include octave if not summarizing
 
 # locate all C++ and m-files in octave-forge, and all m-files in octave
 # don't need C++ files from octave because we have DOCSTRINGS
 my @m_files = ();
 my @C_files = ();
 find(\&cc_and_m_files, ".");
-find(\&cc_and_m_files, "$OCTAVE/scripts");
+find(\&cc_and_m_files, "$OCTAVE/scripts") if $include_octave;
 sub cc_and_m_files { # {{{1 populates global array @files
     return unless -f and /\.(m|cc)$/;  # .m and .cc files
     if (/\.m$/) {
@@ -127,7 +124,10 @@
 }
 
 # grab help from octave's DOCSTRINGS
-if (open (IN,"$OCTAVE/src/DOCSTRINGS")) {
+if ( !$include_octave ) {
+  # skip DOCSTRINGS if just summary
+}
+elsif (open (IN,"$OCTAVE/src/DOCSTRINGS")) {
     $_ = <IN>;
     while (/^\c_/) {
 	my $function = $_;
@@ -146,6 +146,33 @@
     print STDERR "could not open $OCTAVE/src/DOCSTRINGS !\n";
 }
 
+
+# print a summary table rather than generating the html
+if ( $summary ) {
+    # XXX FIXME XXX add an option to spit out contents.m
+    # XXX FIXME XXX what if there is no toolbox?
+    # XXX FIXME XXX preserve category order
+    foreach my $TB ( sort keys %index_by_TB_cat ) {
+	print "$TB_description{$TB}\n\n";
+	foreach my $cat ( sort keys %{$index_by_TB_cat{$TB}} ) {
+	    print "$cat\n";
+	    foreach my $func ( sort @{$index_by_TB_cat{$TB}{$cat}} ) {
+		my $entry = sprintf("%-13s %s",$func,$function_description{$func});
+		print wrap("","\t\t","  $entry"), "\n";
+	    }
+	}
+    } 
+}
+else {
+    write_html(\%index_by_TB_cat,
+           \%TB_description,
+           \%function_description,
+           \%octave_forge_function,
+           \%index_by_function);
+}
+
+
+
 if (@uncategorized) {
     print scalar(@uncategorized), " uncategorized functions ";
     print "(out of ", $n_functions, " total)\n";
@@ -155,14 +182,6 @@
 #    print wrap("\t", "\t", join(" ", sort @uncategorized)), "\n";
 }
 
-
-write_html(\%index_by_TB_cat,
-           \%TB_description,
-           \%function_description,
-           \%octave_forge_function,
-           \%index_by_function);
-
-
 sub first_sentence { # {{{1
 # grab the first real sentence from the function documentation
     my ($desc) = @_;
@@ -292,7 +311,7 @@
     }
 
     my $oneline = first_sentence($desc);
-    printf "%30s %s\n", $function, $oneline;
+    #printf "%30s %s\n", $function, $oneline;
     $function_description{$function} = $oneline;
 #    push @function_description{$function}}, "$file\n$oneline\n$desc";
     #printf "%-12s %-20s %s\n", $function,