Mercurial > hg > octave-lyh
annotate scripts/help/doc.m @ 8874:bd1b1fe9c6e9 ss-3-1-53
bump version info for snapshot
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 25 Feb 2009 18:35:47 -0500 |
parents | 5dd06f19e9be |
children | c0cef1436788 |
rev | line source |
---|---|
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8558
diff
changeset
|
1 ## Copyright (C) 2005, 2006, 2007, 2009 S�ren Hauberg |
5672 | 2 ## |
7016 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
5672 | 15 ## You should have received a copy of the GNU General Public License |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5672 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Command} doc @var{function_name} | |
6615 | 21 ## Display documentation for the function @var{function_name} |
22 ## directly from an on-line version of | |
23 ## the printed manual, using the GNU Info browser. If invoked without | |
24 ## any arguments, the manual is shown from the beginning. | |
25 ## | |
26 ## For example, the command @kbd{doc rand} starts the GNU Info browser | |
27 ## at this node in the on-line version of the manual. | |
28 ## | |
29 ## Once the GNU Info browser is running, help for using it is available | |
30 ## using the command @kbd{C-h}. | |
5672 | 31 ## @seealso{help} |
32 ## @end deftypefn | |
33 | |
34 ## Author: Soren Hauberg <soren@hauberg.org> | |
35 ## Adapted-by: jwe | |
36 | |
37 function retval = doc (fname) | |
38 | |
5830 | 39 if (nargin == 0 || nargin == 1) |
40 | |
41 ftype = 0; | |
42 | |
43 if (nargin == 1) | |
44 ## Get the directory where the function lives. | |
45 ## FIXME -- maybe we should have a better way of doing this. | |
5672 | 46 |
5830 | 47 if (ischar (fname)) |
48 ftype = exist (fname); | |
49 else | |
50 error ("doc: expecting argument to be a character string"); | |
51 endif | |
52 else | |
53 fname = ""; | |
54 endif | |
5672 | 55 |
5830 | 56 if (ftype == 2 || ftype == 3) |
6339 | 57 ffile = which (fname); |
5830 | 58 else |
59 ffile = ""; | |
60 endif | |
61 | |
62 if (isempty (ffile)) | |
63 info_dir = octave_config_info ("infodir"); | |
64 else | |
65 info_dir = fileparts (ffile); | |
66 endif | |
5672 | 67 |
5830 | 68 ## Determine if a file called doc.info exist in the same |
69 ## directory as the function. | |
70 | |
71 info_file_name = fullfile (info_dir, "doc.info"); | |
72 | |
73 [stat_info, err] = stat (info_file_name); | |
74 | |
75 if (err < 0) | |
76 info_file_name = info_file (); | |
77 endif | |
78 | |
6017 | 79 ## FIXME -- don't change the order of the arguments below because |
80 ## the info-emacs-info script currently expects --directory DIR as | |
81 ## the third and fourth arguments. Someone should fix that. | |
82 | |
83 cmd = sprintf ("\"%s\" --file \"%s\" --directory \"%s\"", | |
84 info_program (), info_file_name, info_dir); | |
5672 | 85 |
6344 | 86 have_fname = ! isempty (fname); |
87 | |
88 if (have_fname) | |
89 status = system (sprintf ("%s --index-search %s", cmd, fname)); | |
5830 | 90 endif |
91 | |
6344 | 92 if (! (have_fname && status == 0)) |
93 status = system (cmd); | |
94 if (status == 127) | |
95 warning ("unable to find info program `%s'", info_program ()); | |
96 endif | |
5830 | 97 endif |
98 | |
99 if (nargout > 0) | |
100 retval = status; | |
101 endif | |
102 | |
5672 | 103 else |
5830 | 104 print_usage (); |
5672 | 105 endif |
106 | |
107 endfunction | |
8558
438520011621
Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
108 |
438520011621
Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
109 %!test if exist( info_file ()) != 2 |
438520011621
Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
110 %! error ("Info file %s does not exist!", info_file ()); |
438520011621
Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
111 %! endif |