diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-05-16 00:24:01 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-05-29 21:03:03 +0200 |
commit | cda44bb654ccdc8fc44ee3e0efa7eb0079c71d42 (patch) | |
tree | 20aff181d6649cec7e8386bd51138cb12499ebdd /src/website/lombok | |
parent | 99f373c7e2bd270ef2eb6ecc8037a238635582ab (diff) | |
download | lombok-cda44bb654ccdc8fc44ee3e0efa7eb0079c71d42.tar.gz lombok-cda44bb654ccdc8fc44ee3e0efa7eb0079c71d42.tar.bz2 lombok-cda44bb654ccdc8fc44ee3e0efa7eb0079c71d42.zip |
Website maker updated to fix the changelog and do a proper job at supporting all-versions.
Diffstat (limited to 'src/website/lombok')
-rw-r--r-- | src/website/lombok/website/CompileChangelog.java | 45 | ||||
-rw-r--r-- | src/website/lombok/website/WebsiteMaker.java | 8 |
2 files changed, 44 insertions, 9 deletions
diff --git a/src/website/lombok/website/CompileChangelog.java b/src/website/lombok/website/CompileChangelog.java index 276842be..b1ef53c0 100644 --- a/src/website/lombok/website/CompileChangelog.java +++ b/src/website/lombok/website/CompileChangelog.java @@ -1,8 +1,10 @@ package lombok.website; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -35,7 +37,7 @@ public class CompileChangelog { } else if (latest) { result = buildLatest(sectionByVersion(markdown, version)); } else { - result = build(markdown); + result = markdownToHtml(markdown); } FileOutputStream file = new FileOutputStream(fileOut); @@ -48,20 +50,55 @@ public class CompileChangelog { } } - private static String build(String markdown) { + public static String getHtmlForEdge(File root, String edgeVersion) throws IOException { + File f = new File(root, "doc/changelog.markdown"); + String raw = readFile(f); + return buildEdge(sectionByVersion(raw, edgeVersion)); + } + + public static String getHtmlForLatest(File root, String latestVersion) throws IOException { + File f = new File(root, "doc/changelog.markdown"); + String raw = readFile(f); + return buildLatest(sectionByVersion(raw, latestVersion)); + } + + public static String getHtml(File root) throws IOException { + File f = new File(root, "doc/changelog.markdown"); + String raw = readFile(f); + return markdownToHtml(raw); + } + + private static String readFile(File f) throws IOException { + byte[] b = new byte[65536]; + FileInputStream in = new FileInputStream(f); + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + while (true) { + int r = in.read(b); + if ( r == -1 ) break; + out.write(b, 0, r); + } + in.close(); + return new String(out.toByteArray(), "UTF-8"); + } finally { + in.close(); + } + } + + private static String markdownToHtml(String markdown) { return new MarkdownProcessor().markdown(markdown); } private static String buildEdge(String section) { String latest = section != null ? section : "* No changelog records for this edge release."; - return new MarkdownProcessor().markdown(latest); + return markdownToHtml(latest); } private static String buildLatest(String section) { String latest = section != null ? section : "* No changelog records for this release."; String noIssueLinks = latest.replaceAll("\\[[^]]*[Ii]ssue[^]]*\\]\\([^)]*\\)", ""); String noLinks = noIssueLinks.replaceAll("\\[([^]]*)\\]\\([^)]*\\)", "$1"); - return new MarkdownProcessor().markdown(noLinks); + return markdownToHtml(noLinks); } private static String sectionByVersion(String markdown, String version) { diff --git a/src/website/lombok/website/WebsiteMaker.java b/src/website/lombok/website/WebsiteMaker.java index fddc1b38..85ae5156 100644 --- a/src/website/lombok/website/WebsiteMaker.java +++ b/src/website/lombok/website/WebsiteMaker.java @@ -187,7 +187,7 @@ public class WebsiteMaker { } } - private static final Pattern LOMBOK_LINK = Pattern.compile("^.*<a(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)* href=\"([^\"]+)\"(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)*>([^<]+)</a>.*$"); + private static final Pattern LOMBOK_LINK = Pattern.compile("^.*<a(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)* href=\"(downloads/[^\"]+)\"(?: (?:id|class|rel|rev|download|target|type)(?:=\"[^\"]*\")?)*>([^<]+)</a>.*$"); private Map<String, Object> createDataModel() throws IOException { Map<String, Object> data = new HashMap<String, Object>(); data.put("version", version); @@ -206,11 +206,9 @@ public class WebsiteMaker { in.close(); } - if (links.isEmpty() || !links.get(0).get(0).endsWith("lombok-" + version + ".jar")) { - links.add(Arrays.asList("downloads/lombok-" + version + ".jar", "lombok-" + version + ".jar")); - } - data.put("linksToVersions", links); + data.put("changelog", CompileChangelog.getHtml(baseDir.getParentFile())); + return data; } |