recent changes to help functions

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

recent changes to help functions

John W. Eaton
Administrator
Since your original patch for converting the help system to .m files
was done back in March 2008, the following changes in help.cc might
have been lost:

2008-08-19  David Bateman  <[hidden email]>

        * load-path.cc (load-path::do_find_dir (const std:string&) const)):
        Method to find a directory on the load-path corresponding to the
        argument.
        * load-path.h (load-path::do_find_dir (const std:string&) const),
        load-path::find_dir (const std::string&) const): New methods.
        * utils.cc (std::string contents_file_in_path (const std::string&)):
        New function.
        * utils.h  (std::string contents_file_in_path (const std::string&)):
        Declare it.
        * help.cc (static bool raw_help_from_file (const std::string&,
        std::string&, std::string&, bool&)): Also check is requested
        argument is a directory and contains the file Contents.m.

2008-08-04  John W. Eaton  <[hidden email]>

        * octave.cc (initialize_pathsearch): Fix usage of
        file_ops::dir_sep_str.
        * help.cc (Flookfor): Likewise.
        * dirfns.cc (Ffilesep): Likewise.
        (Fautoload): Likewise.

2008-05-04  John W. Eaton  <[hidden email]>

        * help.cc (make_name_list): Call symbol_table::global_variable_names
        and symbol_table::top_level_variable_names instead of passing
        scope to symbol_table::variable_names.

I also see that things like

  help @a/a

are not working now, and they did before the switch to the .m file
help.

jwe
Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
fre, 23 01 2009 kl. 12:50 -0500, skrev John W. Eaton:
> Since your original patch for converting the help system to .m files
> was done back in March 2008, the following changes in help.cc might
> have been lost:

Yeah, I was fearing that :-(

> 2008-08-19  David Bateman  <[hidden email]>
>
> * load-path.cc (load-path::do_find_dir (const std:string&) const)):
> Method to find a directory on the load-path corresponding to the
> argument.
> * load-path.h (load-path::do_find_dir (const std:string&) const),
> load-path::find_dir (const std::string&) const): New methods.
> * utils.cc (std::string contents_file_in_path (const std::string&)):
> New function.
> * utils.h  (std::string contents_file_in_path (const std::string&)):
> Declare it.
> * help.cc (static bool raw_help_from_file (const std::string&,
> std::string&, std::string&, bool&)): Also check is requested
> argument is a directory and contains the file Contents.m.

It seems that these changes mostly work as-is. However, I think it would
be better to move this code directly into 'help.m'. That would IMHO make
the code simpler. I'm currently spending all my time on grading exams,
so I don't think I'll have any time to look at this till next week.

> 2008-08-04  John W. Eaton  <[hidden email]>
>
> * octave.cc (initialize_pathsearch): Fix usage of
> file_ops::dir_sep_str.
> * help.cc (Flookfor): Likewise.
> * dirfns.cc (Ffilesep): Likewise.
> (Fautoload): Likewise.

I'm not sure what this change does, and how it affects the current
implementation.

> 2008-05-04  John W. Eaton  <[hidden email]>
>
> * help.cc (make_name_list): Call symbol_table::global_variable_names
> and symbol_table::top_level_variable_names instead of passing
> scope to symbol_table::variable_names.

Same comment as above.

> I also see that things like
>
>   help @a/a
>
> are not working now, and they did before the switch to the .m file
> help.

I'm somewhat surprised that this no longer works. I was hoping this
change would have been independent of my changes.

Anyway, I'll look into these changes, but it won't be until some time
next week :-(

Søren

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
lør, 24 01 2009 kl. 09:40 +0100, skrev Søren Hauberg:

> fre, 23 01 2009 kl. 12:50 -0500, skrev John W. Eaton:
> > 2008-08-19  David Bateman  <[hidden email]>
> >
> > * load-path.cc (load-path::do_find_dir (const std:string&) const)):
> > Method to find a directory on the load-path corresponding to the
> > argument.
> > * load-path.h (load-path::do_find_dir (const std:string&) const),
> > load-path::find_dir (const std::string&) const): New methods.
> > * utils.cc (std::string contents_file_in_path (const std::string&)):
> > New function.
> > * utils.h  (std::string contents_file_in_path (const std::string&)):
> > Declare it.
> > * help.cc (static bool raw_help_from_file (const std::string&,
> > std::string&, std::string&, bool&)): Also check is requested
> > argument is a directory and contains the file Contents.m.
>
> It seems that these changes mostly work as-is. However, I think it would
> be better to move this code directly into 'help.m'. That would IMHO make
> the code simpler. I'm currently spending all my time on grading exams,
> so I don't think I'll have any time to look at this till next week.
Did this feature actually work before? I've tried to

  mkdir delme
   echo "## some text" > delme/Contents.m

in the shell and then

  addpath ("delme")
  help delme

from Octave, and it didn't work for me with a checkout from before you
checked in my changes. Anyway, the attached changeset allows for this
behaviour. I've implemented this in 'help.m', so the I removed some more
code from C++.

Søren


help_contents.changeset (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
In reply to this post by Søren Hauberg
lør, 24 01 2009 kl. 09:40 +0100, skrev Søren Hauberg:
> > I also see that things like
> >
> >   help @a/a
> >
> > are not working now, and they did before the switch to the .m file
> > help.
>
> I'm somewhat surprised that this no longer works. I was hoping this
> change would have been independent of my changes.

Are you sure this doesn't work? If I type

  help @polynomial/polynomial

in the 'examples' directory, I get the help text in question. Do you
have an example where it fails?

[a little bit later]
Ohh, I see that

  help @polynomial/polyval

fails, but that also failed before. Anyway, I'll look into it...

Søren

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

David Bateman-2
In reply to this post by Søren Hauberg
Søren Hauberg wrote:

> lør, 24 01 2009 kl. 09:40 +0100, skrev Søren Hauberg:
>  
>> fre, 23 01 2009 kl. 12:50 -0500, skrev John W. Eaton:
>>    
>>> 2008-08-19  David Bateman  <[hidden email]>
>>>
>>> * load-path.cc (load-path::do_find_dir (const std:string&) const)):
>>> Method to find a directory on the load-path corresponding to the
>>> argument.
>>> * load-path.h (load-path::do_find_dir (const std:string&) const),
>>> load-path::find_dir (const std::string&) const): New methods.
>>> * utils.cc (std::string contents_file_in_path (const std::string&)):
>>> New function.
>>> * utils.h  (std::string contents_file_in_path (const std::string&)):
>>> Declare it.
>>> * help.cc (static bool raw_help_from_file (const std::string&,
>>> std::string&, std::string&, bool&)): Also check is requested
>>> argument is a directory and contains the file Contents.m.
>>>      
>> It seems that these changes mostly work as-is. However, I think it would
>> be better to move this code directly into 'help.m'. That would IMHO make
>> the code simpler. I'm currently spending all my time on grading exams,
>> so I don't think I'll have any time to look at this till next week.
>>    
>
> Did this feature actually work before? I've tried to
>
>   mkdir delme
>    echo "## some text" > delme/Contents.m
>
> in the shell and then
>
>   addpath ("delme")
>   help delme
>
> from Octave, and it didn't work for me with a checkout from before you
> checked in my changes. Anyway, the attached changeset allows for this
> behaviour. I've implemented this in 'help.m', so the I removed some more
> code from C++.
>
> Søren
>
>  
It worked when I committed it. Can't say if it worked recently however..

D.


--
David Bateman                                [hidden email]
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

David Bateman-2
In reply to this post by Søren Hauberg
Søren Hauberg wrote:

> lør, 24 01 2009 kl. 09:40 +0100, skrev Søren Hauberg:
>  
>>> I also see that things like
>>>
>>>   help @a/a
>>>
>>> are not working now, and they did before the switch to the .m file
>>> help.
>>>      
>> I'm somewhat surprised that this no longer works. I was hoping this
>> change would have been independent of my changes.
>>    
>
> Are you sure this doesn't work? If I type
>
>   help @polynomial/polynomial
>
> in the 'examples' directory, I get the help text in question. Do you
> have an example where it fails?
>
> [a little bit later]
> Ohh, I see that
>
>   help @polynomial/polyval
>
> fails, but that also failed before. Anyway, I'll look into it...
>
> Søren
>
>
>  
Again this worked in October when I was working on the OOP stuff. Can't
say if it worked recently..

D.


--
David Bateman                                [hidden email]
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
søn, 25 01 2009 kl. 19:01 +0100, skrev David Bateman:
> Again this worked in October when I was working on the OOP stuff. Can't
> say if it worked recently..

Okay, so I got tricked by the simple fact that the only function that
actually has any documentation in the 'examples/@polynomial' directory
is indeed the 'polynomial' function. So, this did indeed work before.
But it also seems to work with the m-file implementation. The only
problem being that the error message is bad. That is, if I type

  help @polynomial/polyval

and this function doesn't have any documentation, then I get an error
message saying

  error: help: `@polynomial/polyval' not found

which is very misleading (it should just say that the function is not
documented).

Søren

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
søn, 25 01 2009 kl. 19:18 +0100, skrev Søren Hauberg:

> søn, 25 01 2009 kl. 19:01 +0100, skrev David Bateman:
> > Again this worked in October when I was working on the OOP stuff. Can't
> > say if it worked recently..
>
> Okay, so I got tricked by the simple fact that the only function that
> actually has any documentation in the 'examples/@polynomial' directory
> is indeed the 'polynomial' function. So, this did indeed work before.
> But it also seems to work with the m-file implementation. The only
> problem being that the error message is bad. That is, if I type
>
>   help @polynomial/polyval
>
> and this function doesn't have any documentation, then I get an error
> message saying
>
>   error: help: `@polynomial/polyval' not found
>
> which is very misleading (it should just say that the function is not
> documented).
Okay, the attached changeset changes the error message into saying that
the function is not documented. Now this stuff seems to work just fine
for me.

I do, however, still see one regression: I cannot do

  type @polynomial/set

which used to be possible. The problem is that

  exist ("@polynomial/set")

returns 0 which the new implementation of 'type' cannot handle. So, my
question is: should the above call to 'exist' return something else, or
should the 'type' implementation be changed such that it doesn't depend
on 'exist'?

Søren

help_undocumented_functions.changeset (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

bpabbott
Administrator

On Jan 25, 2009, at 2:00 PM, Søren Hauberg wrote:

> søn, 25 01 2009 kl. 19:18 +0100, skrev Søren Hauberg:
>> søn, 25 01 2009 kl. 19:01 +0100, skrev David Bateman:
>>> Again this worked in October when I was working on the OOP stuff.  
>>> Can't
>>> say if it worked recently..
>>
>> Okay, so I got tricked by the simple fact that the only function that
>> actually has any documentation in the 'examples/@polynomial'  
>> directory
>> is indeed the 'polynomial' function. So, this did indeed work before.
>> But it also seems to work with the m-file implementation. The only
>> problem being that the error message is bad. That is, if I type
>>
>>  help @polynomial/polyval
>>
>> and this function doesn't have any documentation, then I get an error
>> message saying
>>
>>  error: help: `@polynomial/polyval' not found
>>
>> which is very misleading (it should just say that the function is not
>> documented).
>
> Okay, the attached changeset changes the error message into saying  
> that
> the function is not documented. Now this stuff seems to work just fine
> for me.
>
> I do, however, still see one regression: I cannot do
>
>  type @polynomial/set
>
> which used to be possible. The problem is that
>
>  exist ("@polynomial/set")
>
> returns 0 which the new implementation of 'type' cannot handle. So, my
> question is: should the above call to 'exist' return something else,  
> or
> should the 'type' implementation be changed such that it doesn't  
> depend
> on 'exist'?
>
> Søren

Regarding exist ("@polynomial/set"), the commercial implementation  
gives me the result below

 >> mkdir @polynomial
 >> cd @polynomial/
 >> !echo '% empty help string' > set.m
 >> cd ..
 >> exist('@polynomial/set')
ans = 2

Ben




Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

John W. Eaton
Administrator
On 25-Jan-2009, Ben Abbott wrote:

| Regarding exist ("@polynomial/set"), the commercial implementation  
| gives me the result below
|
|  >> mkdir @polynomial
|  >> cd @polynomial/
|  >> !echo '% empty help string' > set.m
|  >> cd ..
|  >> exist('@polynomial/set')
| ans = 2

I think the following change will fix this problem.

Thanks,

jwe


# HG changeset patch
# User John W. Eaton <[hidden email]>
# Date 1233027320 18000
# Node ID 4e39b00218d305b6ecbb18703b696430095c1f78
# Parent  dacfd030633a4b6359c93418159fa80f8d381da2
load-path.cc (load_path::do_find_fcn): handle @foo/bar

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-26  John W. Eaton  <[hidden email]>
+
+ * load-path.cc (load_path::do_find_fcn): Handle @foo/bar.
+
 2009-01-24  Jaroslav Hajek  <[hidden email]>
 
  * pt-cell.cc (tree_cell::rvalue): Optimize the single row case.
diff --git a/src/load-path.cc b/src/load-path.cc
--- a/src/load-path.cc
+++ b/src/load-path.cc
@@ -903,30 +903,47 @@
   
   //  update ();
 
-  dir_name = std::string ();
+  if (fcn.length () > 0 && fcn[0] == '@')
+    {
+      size_t pos = fcn.find ('/');
 
-  const_fcn_map_iterator p = fcn_map.find (fcn);
+      if (pos != std::string::npos)
+ {
+  std::string class_name = fcn.substr (1, pos-1);
+  std::string meth = fcn.substr (pos+1);
 
-  if (p != fcn_map.end ())
+  retval = do_find_method (class_name, meth, dir_name);
+ }
+      else
+ retval = std::string ();
+    }
+  else
     {
-      const file_info_list_type& file_info_list = p->second;
+      dir_name = std::string ();
 
-      for (const_file_info_list_iterator i = file_info_list.begin ();
-   i != file_info_list.end ();
-   i++)
+      const_fcn_map_iterator p = fcn_map.find (fcn);
+
+      if (p != fcn_map.end ())
  {
-  const file_info& fi = *i;
+  const file_info_list_type& file_info_list = p->second;
 
-  retval = file_ops::concat (fi.dir_name, fcn);
+  for (const_file_info_list_iterator i = file_info_list.begin ();
+       i != file_info_list.end ();
+       i++)
+    {
+      const file_info& fi = *i;
 
-  if (check_file_type (retval, type, fi.types,
-       fcn, "load_path::do_find_fcn"))
-    {
-      dir_name = fi.dir_name;
-      break;
+      retval = file_ops::concat (fi.dir_name, fcn);
+
+      if (check_file_type (retval, type, fi.types,
+   fcn, "load_path::do_find_fcn"))
+ {
+  dir_name = fi.dir_name;
+  break;
+ }
+      else
+ retval = std::string ();
     }
-  else
-    retval = std::string ();
  }
     }
 
Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

John W. Eaton
Administrator
In reply to this post by Søren Hauberg
On 25-Jan-2009, Søren Hauberg wrote:

| søn, 25 01 2009 kl. 19:18 +0100, skrev Søren Hauberg:
| > søn, 25 01 2009 kl. 19:01 +0100, skrev David Bateman:
| > > Again this worked in October when I was working on the OOP stuff. Can't
| > > say if it worked recently..
| >
| > Okay, so I got tricked by the simple fact that the only function that
| > actually has any documentation in the 'examples/@polynomial' directory
| > is indeed the 'polynomial' function. So, this did indeed work before.
| > But it also seems to work with the m-file implementation. The only
| > problem being that the error message is bad. That is, if I type
| >
| >   help @polynomial/polyval
| >
| > and this function doesn't have any documentation, then I get an error
| > message saying
| >
| >   error: help: `@polynomial/polyval' not found
| >
| > which is very misleading (it should just say that the function is not
| > documented).
|
| Okay, the attached changeset changes the error message into saying that
| the function is not documented. Now this stuff seems to work just fine
| for me.
|
| I do, however, still see one regression: I cannot do
|
|   type @polynomial/set
|
| which used to be possible. The problem is that
|
|   exist ("@polynomial/set")
|
| returns 0 which the new implementation of 'type' cannot handle. So, my
| question is: should the above call to 'exist' return something else, or
| should the 'type' implementation be changed such that it doesn't depend
| on 'exist'?

I fixed this problem.

Please commit your change.

  # HG changeset patch
  # User sh@sh-t400

You might want to set

  [ui]
  username = Søren Hauberg <...>

in your .hgrc file so that your ID in the commit logs is meaningful.

Thanks,

jwe

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

John W. Eaton
Administrator
In reply to this post by Søren Hauberg
On 25-Jan-2009, Søren Hauberg wrote:

| lør, 24 01 2009 kl. 09:40 +0100, skrev Søren Hauberg:
| > fre, 23 01 2009 kl. 12:50 -0500, skrev John W. Eaton:
| > > 2008-08-19  David Bateman  <[hidden email]>
| > >
| > > * load-path.cc (load-path::do_find_dir (const std:string&) const)):
| > > Method to find a directory on the load-path corresponding to the
| > > argument.
| > > * load-path.h (load-path::do_find_dir (const std:string&) const),
| > > load-path::find_dir (const std::string&) const): New methods.
| > > * utils.cc (std::string contents_file_in_path (const std::string&)):
| > > New function.
| > > * utils.h  (std::string contents_file_in_path (const std::string&)):
| > > Declare it.
| > > * help.cc (static bool raw_help_from_file (const std::string&,
| > > std::string&, std::string&, bool&)): Also check is requested
| > > argument is a directory and contains the file Contents.m.
| >
| > It seems that these changes mostly work as-is. However, I think it would
| > be better to move this code directly into 'help.m'. That would IMHO make
| > the code simpler. I'm currently spending all my time on grading exams,
| > so I don't think I'll have any time to look at this till next week.
|
| Did this feature actually work before? I've tried to
|
|   mkdir delme
|    echo "## some text" > delme/Contents.m
|
| in the shell and then
|
|   addpath ("delme")
|   help delme
|
| from Octave, and it didn't work for me with a checkout from before you
| checked in my changes. Anyway, the attached changeset allows for this
| behaviour. I've implemented this in 'help.m', so the I removed some more
| code from C++.

Please commit this change.

Thanks,

jwe

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
In reply to this post by John W. Eaton
man, 26 01 2009 kl. 23:12 -0500, skrev John W. Eaton:
> Please commit your change.

Done

>   # HG changeset patch
>   # User sh@sh-t400
>
> You might want to set
>
>   [ui]
>   username = Søren Hauberg <...>
>
> in your .hgrc file so that your ID in the commit logs is meaningful.

It seems I had to call myself 'Soren' to avoid UTF errors. But, hey, I'm used to that :-)

Soren

Reply | Threaded
Open this post in threaded view
|

Re: recent changes to help functions

Søren Hauberg
In reply to this post by John W. Eaton
man, 26 01 2009 kl. 23:13 -0500, skrev John W. Eaton:
> Please commit this change.

Done

Søren