changeset 8863:34a821854961

pkg.m (generate_lookfor_cache): generate a DOC file for each directory
author Jason Riedy <jason@acm.org>
date Wed, 25 Feb 2009 00:41:40 -0500
parents f71b749be1c1
children 4d328b8979c8
files scripts/ChangeLog scripts/help/gen_doc_cache.m scripts/pkg/pkg.m src/ChangeLog src/help.cc
diffstat 5 files changed, 27 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Feb 25 00:39:09 2009 -0500
+++ b/scripts/ChangeLog	Wed Feb 25 00:41:40 2009 -0500
@@ -1,11 +1,15 @@
 2009-02-24  John W. Eaton  <jwe@octave.org>
 
 	* help/gen_doc_cache.m: Don't compress output file.  By default,
-	write to DOC, not DOC.gz.
+	write to DOC, not DOC.gz.  Don't save empty cache.
+
 	* help/lookfor.m: Use doc_cache_file to get location of DOC file.
 
 2009-02-24  Jason Riedy  <jason@acm.org>
 
+	* pkg/pkg.m (generate_lookfor_cache): Generate a DOC file for each
+	directory.
+
 	* help/gen_doc_cache.m: Call __makeinfo__, not makeinfo.
 
 2009-02-24  Jaroslav Hajek  <highegg@gmail.com>
--- a/scripts/help/gen_doc_cache.m	Wed Feb 25 00:39:09 2009 -0500
+++ b/scripts/help/gen_doc_cache.m	Wed Feb 25 00:41:40 2009 -0500
@@ -44,7 +44,9 @@
   endif
   
   ## Save cache
-  save ("-text", out_file, "cache");
+  if (! isempty (cache))
+    save ("-text", out_file, "cache");
+  endif
 endfunction
 
 function [text, first_sentence, status] = handle_function (f, text, format)
--- a/scripts/pkg/pkg.m	Wed Feb 25 00:39:09 2009 -0500
+++ b/scripts/pkg/pkg.m	Wed Feb 25 00:41:40 2009 -0500
@@ -1585,7 +1585,10 @@
 endfunction
 
 function generate_lookfor_cache (desc)
-  gen_doc_cache (genpath (desc.dir));
+  dirs = split_by (genpath (desc.dir), pathsep ());
+  for i = 1 : length (dirs)
+    gen_doc_cache (fullfile (dirs{i}, "DOC"), dirs{i});
+  endfor
 endfunction
 
 ## Make sure the package contains the essential files.
--- a/src/ChangeLog	Wed Feb 25 00:39:09 2009 -0500
+++ b/src/ChangeLog	Wed Feb 25 00:41:40 2009 -0500
@@ -1,10 +1,10 @@
 2009-02-25  John W. Eaton  <jwe@octave.org>
 
+	* help.cc (__list_functions__): Simplify
+
 	* input.cc (get_debug_input): Don't pass arbitrary input to
 	message as a format string.
 
-	* help.cc (__list_functions__): Simplify
-
 2009-02-24  John W. Eaton  <jwe@octave.org>
 
 	* help.cc, help.h (Vdoc_cache_file): New global variable.
--- a/src/help.cc	Wed Feb 25 00:39:09 2009 -0500
+++ b/src/help.cc	Wed Feb 25 00:41:40 2009 -0500
@@ -935,60 +935,27 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value retval;
 
   // Get list of functions
-  const string_vector ffl = load_path::fcn_names ();
-  const int ffl_len = ffl.length ();
-  const string_vector afl = autoloaded_functions ();
-  const int afl_len = afl.length ();
+  string_vector ffl = load_path::fcn_names ();
+  string_vector afl = autoloaded_functions ();
   
   if (args.length () == 0)
-    {
-      Cell C (ffl_len + afl_len, 1);
-      int j = 0;
-      for (int i = 0; i < ffl_len; i++)
-        C (j++, 0) = octave_value (ffl [i]);
-      for (int i = 0; i < afl_len; i++)
-        C (j++, 0) = octave_value (afl [i]);
-            
-      retval.append (octave_value (C));
-    }
+    retval = Cell (ffl.append (afl));
   else
     {
-      // Get input
       std::string dir = args (0).string_value ();
-      if (error_state)
-        error ("__list_functions__: input must be a string");
+
+      if (! error_state)
+	{
+	  string_vector fl = load_path::files (dir);
+
+	  if (! error_state)
+	    retval = Cell (fl);
+	}
       else
-        {
-          dir = file_ops::canonicalize_file_name (dir);
-          
-          // FIXME -- This seems very inefficient. Is there a better way?
-          std::list<std::string> list;
-          for (int i = 0; i < ffl_len; i++)
-            {
-              const std::string filename = do_which (ffl [i]);
-              if (file_is_in_dir (filename, dir))
-                list.push_back (ffl [i]);
-            }
-          for (int i = 0; i < afl_len; i++)
-            {
-              const std::string filename = do_which (afl [i]);
-              if (file_is_in_dir (filename, dir))
-                list.push_back (afl [i]);
-            }
-            
-          Cell C (list.size (), 1);
-          int j = 0;
-          for (std::list<std::string>::const_iterator iter = list.begin ();
-               iter != list.end (); iter++)
-            {
-              C (j++, 0) = octave_value (*iter);
-            }
-
-          retval.append (octave_value (C));
-        }
+        error ("__list_functions__: input must be a string");
     }  
 
   return retval;