annotate scripts/miscellaneous/news.m @ 13863:b81e0b3fedab

news: support to read news of installed packages
author Carnë Draug <carandraug+dev@gmail.com>
date Thu, 03 Nov 2011 12:11:31 +0000
parents e51ad94535b9
children a03e96aa4977
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
1 ## Copyright (C) 2007-2011 John W. Eaton
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
2 ##
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
4 ##
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6252
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6252
diff changeset
8 ## your option) any later version.
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
9 ##
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
14 ##
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
15 ## 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: 6252
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6252
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
18
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
13863
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
20 ## @deftypefn {Function File} {} news (@var{package})
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
21 ## Display the current NEWS file for Octave or installed package.
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
22 ##
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
23 ## If @var{package} is the name of an installed package, display the current
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
24 ## NEWS file for that package.
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
25 ## @end deftypefn
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
26
13863
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
27 function news (package)
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
28
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
29 ## also let users specify 'octave'
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
30 if (nargin == 0 || (nargin == 1 && ischar (package) && strcmpi (package, "octave")))
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
31 octetcdir = octave_config_info ("octetcdir");
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
32 newsfile = fullfile (octetcdir, "NEWS");
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
33
13863
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
34 elseif (nargin == 1 && ischar (package))
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
35 installed = pkg ("list");
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
36 names = cellfun (@(x) x.name, installed, "UniformOutput", false);
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
37 ## we are nice and let the user use any case on the package name
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
38 pos = strcmpi (names, package);
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
39 if (!any (pos))
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
40 error ("Package '%s' is not installed.", package);
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
41 endif
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
42 newsfile = fullfile (installed{pos}.dir, "doc", "NEWS");
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
43
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
44 else
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
45 print_usage;
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
46 endif
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
47
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
48 if (exist (newsfile, "file"))
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
49 f = fopen (newsfile, "r");
7769
247828ad21e2 Replace deprecated isstr() call
Thomas Weber <thomas.weber.mail@gmail.com>
parents: 7016
diff changeset
50 while (ischar (line = fgets (f)))
8688
d7306ecd077a news.m: use puts, not printf
John W. Eaton <jwe@octave.org>
parents: 7769
diff changeset
51 puts (line);
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
52 endwhile
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
53 else
13863
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
54 if (package)
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
55 error ("news: unable to locate NEWS file of %s package", package);
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
56 else
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
57 error ("news: unable to locate NEWS file");
b81e0b3fedab news: support to read news of installed packages
Carnë Draug <carandraug+dev@gmail.com>
parents: 12844
diff changeset
58 endif
6252
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
59 endif
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
60
738c97e101eb [project @ 2007-01-24 19:58:46 by jwe]
jwe
parents:
diff changeset
61 endfunction
12844
e51ad94535b9 codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
62
e51ad94535b9 codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
63 ## Remove from test statistics. No real tests possible
e51ad94535b9 codesprint: Remove news.m from test statistics.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
64 %!assert (1)