changeset 14489:f36301ea650f

maint: merge in Mike's changes
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 22 Mar 2012 11:32:15 -0400
parents aa490c112c88 (current diff) a467f3e04b7a (diff)
children 5bd9e47e9277
files
diffstat 2 files changed, 35 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/help/gen_doc_cache.m
+++ b/scripts/help/gen_doc_cache.m
@@ -41,16 +41,23 @@
   ## Generate cache
   if (isempty (directory))
     cache = gen_builtin_cache ();
+  elseif (iscell (directory))
+    if all(cellfun (@ischar, directory))
+      cache = gen_doc_cache_in_dir (directory);
+    else
+      error ("gen_doc_cache: cell must contain only strings");
+    end
   elseif (ischar (directory))
-    cache = gen_doc_cache_in_dir (directory);
+     cache = gen_doc_cache_in_dir (directory);
   else
-    error ("gen_doc_cache: second input argument must be a string");
+     error ("gen_doc_cache: second input argument must be a string or a cell of strings");
   endif
 
   ## Save cache
   if (! isempty (cache))
-    save ("-text", out_file, "cache");
+     save ("-text", out_file, "cache");
   endif
+
 endfunction
 
 function [text, first_sentence, status] = handle_function (f, text, format)
@@ -108,31 +115,33 @@
 endfunction
 
 function cache = gen_doc_cache_in_dir (directory)
+
   ## If 'directory' is not in the current path, add it so we search it
-  dir_in_path = false;
-  p = path ();
-  idx = find (p == pathsep ());
-  prev_idx = 1;
-  for n = 1:length (idx)
-    f = p (prev_idx:idx (n)-1);
-    if (strcmp (f, directory))
-      dir_in_path = true;
-      break;
-    endif
-    prev_idx = idx (n) + 1;
-  endfor
+  dir_in_path = ismember (directory, strsplit (path (), pathsep ()));
+
+  # dirs not in path
+  if !iscell (directory)
+    directory = {directory};
+  end
+  dirs_notpath = {directory{!dir_in_path}};
+
+  # add them
+  if !isempty (dirs_notpath)
+    cellfun (@addpath, dirs_notpath);
+  end
 
-  if (!dir_in_path)
-    addpath (directory);
-  endif
+  # create cache
+  func = @(s_) create_cache (__list_functions__ (s_));
+  cache = cellfun (func, directory, 'UniformOutput', false);
 
-  ## Get list of functions in directory and create cache
-  list = __list_functions__ (directory);
-  cache = create_cache (list);
+  # concatenate results
+  cache = [cache{:}];
 
-  if (!dir_in_path)
-    rmpath (directory);
-  endif
+  #remove dirs form path
+  if !isempty (dirs_notpath)
+    cellfun (@rmpath, dirs_notpath);
+  end
+
 endfunction
 
 function cache = gen_builtin_cache ()
@@ -148,4 +157,3 @@
 %% No true tests desirable for this function.
 %% Test input validation
 %!error gen_doc_cache (1)
-
--- a/scripts/pkg/private/create_pkgadddel.m
+++ b/scripts/pkg/private/create_pkgadddel.m
@@ -29,8 +29,8 @@
   ## architecture dependent directory so that the autoload/mfilename
   ## commands work as expected. The only part that doesn't is the
   ## part in the main directory.
-  archdir = fullfile (getarchprefix (desc), cstrcat (desc.name, "-",
-                      desc.version), getarch ());
+  archdir = fullfile (getarchprefix (desc, global_install), cstrcat (desc.name,
+                      "-", desc.version), getarch ());
   if (exist (getarchdir (desc, global_install), "dir"))
     archpkg = fullfile (getarchdir (desc, global_install), nm);
     archfid = fopen (archpkg, "at");