annotate scripts/help/doc.m @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents a4268efb7334
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
3 ## Copyright (C) 2005-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27898
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11547
diff changeset
7 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
8 ## This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23241
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23241
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
14 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
19 ##
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6615
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23241
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
25
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20727
diff changeset
27 ## @deftypefn {} {} doc @var{function_name}
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20727
diff changeset
28 ## @deftypefnx {} {} doc
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
29 ## 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: 19833
diff changeset
30 ## online version of the printed manual, using the GNU Info browser.
6615
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6344
diff changeset
31 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## If invoked without an argument, the manual is shown from the beginning.
6615
687ae48b2253 [project @ 2007-05-13 06:24:57 by jwe]
jwe
parents: 6344
diff changeset
33 ##
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## 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: 19833
diff changeset
35 ## @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: 19833
diff changeset
36 ##
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
37 ## 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: 19833
diff changeset
38 ## the command @kbd{C-h}.
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
39 ## @seealso{help}
11547
e1851653d59c Eliminate @deffn macros.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
40 ## @end deftypefn
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
41
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20158
diff changeset
42 function retval = doc (function_name)
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
43
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
44 if (nargin > 1)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
45 print_usage ();
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
46 endif
5830
0bb816a28335 [project @ 2006-05-26 19:04:08 by jwe]
jwe
parents: 5794
diff changeset
47
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
48 if (nargin == 1)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
49 if (! ischar (function_name))
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
50 error ("doc: FUNCTION_NAME must be a string");
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
51 endif
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
52 ftype = exist (function_name);
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
53 else
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
54 function_name = "";
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
55 ftype = 0;
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
56 endif
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
57
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
58 ## if GUI is running, let it display the function
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
59 if (isguirunning ())
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
60 status = ! __event_manager_show_doc__ (function_name);
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
61 else
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
62 if (ftype == 2 || ftype == 3)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
63 ffile = which (function_name);
5830
0bb816a28335 [project @ 2006-05-26 19:04:08 by jwe]
jwe
parents: 5794
diff changeset
64 else
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
65 ffile = "";
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
66 endif
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
67
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
68 if (isempty (ffile))
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
69 info_dir = __octave_config_info__ ("infodir");
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
70 else
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
71 info_dir = fileparts (ffile);
5830
0bb816a28335 [project @ 2006-05-26 19:04:08 by jwe]
jwe
parents: 5794
diff changeset
72 endif
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
73
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
74 ## Determine if a file called doc.info exist in the same
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
75 ## directory as the function.
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
76 info_file_name = fullfile (info_dir, "doc.info");
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18191
diff changeset
77
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
78 [~, err] = stat (info_file_name);
5830
0bb816a28335 [project @ 2006-05-26 19:04:08 by jwe]
jwe
parents: 5794
diff changeset
79
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
80 if (err < 0)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
81 info_file_name = info_file ();
5830
0bb816a28335 [project @ 2006-05-26 19:04:08 by jwe]
jwe
parents: 5794
diff changeset
82
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
83 if (! exist (info_file_name, "file")
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
84 && ! exist ([info_file_name ".gz"], "file")
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
85 && ! exist ([info_file_name ".bz2"], "file"))
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
86 __gripe_missing_component__ ("doc", "info-file");
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
87 endif
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
88 endif
17516
21656a949661 Add hook function to handle missing Octave components
Mike Miller <mtmiller@ieee.org>
parents: 17336
diff changeset
89
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
90 ## FIXME: Don't change the order of the arguments below because
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
91 ## the info-emacs-info script currently expects --directory DIR as
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
92 ## the third and fourth arguments. Someone should fix that.
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
93 cmd = sprintf ('"%s" --file "%s" --directory "%s"',
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
94 info_program (), info_file_name, info_dir);
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
95
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
96 have_fname = ! isempty (function_name);
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
97
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
98 if (have_fname)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
99 status = system (sprintf ('%s --index-search "%s"', cmd, function_name));
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
100 endif
6017
b124a912d28b [project @ 2006-10-02 14:58:18 by jwe]
jwe
parents: 6016
diff changeset
101
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
102 if (! (have_fname && status == 0))
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
103 status = system (cmd);
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
104 if (status == 127)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
105 warning ("doc: unable to find info program '%s'", info_program ());
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
106 endif
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
107 endif
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
108
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
109 endif
6344
860682863572 [project @ 2007-02-22 20:24:11 by jwe]
jwe
parents: 6339
diff changeset
110
23241
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
111 if (nargout > 0)
756c7a550542 doc.m: Overhaul function (bug #50423).
Rik <rik@octave.org>
parents: 23220
diff changeset
112 retval = status;
5672
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
113 endif
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
114
62734ddaf17b [project @ 2006-03-15 21:27:34 by jwe]
jwe
parents:
diff changeset
115 endfunction
8558
438520011621 Check for successful build of the documentation
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
116
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
117
21132
6586ccfc61d6 * doc.m: Make test conditional on ENABLE_DOCS.
John W. Eaton <jwe@octave.org>
parents: 20852
diff changeset
118 %!testif ENABLE_DOCS
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
119 %! ifile = info_file ();
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
120 %! 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
121 %! 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
122 %! endif