Skip to content

Commit c597c8e

Browse files
authored
Merge 79736b4 into c84eaa4
2 parents c84eaa4 + 79736b4 commit c597c8e

File tree

3 files changed

+177
-166
lines changed

3 files changed

+177
-166
lines changed

main/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies {
4646
implementation 'com.univocity:univocity-parsers:2.9.0'
4747
implementation 'com.google.geometry:s2-geometry:2.0.0'
4848
implementation 'org.thymeleaf:thymeleaf:3.0.15.RELEASE'
49+
implementation 'com.vladsch.flexmark:flexmark-all:0.64.8'
4950
implementation 'io.github.classgraph:classgraph:4.8.146'
5051
testImplementation group: 'junit', name: 'junit', version: '4.13'
5152
testImplementation 'com.google.truth:truth:1.0.1'

main/src/main/java/org/mobilitydata/gtfsvalidator/report/model/NoticeView.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
package org.mobilitydata.gtfsvalidator.report.model;
22

33
import com.google.gson.JsonObject;
4+
import com.vladsch.flexmark.html.HtmlRenderer;
5+
import com.vladsch.flexmark.parser.Parser;
6+
import com.vladsch.flexmark.util.ast.Document;
47
import java.util.ArrayList;
58
import java.util.List;
69
import org.mobilitydata.gtfsvalidator.notice.Notice;
10+
import org.mobilitydata.gtfsvalidator.notice.NoticeDocComments;
711
import org.mobilitydata.gtfsvalidator.notice.SeverityLevel;
12+
import org.mobilitydata.gtfsvalidator.notice.schema.NoticeSchemaGenerator;
813

914
/** NoticeView is a wrapper class to display a Notice. */
1015
public class NoticeView {
1116
private final Notice notice;
1217
private final JsonObject json;
1318
private final List<String> fields;
19+
private final NoticeDocComments comments;
1420

1521
public NoticeView(Notice notice) {
1622
this.notice = notice;
1723
this.json = notice.getContext().getAsJsonObject();
1824
this.fields = new ArrayList<>(json.keySet());
25+
this.comments = NoticeSchemaGenerator.loadComments(notice.getClass());
1926
}
2027

2128
/**
@@ -55,6 +62,28 @@ public SeverityLevel getSeverityLevel() {
5562
return notice.getSeverityLevel();
5663
}
5764

65+
/**
66+
* Returns the description text for the notice.
67+
*
68+
* @return description text
69+
*/
70+
public String getCommentForField(String field) {
71+
return comments.getFieldComment(field);
72+
}
73+
/**
74+
* Returns the description text for the notice.
75+
*
76+
* @return description text
77+
*/
78+
public String getDescription() {
79+
String markdown = this.comments.getDocComment();
80+
81+
Parser parser = Parser.builder().build();
82+
Document document = parser.parse(markdown == null ? "" : markdown);
83+
HtmlRenderer renderer = HtmlRenderer.builder().build();
84+
return renderer.render(document);
85+
}
86+
5887
/**
5988
* Returns a descriptive type-specific name for this notice class simple name.
6089
*

0 commit comments

Comments
 (0)