File: optim_doc.m

package info (click to toggle)
octave-optim 1.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 2,368 kB
  • sloc: cpp: 1,437; makefile: 185; perl: 169; xml: 29; sh: 3
file content (58 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## Copyright (C) 2014-2016 Olaf Till
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {} optim_doc ()
## @deftypefnx {Function File} {} optim_doc (@var{keyword})
## Show optim package documentation.
##
## Runs the info viewer Octave is configured with on the documentation
## in info format of the installed optim package. Without argument, the
## top node of the documentation is displayed. With an argument, the
## respective index entry is searched for and its node displayed.
##
## @end deftypefn

function optim_doc (keyword)

  if ((nargs = nargin ()) > 1)
    print_usage ()
  endif

  ## locate installed documentation
  persistent infopath = "/usr/share/info/octave-optim.info.gz";

  ## display info
  INFO = info_program ();

  if (nargs)
    error_hint = ", maybe the keyword was not found in the index";
    status = system (sprintf ("%s %s --index-search \"%s\"",
                              INFO, infopath, keyword));
  else
    error_hint = "";
    status = system (sprintf ("%s %s", INFO, infopath));
  endif

  if (status)
    if (status == 127)
      error ("unable to find info program `%s'", INFO);
    else
      error ("info program `%s' returned error code %i%s",
             INFO, status, error_hint);
    endif
  endif

endfunction