|
| 1 | +#!/usr/bin/perl |
| 2 | +# updates the news file from changelog.qgis.org |
| 3 | + |
| 4 | +# Copyright (C) 2016 Jürgen E. Fischer <jef@norbit.de> |
| 5 | + |
| 6 | +# This program is free software; you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation; either version 2 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | + |
| 11 | +use strict; |
| 12 | +use warnings; |
| 13 | +use Pod::Usage; |
| 14 | +use LWP::Simple; |
| 15 | +use File::Temp qw/tempfile/; |
| 16 | +use File::Copy qw/copy/; |
| 17 | + |
| 18 | +pod2usage(1) if @ARGV!=3; |
| 19 | + |
| 20 | +my ($major,$minor,$releasename) = @ARGV; |
| 21 | + |
| 22 | + |
| 23 | +my ($news,$tempfile) = tempfile(); |
| 24 | + |
| 25 | +open my $in, "doc/news.t2t"; |
| 26 | +while(<$in>) { |
| 27 | + print $news $_; |
| 28 | + last if /^Last Change/; |
| 29 | +} |
| 30 | + |
| 31 | +my $content = get("http://changelog.qgis.org/en/qgis/version/$major.$minor.0/gnu/" ); |
| 32 | +die "Couldn't get it!" unless defined $content; |
| 33 | + |
| 34 | +print $news "\n= What's new in Version $major.$minor '$releasename'? =\n\n"; |
| 35 | +print $news "This release has following new features:\n\n"; |
| 36 | + |
| 37 | +for $_ (split /\n/, $content) { |
| 38 | + next if /^Changelog /; |
| 39 | + next if /^------/; |
| 40 | + next if /^\s*$/; |
| 41 | + |
| 42 | + s/^"/"/g; |
| 43 | + s/^\*\s+/- /; |
| 44 | + s/ : /: /; |
| 45 | + s/\s+$//; |
| 46 | + |
| 47 | + print $news "$_\n"; |
| 48 | +} |
| 49 | + |
| 50 | +print $news "\n"; |
| 51 | + |
| 52 | +while(<$in>) { |
| 53 | + print $news $_; |
| 54 | +} |
| 55 | + |
| 56 | +close $news; |
| 57 | +close $in; |
| 58 | + |
| 59 | +copy($tempfile, "doc/news.t2t"); |
| 60 | + |
| 61 | +system "txt2tags -odoc/news.html -t html doc/news.t2t"; |
| 62 | +system "txt2tags -oNEWS -t txt doc/news.t2t"; |
| 63 | + |
| 64 | +=head1 NAME |
| 65 | +
|
| 66 | +update-news.pl - updates the news file from changelog.qgis.org |
| 67 | +
|
| 68 | +=head1 SYNOPSIS |
| 69 | +
|
| 70 | +update-news.pl major minor releasename |
| 71 | +
|
| 72 | +=cut |
0 commit comments