File: doc_control.m

package info (click to toggle)
octave-control 4.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,924 kB
  • sloc: fortran: 122,524; cpp: 6,954; objc: 210; makefile: 40; xml: 33; sh: 3
file content (95 lines) | stat: -rw-r--r-- 2,527 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
## Copyright (C) 2023-2024 Torsten Lilge
##
## This file is part of the Control package for GNU Octave
##
## This 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 software 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 the Control package. If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {} doc_control @var{fcn1} @var{fcn2}  ...
## @deftypefnx {} {@var{st} =} doc_control (@var{fcn1}, @var{fcn2},  ...)
##
## Open online documentation of the Control package in the system's
## standard browser.
##
## @strong{Inputs}
## @table @var
## @item fcn1, fcn2, ...
## Function names for which the documentation should be displayed.
## If no function name is given, the index of the documentation is shown.
## If one of the function names is 'license', copyright and license
## information are displayed.
## @end table
##
## @strong{Outputs}
## @table @var
## @item st
## The return value @var{st} has one of the values:
## @itemize @bullet
## @item
## @samp{0} Found and opened system browser successfully.
## @item
## @samp{1} System browser not found.
## @item
## @samp{2} System browser found, but an error occurred.
## @end itemize
## @end table
##
## @end deftypefn

## Author: Torsten Lilge <ttl-octave@mailbox.org>
## Created: December 2023
## Version: 0.1

function st = doc_control (varargin)

  base = 'https://gnu-octave.github.io/pkg-control/';
  license = 'https://github.com/gnu-octave/pkg-control/blob/main/COPYING';

  status = 0;

  if nargin == 0

    status = web (base);

  else

    for i = 1:nargin

      if ischar (varargin{i})
        fcn = strtrim (varargin{i});
        if (strcmp (fcn, 'license'))
          url = license;
        else
          url = [base, strrep(fcn, '/', '_'), '.html'];
        endif
        sti = web (url);
        if sti > 1
          status = sti;
          break;
        elseif status == 0
          status = sti;
        endif
      else
        error ("argument %d is not a string\n", i);
      endif

    endfor

  endif

  if nargout > 0
    st = status;
  endif

endfunction