Skip to content

Commit 0ed5bc0

Browse files
committed
Merge remote-tracking branch 'origin/2.10.x' into merge/2.10.x-to-master
Conflicts: README.md hand-written.md release-notes.html src/main/scala/MakeReleaseNotes.scala
2 parents f935c09 + b9b7f3c commit 0ed5bc0

File tree

4 files changed

+95
-12
lines changed

4 files changed

+95
-12
lines changed

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.

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+
}

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+
}

src/main/scala/MakeReleaseNotes.scala

+7-6
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,9 +33,11 @@ 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!
4243
val newLines = lines.map(x => if (x.startsWith(" *")) "\n" + x else x)

0 commit comments

Comments
 (0)