Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: automate the creation of proposals/README.md #86

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.scala/
.bsp/
.metals/
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,36 @@ Proposals should follow the format and sections laid out in the [template
proposal](https://github.com/scalacenter/advisoryboard/tree/main/templates/proposal.md),
and should be concise enough to fit on a single side of paper if printed out.

## Recommendations
### Recommendations

Once a proposal has been adopted by the Advisory Board, it will become a
recommendation, and should be copied, noting any amendments, into the
[recommendations](https://github.com/scalacenter/advisoryboard/tree/main/recommendations)
directory.

### Proposals status

To see the up-to-date status of a proposal see the
[proposals/README](./proposals/README.md) which holds a summary of updates and
statuses of all proposals.

_NOTE_: This proposals/README.md file is auto-generated, so if you need to add
an update or change the status of a proposal make sure to do so in the heading
of the proposal file. The possible headings are:

```yaml
date: date proposed
accepted: true, yes, false, no
updates:
- postponed until next meeting
- accepted after discussion
- Updates found at https://www.scala-lang.org/blog/
status: completed, postponed, active, etc
```

To regenerate the proposals/README.md file run `scala-cli run bin/` from the
root of this project.

## Invitations

For reference, invitations sent to each Advisory Board representative are
Expand Down
8 changes: 8 additions & 0 deletions bin/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = "3.3.1"
runner.dialect = scala3

rewrite.scala3.convertToNewSyntax = yes
rewrite.scala3.removeOptionalBraces = yes
rewrite.scala3.insertEndMarkerMinLines = 15

docstrings.wrap = no
165 changes: 165 additions & 0 deletions bin/generate-proposal-listing.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// using scala 3.1.0
// using lib com.vladsch.flexmark:flexmark-all:0.62.2

import java.io.PrintWriter
import java.io.File
import java.nio.file.Paths
import java.util.Collection

import com.vladsch.flexmark.ext.yaml.front.matter.AbstractYamlFrontMatterVisitor
import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension
import com.vladsch.flexmark.parser.{Parser as FlexParser}
import com.vladsch.flexmark.util.ast.Document
import com.vladsch.flexmark.util.data.MutableDataSet
import com.vladsch.flexmark.util.misc.Extension

import scala.jdk.CollectionConverters.*
import scala.io.Source

/** This is a https://scala-cli.virtuslab.org/ script to iterate through all
* the proposals, grab their front matter and then generate the
* proposals/README.md file.
*/
@main def generate() =
val wd = Paths.get(".")

val proposalDir = Paths.get(".", "proposals").toFile

assert(
proposalDir.isDirectory,
"""|Looks like you're not in the root of this project.
|Run scala-cli from the root.
|
|scala-cli run bin/""".stripMargin
)

for
file <- proposalDir.listFiles.sorted
if file.isFile &&
file.getName.endsWith(".md") &&
file.getName.startsWith("0")
do
val contents = Source
.fromFile(file)
.getLines
.mkString(Printer.newline)
val document = Parser.parser.parse(contents)
val (date, accepted, updates, status) =
Parser.retrieveMetaData(document, file)
Printer.printName(file)
Printer.printDate(file, date)
Printer.printAccepted(file, accepted)
Printer.printUpdates(file, updates)
Printer.printStatus(file, status)
end for

Printer.printWarning()
Printer.close()

end generate

object Printer:
private val pw = new PrintWriter(new File("proposals", "README.md"))

def close() = pw.close()

// Just for sanity, let's force unix and not use System.lineSeparator or
// anything like that.
val newline = "\n"
val tab = "\t"

def printName(file: File) =
pw.write(s"# [${file.getName}](./${file.getName})$newline")

def printDate(file: File, date: Option[String]) =
date match
case Some(d) => pw.write(s"* Date proposed: $d$newline")
case _ => println(s"""Missing "date" for ${file.getName}""")

def printAccepted(file: File, accepted: Option[String]) =
accepted match
case Some("true" | "yes") => pw.write(s"* Accepted: yes$newline")
case Some("false" | "no") => pw.write(s"* Accepted: no$newline")
case Some(_) =>
println("Invalid value for accepted. Use either true, yes, false, no")
case _ => println(s"""Missing "accepted" value for ${file.getName}""")

def printUpdates(file: File, updates: Option[List[String]]) =
updates match
case Some(u) =>
pw.write(s"* Updates:$newline")
u.foreach(update => pw.write(s"$tab* $update$newline"))
case None => println(s"No updates found for ${file.getName}")

def printStatus(file: File, status: Option[String]) =
status match
case Some(s) => pw.write(s"* Status: **$s**$newline")
case _ => println(s"""Missing "status" for ${file.getName}""")

def printWarning() =
pw.write(
s"${newline}_This file is auto-generated. Don't edit here, instead run scala-cli run bin/ to regenerate._"
)

end Printer

object Parser:
val rawExtensions: List[Extension] = List(
YamlFrontMatterExtension.create()
)

val extensions: Collection[Extension] = rawExtensions.asJava

val options =
new MutableDataSet()
.set(FlexParser.EXTENSIONS, extensions)

val parser = FlexParser.builder(options).build()

enum AcceptedKey(key: String):
case date extends AcceptedKey("date")
case accepted extends AcceptedKey("accepted")
case updates extends AcceptedKey("updates")
case status extends AcceptedKey("status")
end AcceptedKey

def retrieveMetaData(node: Document, file: File) =
val visitor = new AbstractYamlFrontMatterVisitor()
visitor.visit(node)
val data = visitor.getData.asScala

val metadata: Map[AcceptedKey, List[String]] = visitor
.getData()
.asScala
.toMap
.foldLeft(Map.empty) { case (mapping, (key, value)) =>
if value.asScala.toList.nonEmpty && AcceptedKey.values
.map(_.toString.toLowerCase)
.contains(key.toLowerCase)
then mapping + (AcceptedKey.valueOf(key) -> value.asScala.toList)
else if value.asScala.toList.nonEmpty then
println(
s"""|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|"$key" in file: ${file.getName} is not an accepted front matter.
|!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|The accepted values are:
| ${AcceptedKey.values.mkString(", ")}
|
|""".stripMargin
)
mapping
else mapping

}

// Keep in mind the YAML front matter only supports subset of YAML
// https://github.com/vsch/flexmark-java/wiki/Extensions#yaml-front-matter
val date = metadata.get(AcceptedKey.date).flatMap(_.headOption)
val accepted = metadata.get(AcceptedKey.accepted).flatMap(_.headOption)
val updates = metadata.get(AcceptedKey.updates)
val status = metadata.get(AcceptedKey.status).flatMap(_.headOption)

(date, accepted, updates, status)
end retrieveMetaData
end Parser
10 changes: 10 additions & 0 deletions proposals/001-native-scala-for-spark.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---
date: May 2016
accepted: true
updates:
- deferred for later consideration
- considered again and accepted August 2016
- dormant no recent activity as of August 2019
status: dormant
---

# SCP-001: Native Execution of Scala/Spark via LLVM

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/002-dotty-migration-path.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2016
accepted: true
updates:
- Remains active as of August 2019
status: active
---

# SCP-002: Migration path to Dotty for Scalac users

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/003-scala-center-publicity-chair.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2016
accepted: true
updates:
- Remains active as of August 2019
status: active
---

# SCP-003: Scala Center Publicity Chair

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/004-sip-and-slip-coordination.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2016
accepted: true
updates:
- SIP coordinator is Darja
status: active
---

# SCP-004: Center to coordinate SIP/SLIP process

## Note
Expand Down
8 changes: 8 additions & 0 deletions proposals/005-continuity-of-scala-js.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2016
accepted: true
updates:
- Remains active as of August 2019
status: active
---

# SCP-005: Ensurance of continuity of Scala.js project

## Note
Expand Down
8 changes: 8 additions & 0 deletions proposals/006-compile-time-serializibility-check.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: August 2016
accepted: true
updates:
- Completed in 2016
status: completed
---

# SCP-006: Compile Time Check of Serializability

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/007-collections.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: November 2016
accepted: true
updates:
- Completed in 2019 with the release of 2.13
status: completed
---

# SCP-007: Collaborative redesign and implementation of Scala 2.13's collections library.

## Proposer
Expand Down
6 changes: 6 additions & 0 deletions proposals/008-websites.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
date: November 2016
accepted: true
status: active
---

# SCP-008: Maintain scala-lang, docs.scala-lang, scala.epfl.ch websites

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/009-improve-direct-dependency-experience.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: November 2016
accepted: true
updates:
- Completed in 2017
status: completed
---

# SCP-009: Improve user experience for builds that use only direct dependencies

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/010-compiler-profiling.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2017
accepted: true
updates:
- Completed in 2018
status: completed
---

# Providing Better Compilation Performance Information

## Proposer
Expand Down
9 changes: 9 additions & 0 deletions proposals/011-debugging-symbols.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
date: May 2017
accepted: false
updates:
- Was postponed after discussion
- Superseded by a sequel proposal: SCP-022
status: superseded
---

# Debugging Position Information

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/012-improve-sbt-learning-materials.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: May 2017
accepted: false
updates:
- Withdrawn after discussion
status: withdrawn
---

# Improve Resources for Learning SBT

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/013-sbt-migration.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: September 2017
accepted: true
updates:
- Migration largely complete as of August 2019
status: completed
---

# SCP-013: Aid the ecosystem in upgrading to sbt 1.0.x

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/014-production-ready-scalamacros.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: September 2017
accepted: true
updates:
- In the sense that designs were discussed, trials were made, and conclusions were reached: no substantial changes in Scala 2; design and implementation work on Scala 3 macros remains ongoing at LAMP
status: completed
---

# SCP-014: Production ready scalamacros/scalamacros

## Proposer
Expand Down
8 changes: 8 additions & 0 deletions proposals/015-zinc-performance.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
date: September 2017
accepted: true
updates:
- Completed in 2018
status: completed
---

# SCP-015: Improving performance and profiling of Zinc

## Proposer
Expand Down
Loading