-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathissuegen.pl
134 lines (112 loc) · 3.42 KB
/
issuegen.pl
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/perl
# Color coding
# Note statuses will get lowercased before lookup
%statusStyle = (
'accepted' => 'a',
'retracted' => 'a',
'rejected' => 'r',
'objection' => 'fo',
'deferred' => 'd',
'invalid' => 'oi',
'outofscope' => 'oi',
);
# Header template is at the end of the file
################################################################################
my $inFile = $ARGV[0];
if (!$inFile) {
print "\nPass in issues list filename for processing!\n\n";
print "~~~~~~~~~~~~~~~~~~~~~ Template for issues-list.txt ~~~~~~~~~~~~~~~~~~~~~\n";
print <<XXX;
Draft: http://www.w3.org/TR/2013/WD-css-text-decor-3-20130103/
Title: CSS Text Decoration Level 3
... anything else you want here, except 4 dashes ...
----
Issue 1.
Summary: [summary]
From: [name]
Comment: [url]
Response: [url]
Closed: [status ... or replace this "Closed" line with "Open"]
Verified: [url]
----
XXX
exit;
}
# Input/Output setup
my $outFile = $inFile;
$outFile =~ s/\.txt/\.html/;
open IN, "<", $inFile || die "Cannot open $inFile: $!";
open OUT, ">", $outFile || die "Cannot open $outFile: $!";
$/ = "----\n";
# Header
&header;
# Issues
while (<IN>) {
chomp;
# Issue number
s/Issue (\d+)\./Issue \1. <a href="#issue-\1">#<\/a>/;
$index = $1;
# Color coding
$code = '';
if (/\nVerified:\s+http/) {
$code = 'a';
}
elsif (/\n(?:Closed|Open):\s+(\S+)/) {
$code = $statusStyle{lc $1};
}
if (/\nOpen/) {
$code .= ' ' if $code;
$code .= 'open';
}
# And print it
print OUT "<pre class='$code' id='issue-$index'>\n";
s/(http\S+)/<a href="\1">\1<\/a>/g;
print OUT;
print OUT "</pre>\n";
}
sub header {
# Read header
local $_ = <IN>;
chomp;
# Extract title and URL
my $title, $url;
for (split /\n+/) {
$title = $1 if (/^Title:\s+(.+)$/);
$url = $1 if (/^Draft:\s+(\S+)/);
}
die "Error: missing document URL or title.\n" unless ($url && $title);
# Process URL to get status, date, shorname
die "Error: Draft URL wrong format.\n" unless
($url =~ /([A-Z]{2})-([a-z0-9-]+)-(\d{8})/);
($status, $shortname, $date) = ($1, $2, $3);
$status = 'LCWD' if ('WD' eq $status && $inFile =~ /[lL][cC]/);
$date = "$1-$2-$3" if ($date =~ /(\d{4})(\d{2})(\d{2})/);
# Print it all out
print OUT <<XXX;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>$title Disposition of Comments for $date $status</title>
<style type="text/css">
.a { background: lightgreen }
.d { background: lightblue }
.r { background: orange }
.fo { background: red }
.open { border: solid red; padding: 0.2em; }
:target { box-shadow: 0.25em 0.25em 0.25em; }
</style>
<h1>$title Disposition of Comments for $date $status</h1>
<p>Last call document: <a href="$url">$url</a>
<p>Editor's draft: <a href="http://dev.w3.org/csswg/$shortname/">http://dev.w3.org/csswg/$shortname/</a>
<p>The following color coding convention is used for comments:</p>
<ul>
<li class="a">Accepted or Rejected and positive response
<li class="r">Rejected and no response
<li class="fo">Rejected and negative response
<li class="d">Deferred
<li class="oi">Out-of-Scope or Invalid and not verified
</ul>
<p class=open>Open issues are marked like this</p>
<p>An issue can be closed as <code>Accepted</code>, <code>OutOfScope</code>,
<code>Invalid</code>, <code>Rejected</code>, or <code>Retracted</code>.
<code>Verified</code> indicates commentor's acceptance of the response.</p>
XXX
}