Skip to content

Commit a2f9ad3

Browse files
committed
Merge pull request #23 from retronym/merge/2.10.x-to-master
Merge/2.10.x to master
2 parents f935c09 + 8c02be9 commit a2f9ad3

File tree

6 files changed

+100
-16
lines changed

6 files changed

+100
-16
lines changed

Diff for: README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ For now, it's still mostly manual. What you need to do:
1212
2. Update the highlights notes in `hand-written.md`.
1313
3. run `sbt -Dfile.encoding=UTF-8 console`, and then the following if you want .html output:
1414

15-
scala> MakeReleaseNotes(new java.io.File("~/git/scala"), "v2.9.2", "v2.9.3")
16-
17-
and the following if you want .md as output:
18-
19-
scala> MakeReleaseNotes(new java.io.File("~/git/scala"), "v2.9.2", "v2.9.3")(MarkDown)
15+
```
16+
scala> MakeReleaseNotes(new java.io.File("~/git/scala"), "v2.9.2", "v2.9.3")
17+
scala> MakeReleaseNotes(new java.io.File("~/git/scala"), "v2.9.2", "v2.9.3")(MarkDown) // markdown for scala-lang.org
18+
```
2019

2120
where the two strings are the tags to compare.
2221

22+
To make the download page:
23+
24+
```
25+
scala> new MakeDownloadPage("2.10.3-RC2").write()
26+
```
2327

2428
## Contributing
2529

26-
Feel free to improve. Make sure to sign the Scala CLA.
30+
Feel free to improve. Make sure to sign the Scala CLA.

Diff for: src/main/scala/GitInfo.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
case class Commit(sha: String, author: String, header: String, body: String) {
3+
def trimmedHeader = header.take(80)
34
override def toString = " * " + sha + " (" + author + ") " + header + " - " + body.take(5) + " ..."
45
}
56

@@ -75,7 +76,7 @@ class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: Str
7576
sb append header4("Complete commit list!")
7677
sb append targetLanguage.tableHeader("sha", "Title")
7778
for (commit <- commits)
78-
sb append targetLanguage.tableRow(commitShaLink(commit.sha), commit.header)
79+
sb append targetLanguage.tableRow(commitShaLink(commit.sha), commit.trimmedHeader)
7980
sb append targetLanguage.tableEnd
8081
sb.toString
8182
}
@@ -86,7 +87,7 @@ class GitInfo(gitDir: java.io.File, val previousTag: String, val currentTag: Str
8687
sb append header4(s"Commits and the issues they fixed since ${previousTag}")
8788
sb append targetLanguage.tableHeader("Issue(s)", "Commit", "Message")
8889
for (commit <- fixCommits)
89-
sb append targetLanguage.tableRow(fixLinks(commit), commitShaLink(commit.sha), commit.header)
90+
sb append targetLanguage.tableRow(fixLinks(commit), commitShaLink(commit.sha), commit.trimmedHeader)
9091
sb append targetLanguage.tableEnd
9192
sb append blankLine()
9293
sb.toString

Diff for: src/main/scala/IO.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.io.File
2+
3+
object IO {
4+
def write(f: java.io.File, contents: String) {
5+
val buf = new java.io.BufferedWriter(new java.io.FileWriter(f))
6+
try buf.write(contents)
7+
finally buf.close()
8+
}
9+
}

Diff for: src/main/scala/MakeDownloadPage.scala

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import java.util.Date
2+
import java.text._
3+
4+
class MakeDownloadPage(version: String, releaseDate: Date = new Date()) {
5+
def write() = {
6+
require(!version.startsWith("v"), "version should *not* start with 'v'")
7+
val fileName = s"${format("yyyy-MM-dd")}-$version.md"
8+
IO.write(new java.io.File(fileName), page)
9+
println("generated " + fileName)
10+
}
11+
12+
def humanSize(url: String) = {
13+
import scala.sys.process._
14+
println(url)
15+
val tmpFile = java.io.File.createTempFile("download", ".tmp")
16+
val res = s"curl --fail --silent --output ${tmpFile.getAbsolutePath} $url".!
17+
val dfOutput = s"du -h ${tmpFile.getAbsolutePath}".!!
18+
val output = dfOutput.trim.split("\t").head
19+
if (output == "0B") {
20+
println(s"warning: could not fetch $url")
21+
""
22+
} else output
23+
}
24+
25+
def resourceArchive(cls: String, name: String, ext: String, desc: String) = {
26+
val fileName = s"$name-$version.$ext"
27+
val relUrl = s"/files/archive/$fileName"
28+
val fullUrl = s"http://www.scala-lang.org$relUrl"
29+
resource(cls, fileName, desc, relUrl, fullUrl)
30+
}
31+
32+
def resource(cls: String, fileName: String, desc: String, relUrl: String, fullUrl: String) = {
33+
s"""[$cls, "$fileName", "$relUrl", "$desc", "${humanSize(fullUrl)}"]"""
34+
}
35+
36+
def defaultClass = "-non-main-sys"
37+
38+
def format(fmt: String) = new SimpleDateFormat(fmt).format(releaseDate)
39+
40+
def ghSourceUrl = s"https://github.com/scala/scala/archive/v$version.tar.gz"
41+
42+
def page: String = {
43+
44+
s"""
45+
---
46+
title: Scala $version
47+
start: ${format("dd MMMM yyyy")}
48+
layout: downloadpage
49+
release_version: $version
50+
release_date: "${format("MMMM dd, yyyy")}"
51+
show_resources: "true"
52+
permalink: /download/$version.html
53+
requirements: "This Scala software distribution can be installed on any Unix-like or Windows system. It requires the Java runtime version 1.6 or later, which can be downloaded <a href='http://www.java.com/'>here</a>."
54+
resources: [
55+
${resourceArchive("-main-unixsys", "scala", "tgz", "Max OS X, Unix, Cygwin" )}
56+
${resourceArchive("-main-windows", "scala", "msi", "Windows (msi installer)" )},
57+
${resourceArchive(defaultClass, "scala", "zip", "Windows" )},
58+
${resourceArchive(defaultClass, "scala-docs", "txz", "API docs" )},
59+
${resourceArchive(defaultClass, "scala-docs", "zip", "API docs" )},
60+
${resource (defaultClass, s"scala-sources-$version.zip", "sources", ghSourceUrl, ghSourceUrl)},
61+
${resourceArchive(defaultClass, "scala-tool-support", "tgz", "Scala Tool Support (tgz)")},
62+
${resourceArchive(defaultClass, "scala-tool-support", "zip", "Scala Tool Support (zip)")}
63+
]
64+
---
65+
66+
67+
"""
68+
}
69+
}

Diff for: src/main/scala/MakeReleaseNotes.scala

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ object MakeReleaseNotes {
99
case Html => new java.io.File("release-notes.html")
1010
case MarkDown => new java.io.File(s"release-notes-${currentTag}.md")
1111
}
12-
val buf = new java.io.BufferedWriter(new java.io.FileWriter(out))
13-
try buf.write(makeReleaseNotes(scalaDir, previousTag, currentTag))
14-
finally buf.close()
12+
13+
IO.write(out, makeReleaseNotes(scalaDir, previousTag, currentTag))
1514
}
1615

1716
def parseHandWrittenNotes(file: java.io.File = new java.io.File("hand-written.md")): String = {
@@ -34,12 +33,14 @@ object MakeReleaseNotes {
3433
}
3534

3635
def makeReleaseNotes(scalaDir: java.io.File, previousTag: String, currentTag: String)(implicit targetLanguage: TargetLanguage): String = {
37-
def rawHandWrittenNotes(file: java.io.File = new java.io.File(s"history/hand-written-${currentTag drop 1}.md")): String = {
38-
val src = Source.fromFile(file)
39-
val lines = src.getLines
36+
def rawHandWrittenNotes(file: java.io.File = new java.io.File(s"hand-written.md")): String = {
37+
val lines: List[String] = if (file.exists) {
38+
val src = Source.fromFile(file)
39+
src.getLines.toList
40+
} else Nil
4041
// if you don't have the next line, sub-bullets would be screwed!
4142
// please take this case into account and comment out 2 next lines and uncomment the line after!
42-
val newLines = lines.map(x => if (x.startsWith(" *")) "\n" + x else x)
43+
val newLines = lines.map(x => if (x.startsWith(" *")) "\n" + x.stripPrefix(" ") else x)
4344
newLines.mkString("\n")
4445
// lines.mkString("\n")
4546
}

Diff for: src/main/scala/TargetLanguage.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sealed trait TargetLanguage {
1010
}
1111
case object MarkDown extends TargetLanguage {
1212
def createHyperLink(link: String, content: String): String =
13-
s"[$link]($content)"
13+
s"[$content]($link)"
1414
def blankLine(): String = "\n"
1515
def header4(msg: String): String = s"#### $msg\n"
1616
def tableHeader(firstColumn: String, secondColumn: String): String =

0 commit comments

Comments
 (0)