Skip to content

Commit d546c31

Browse files
committed
warn: Reorganize messages object, should make it more clear to maintain
Setting it up this way means there is even more of a difference between the scaled levels (level2, level4im, etc.) and singlenotice/singlewarning/custom, but doing so should make it very straightforward to remove or add templates (pursuant to any discussion in #533). The only change to the enduser is that this will now generate a submenu category for every grouping, even if there are no templates in that group at that level. At the moment, this is only the `4im` level for the "Removal of deletion tags" category. I'm not sure this is a bad thing. One header was mistmatched ('other editors' versus 'other users'), resolves that.
1 parent f11d797 commit d546c31

File tree

2 files changed

+688
-611
lines changed

2 files changed

+688
-611
lines changed

modules/procjson.pl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env perl
2+
# procjson.pl by Amory Meltzer
3+
4+
use strict;
5+
use warnings;
6+
use diagnostics;
7+
8+
my (%store,%catL);
9+
my @cats;
10+
my @levels = qw(1 2 3 4 4im);
11+
my ($uw, $lvl, $lt) = (q{},q{},0);
12+
my $cat = q{};
13+
14+
open my $in, '<', "$ARGV[0]" or die $1;
15+
while (my $l = <$in>) {
16+
chomp $l;
17+
if ($l =~ /^\t\t\t"(uw-.+)(\d(?:im)?)": \{/) { # Level template
18+
($uw,$lvl,$lt) = ($1,$2,$.);
19+
push @{$catL{$cat}}, $uw;
20+
} elsif ($l =~ /^\t\t"(.+)": \{/) { # Category
21+
$cat = $1;
22+
push @cats, $cat;
23+
} elsif ($. == $lt+1) { # label
24+
$store{$cat}{$uw}{$lvl}{label} = $l;
25+
} elsif ($. == $lt+2) { # summary
26+
$store{$cat}{$uw}{$lvl}{summary} = $l;
27+
}
28+
}
29+
close $in or die $1;
30+
31+
# use Data::Dumper;
32+
# print Dumper(%store);
33+
34+
# Uniqify
35+
my %seen;
36+
@cats = grep !$seen{$_}++, @cats;
37+
38+
# process outfile
39+
open my $out, '>', 'out.json' or die $1;
40+
print $out "\tlevels: {\n";
41+
foreach my $group (@cats) {
42+
print $out "\t\t\"$group\": {\n";
43+
# Uniqify
44+
my %seen2;
45+
@{$catL{$group}} = grep !$seen{$_}++, @{$catL{$group}};
46+
foreach my $temp (@{$catL{$group}}) {
47+
print $out "\t\t\t\"$temp\": {\n";
48+
foreach my $level (@levels) {
49+
if ($store{$group}{$temp}{$level}) {
50+
print $out "\t\t\t\tlevel$level: {\n";
51+
print $out "\t$store{$group}{$temp}{$level}{label}\n";
52+
print $out "\t$store{$group}{$temp}{$level}{summary}\n";
53+
print $out "\t\t\t\t},\n";
54+
}
55+
}
56+
print $out "\t\t\t},\n";
57+
}
58+
print $out "\t\t},";
59+
}
60+
print $out '},\n';
61+
close $out or die $1;

0 commit comments

Comments
 (0)