Mercurial > octave-nkf
annotate scripts/help/doc.m @ 20595:c1a6c31ac29a
eliminate more simple uses of error_state
* ov-classdef.cc: Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Oct 2015 00:20:02 -0400 |
parents | 7503499a252b |
children |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
1 ## Copyright (C) 2005-2015 Søren Hauberg |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11547
diff
changeset
|
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 -*- | |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
20 ## @deftypefn {Command} {} doc @var{function_name} |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
21 ## @deftypefnx {Command} {} doc |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
22 ## Display documentation for the function @var{function_name} directly from an |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
23 ## online version of the printed manual, using the GNU Info browser. |
6615 | 24 ## |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
25 ## If invoked without an argument, the manual is shown from the beginning. |
6615 | 26 ## |
20193
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
27 ## For example, the command @kbd{doc rand} starts the GNU Info browser at the |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
28 ## @code{rand} node in the online version of the manual. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
29 ## |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
30 ## Once the GNU Info browser is running, help for using it is available using |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19867
diff
changeset
|
31 ## the command @kbd{C-h}. |
5672 | 32 ## @seealso{help} |
11547 | 33 ## @end deftypefn |
5672 | 34 |
35 ## Author: Soren Hauberg <soren@hauberg.org> | |
36 ## Adapted-by: jwe | |
37 | |
38 function retval = doc (fname) | |
39 | |
5830 | 40 if (nargin == 0 || nargin == 1) |
41 | |
42 ftype = 0; | |
43 | |
44 if (nargin == 1) | |
45 ## Get the directory where the function lives. | |
18891
7bbe3658c5ef
maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents:
18190
diff
changeset
|
46 ## FIXME: Maybe we should have a better way of doing this? |
5672 | 47 |
5830 | 48 if (ischar (fname)) |
10549 | 49 ftype = exist (fname); |
5830 | 50 else |
10549 | 51 error ("doc: expecting argument to be a character string"); |
5830 | 52 endif |
53 else | |
54 fname = ""; | |
55 endif | |
5672 | 56 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
57 ## if GUI is running, let it display the function |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
58 if (isguirunning ()) |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
59 __octave_link_show_doc__ (fname); |
5830 | 60 else |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18190
diff
changeset
|
61 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
62 if (ftype == 2 || ftype == 3) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
63 ffile = which (fname); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
64 else |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
65 ffile = ""; |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
66 endif |
5830 | 67 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
68 if (isempty (ffile)) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
69 info_dir = octave_config_info ("infodir"); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
70 else |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
71 info_dir = fileparts (ffile); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
72 endif |
5830 | 73 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
74 ## Determine if a file called doc.info exist in the same |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
75 ## directory as the function. |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
76 |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
77 info_file_name = fullfile (info_dir, "doc.info"); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
78 |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
79 [stat_info, err] = stat (info_file_name); |
5830 | 80 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
81 if (err < 0) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
82 info_file_name = info_file (); |
17516
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17336
diff
changeset
|
83 |
18190
ab775508dff9
doc.m: Check for existence of compressed info file (bug #41054)
Mike Miller <mtmiller@ieee.org>
parents:
17744
diff
changeset
|
84 if (! exist (info_file_name, "file") |
19339
e433efa383e4
doc.m: Add support for info files in bzip format (bug #43526).
Rik <rik@octave.org>
parents:
18891
diff
changeset
|
85 && ! exist ([info_file_name ".gz"], "file") |
e433efa383e4
doc.m: Add support for info files in bzip format (bug #43526).
Rik <rik@octave.org>
parents:
18891
diff
changeset
|
86 && ! exist ([info_file_name ".bz2"], "file")) |
17516
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17336
diff
changeset
|
87 __gripe_missing_component__ ("doc", "info-file"); |
21656a949661
Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents:
17336
diff
changeset
|
88 endif |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
89 endif |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
90 |
18891
7bbe3658c5ef
maint: Use "FIXME:" coding convention in m-files.
Rik <rik@octave.org>
parents:
18190
diff
changeset
|
91 ## FIXME: Don't change the order of the arguments below because |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
92 ## the info-emacs-info script currently expects --directory DIR as |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
93 ## the third and fourth arguments. Someone should fix that. |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
94 |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
95 cmd = sprintf ("\"%s\" --file \"%s\" --directory \"%s\"", |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
96 info_program (), info_file_name, info_dir); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
97 |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
98 have_fname = ! isempty (fname); |
6017 | 99 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
100 if (have_fname) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
101 status = system (sprintf ("%s --index-search \"%s\"", cmd, fname)); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
102 endif |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18190
diff
changeset
|
103 |
5672 | 104 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
105 if (! (have_fname && status == 0)) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
106 status = system (cmd); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
107 if (status == 127) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
108 warning ("unable to find info program '%s'", info_program ()); |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
109 endif |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
110 endif |
6344 | 111 |
17029
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
112 if (nargout > 0) |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
113 retval = status; |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
114 endif |
359c5ca795cd
Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents:
15545
diff
changeset
|
115 |
5830 | 116 endif |
5672 | 117 else |
5830 | 118 print_usage (); |
5672 | 119 endif |
120 | |
121 endfunction | |
8558
438520011621
Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
122 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
123 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
124 %!test |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
125 %! ifile = info_file (); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
126 %! if (exist (ifile) != 2 && exist (sprintf ("%s.gz", ifile)) != 2) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
127 %! error ("Info file %s or %s.gz does not exist!", ifile, ifile); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
128 %! endif |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
129 |