Skip to content

Commit dde975c

Browse files
committed
CLDR-16560 CheckCLDR UI for non-path checks
- add a new 'supplemental' report that simply lists the overall errors - update Chart API to take testbundle and subtype mapper
1 parent 277e98c commit dde975c

File tree

8 files changed

+137
-3
lines changed

8 files changed

+137
-3
lines changed

tools/cldr-apps/js/src/esm/cldrText.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ const strings = {
495495
special_r_datetime: "Datetime",
496496
special_r_zones: "Zones",
497497
special_r_personnames: "Person Names",
498+
special_r_supplemental: "Entire Locale Errors",
498499
special_recent_activity: "Recent Activity",
499500
special_retry: "Retry",
500501
special_retry_inplace: "Retry",

tools/cldr-apps/src/main/java/org/unicode/cldr/web/SubtypeToURLMap.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
import org.jsoup.Jsoup;
3535
import org.jsoup.nodes.Document;
3636
import org.unicode.cldr.test.CheckCLDR.CheckStatus.Subtype;
37+
import org.unicode.cldr.test.CheckCLDR.SubtypeToURLProvider;
3738
import org.unicode.cldr.util.CLDRCacheDir;
3839
import org.unicode.cldr.util.CLDRTool;
3940

4041
@CLDRTool(
4142
alias = "subtype-to-url-map",
4243
description = "parse each of the params as a path or URL to a subtype map and check.")
43-
public class SubtypeToURLMap {
44+
public class SubtypeToURLMap implements SubtypeToURLProvider {
4445
static final Logger logger = SurveyLog.forClass(SubtypeToURLMap.class);
4546
/**
4647
* Little tool for validating input data.
@@ -510,4 +511,8 @@ public static String forSubtype(Subtype subtype) {
510511
public static SubtypeToURLMap reload() {
511512
return (SubtypeToURLMapHelper.INSTANCE = SubtypeToURLMapHelper.make());
512513
}
514+
@Override
515+
public String apply(Subtype t) {
516+
return forSubtype(t);
517+
}
513518
}

tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/ReportAPI.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
import org.unicode.cldr.util.VoterReportStatus.ReportAcceptability;
3333
import org.unicode.cldr.util.VoterReportStatus.ReportId;
3434
import org.unicode.cldr.web.CookieSession;
35+
import org.unicode.cldr.web.DataPage;
3536
import org.unicode.cldr.web.ReportsDB;
3637
import org.unicode.cldr.web.ReportsDB.UserReport;
3738
import org.unicode.cldr.web.STFactory;
39+
import org.unicode.cldr.web.SubtypeToURLMap;
3840
import org.unicode.cldr.web.SurveyAjax;
3941
import org.unicode.cldr.web.SurveyMain;
4042
import org.unicode.cldr.web.UserRegistry;
@@ -414,10 +416,14 @@ public Response getReportOutput(
414416

415417
private String writeReport(ReportId report, CLDRLocale loc) throws IOException {
416418
final Writer w = new StringWriter();
419+
final STFactory stf = CookieSession.sm.getSTFactory();
417420
final Chart chart = Chart.forReport(report, loc.getBaseName());
418421
if (chart != null) {
419-
final STFactory stf = CookieSession.sm.getSTFactory();
420-
chart.writeContents(w, stf);
422+
chart.writeContents(
423+
w,
424+
stf,
425+
stf.getTestResult(loc, DataPage.getSimpleOptions(loc)),
426+
SubtypeToURLMap.getInstance());
421427
} else {
422428
switch (report) {
423429
// "Old Three" reports

tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424
import java.util.Set;
2525
import java.util.TreeSet;
26+
import java.util.function.Function;
2627
import java.util.logging.Logger;
2728
import java.util.regex.Matcher;
2829
import java.util.regex.Pattern;
@@ -784,6 +785,12 @@ protected boolean accept(List<CheckStatus> result) {
784785

785786
Options cachedOptions = null;
786787

788+
/**
789+
* abstract interface for mapping from a Subtype to a "more details" URL. see
790+
* org.unicode.cldr.web.SubtypeToURLMap
791+
*/
792+
public interface SubtypeToURLProvider extends Function<Subtype, String> {}
793+
787794
/** Status value returned from check */
788795
public static class CheckStatus implements Comparable<CheckStatus> {
789796
public static final Type alertType = Type.Comment,

tools/cldr-code/src/main/java/org/unicode/cldr/tool/Chart.java

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.io.Writer;
1010
import java.util.Arrays;
1111
import java.util.stream.Collectors;
12+
import org.unicode.cldr.test.CheckCLDR;
13+
import org.unicode.cldr.test.TestCache.TestResultBundle;
1214
import org.unicode.cldr.tool.FormattedFileWriter.Anchors;
1315
import org.unicode.cldr.util.CLDRConfig;
1416
import org.unicode.cldr.util.CLDRFile;
@@ -158,6 +160,18 @@ public void writeContents(Writer pw, Factory factory) throws IOException {
158160
throw new IllegalArgumentException("Not implemented yet");
159161
}
160162

163+
/**
164+
* extended function with some additional parameters subclasses may optionally implement this.
165+
*/
166+
public void writeContents(
167+
Writer pw,
168+
Factory factory,
169+
TestResultBundle bundle,
170+
CheckCLDR.SubtypeToURLProvider urlProvider)
171+
throws IOException {
172+
this.writeContents(pw, factory);
173+
}
174+
161175
private static final class AnalyticsHelper {
162176
private static final AnalyticsHelper INSTANCE = new AnalyticsHelper();
163177

@@ -220,6 +234,8 @@ public static Chart forReport(final ReportId report, final String locale) {
220234
switch (report) {
221235
case personnames:
222236
return new ChartPersonName(locale);
237+
case supplemental:
238+
return new ChartSupplemental(locale);
223239
default:
224240
return null;
225241
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package org.unicode.cldr.tool;
2+
3+
import java.io.IOException;
4+
import java.io.Writer;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.Set;
8+
import java.util.TreeSet;
9+
import org.unicode.cldr.test.CheckCLDR.CheckStatus;
10+
import org.unicode.cldr.test.CheckCLDR.SubtypeToURLProvider;
11+
import org.unicode.cldr.test.TestCache.TestResultBundle;
12+
import org.unicode.cldr.util.CLDRConfig;
13+
import org.unicode.cldr.util.CLDRFile;
14+
import org.unicode.cldr.util.CLDRPaths;
15+
import org.unicode.cldr.util.Factory;
16+
17+
public class ChartSupplemental extends Chart {
18+
private static final CLDRConfig CLDR_CONFIG = CLDRConfig.getInstance();
19+
static final CLDRFile ENGLISH = CLDR_CONFIG.getEnglish();
20+
static final String DIR = CLDRPaths.CHART_DIRECTORY + "verify/supplemental/";
21+
22+
private final String locale;
23+
24+
public ChartSupplemental(String locale) {
25+
super();
26+
this.locale = locale;
27+
}
28+
29+
@Override
30+
public String getDirectory() {
31+
return DIR;
32+
}
33+
34+
@Override
35+
public String getTitle() {
36+
return ENGLISH.getName(locale) + ": Overall Errors";
37+
}
38+
39+
@Override
40+
public String getExplanation() {
41+
return "<p>This chart shows errors which apply to the entire locale.</p>";
42+
}
43+
44+
@Override
45+
public String getFileName() {
46+
return locale;
47+
}
48+
49+
@Override
50+
public void writeContents(
51+
Writer pw, Factory factory, TestResultBundle test, SubtypeToURLProvider urlProvider)
52+
throws IOException {
53+
CLDRFile cldrFile = factory.make(locale, true);
54+
55+
if (test != null) {
56+
Set<CheckStatus> pp = new TreeSet<CheckStatus>();
57+
58+
// add any 'early' errors
59+
pp.addAll(test.getPossibleProblems());
60+
61+
// add all non-path status
62+
for (final String x : cldrFile) {
63+
List<CheckStatus> result = new ArrayList<CheckStatus>();
64+
test.check(x, result, cldrFile.getStringValue(x));
65+
for (final CheckStatus s : result) {
66+
if (s.isEntireLocale()) pp.add(s);
67+
}
68+
}
69+
70+
// report
71+
72+
if (pp.isEmpty()) {
73+
pw.write("<h3>No Errors</h3>\n");
74+
pw.write("There are no overall locale issues to report");
75+
} else {
76+
pw.write("<h3>Overall Errors</h3>\n");
77+
pw.write("<ol>\n");
78+
for (final CheckStatus s : pp) {
79+
pw.write(
80+
String.format(
81+
"<li> <b>%s</b> <i title='%s'>%s</i>\n",
82+
s.getType(), s.getSubtype().name(), s.getSubtype()));
83+
pw.write("<p>" + s.getMessage() + "</p>");
84+
if (urlProvider != null) {
85+
final String moreDetailsUrl = urlProvider.apply(s.getSubtype());
86+
pw.write(String.format("<a href=\"%s\">more details</a>", moreDetailsUrl));
87+
}
88+
pw.write("</li>\n");
89+
}
90+
pw.write("</ol>\n\n");
91+
}
92+
}
93+
94+
pw.write("</div> <!-- ReportSupplemental -->\n");
95+
}
96+
}

tools/cldr-code/src/main/java/org/unicode/cldr/util/VettingViewer.java

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ public Status getErrorStatus(
197197
StringBuilder errorMessage = new StringBuilder();
198198
factory.getTestCache().getBundle(options).check(path, result, value);
199199
for (CheckStatus checkStatus : result) {
200+
if (checkStatus.isEntireLocale())
201+
continue; // these will show up in the Entire Locale (supplemental) report
200202
final CheckCLDR cause = checkStatus.getCause();
201203
/*
202204
* CheckCoverage will be shown under Missing, not under Warnings; and

tools/cldr-code/src/main/java/org/unicode/cldr/util/VoterReportStatus.java

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class VoterReportStatus<T> {
2121
* 'Person Names' Also see {@link org.unicode.cldr.tool.Chart#forReport(ReportId, String)}
2222
*/
2323
public enum ReportId {
24+
supplemental, // non-Chart (Entire Locale)
2425
datetime, // non-Chart
2526
zones, // non-Chart
2627
compact, // non-Chart, aka 'numbers'

0 commit comments

Comments
 (0)