-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from danicheg/microsite
Migrate the website to Docusaurus
- Loading branch information
Showing
54 changed files
with
14,502 additions
and
163,847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
docs-gen/src/main/scala/ch/epfl/scala/profiling/Docs.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ch.epfl.scala.profiling | ||
|
||
import ch.epfl.scala.profiling.docs.Sonatype | ||
import mdoc.MainSettings | ||
|
||
import scala.meta.io.AbsolutePath | ||
|
||
object Docs { | ||
def main(args: Array[String]): Unit = { | ||
val cwd0 = AbsolutePath.workingDirectory | ||
// Depending on who runs it (sbt vs bloop), the current working directory is different | ||
val cwd = if (!cwd0.resolve("docs").isDirectory) cwd0.toNIO.getParent else cwd0.toNIO | ||
|
||
def prepareVersions(prefix: String): Seq[String] => String = | ||
_.sortWith { | ||
case (l, r) => | ||
l.replaceFirst(prefix + ".", "").toInt <= | ||
r.replaceFirst(prefix + ".", "").toInt | ||
}.mkString(", ") | ||
|
||
val (scala212Versions, scala213Versions) = | ||
scalac.profiling.internal.build.BuildInfo.crossScalaVersions.partition(_.startsWith("2.12")) | ||
|
||
val settings = MainSettings() | ||
.withSiteVariables( | ||
Map( | ||
"VERSION" -> Sonatype.releaseScalacProfiling.version, | ||
"LATEST_VERSION" -> scalac.profiling.internal.build.BuildInfo.version, | ||
"SBT_PLUGIN_VERSION" -> Sonatype.releaseSbtPlugin.version, | ||
"SCALA212_VERSIONS" -> prepareVersions("2.12")(scala212Versions), | ||
"SCALA213_VERSIONS" -> prepareVersions("2.13")(scala213Versions) | ||
) | ||
) | ||
.withArgs(args.toList) | ||
// it should work with mdoc when run inside bloop but it doesn't, let's wait until it's fixed | ||
.withIn(cwd.resolve("docs")) | ||
.withOut(cwd.resolve("out")) | ||
|
||
val exitCode = _root_.mdoc.Main.process(settings) | ||
if (exitCode != 0) sys.exit(exitCode) | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
docs-gen/src/main/scala/ch/epfl/scala/profiling/docs/DependencyResolution.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package ch.epfl.scala.profiling.docs | ||
|
||
import coursierapi.Repository | ||
import coursierapi.error.CoursierError | ||
|
||
import ch.epfl.scala.profiledb.utils.AbsolutePath | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
// Slight modification of `bloop.DependencyResolution` | ||
object DependencyResolution { | ||
|
||
/** | ||
* @param organization The module's organization. | ||
* @param module The module's name. | ||
* @param version The module's version. | ||
*/ | ||
final case class Artifact(organization: String, module: String, version: String) | ||
|
||
/** | ||
* Resolve the specified modules and get all the files. By default, the local Ivy | ||
* repository and Maven Central are included in resolution. This resolution throws | ||
* in case there is an error. | ||
* | ||
* @param artifacts Artifacts to resolve | ||
* @param resolveSources Resolve JAR files containing sources | ||
* @param additionalRepos Additional repositories to include in resolution. | ||
* @return All the resolved files. | ||
*/ | ||
def resolve( | ||
artifacts: List[Artifact], | ||
resolveSources: Boolean = false, | ||
additionalRepos: Seq[Repository] = Nil | ||
): Array[AbsolutePath] = { | ||
resolveWithErrors(artifacts, resolveSources, additionalRepos) match { | ||
case Right(paths) => paths | ||
case Left(error) => throw error | ||
} | ||
} | ||
|
||
/** | ||
* Resolve the specified module and get all the files. By default, the local ivy | ||
* repository and Maven Central are included in resolution. This resolution is | ||
* pure and returns either some errors or some resolved jars. | ||
* | ||
* @param artifacts Artifacts to resolve | ||
* @return Either a coursier error or all the resolved files. | ||
*/ | ||
def resolveWithErrors( | ||
artifacts: List[Artifact], | ||
resolveSources: Boolean = false, | ||
additionalRepositories: Seq[Repository] = Nil | ||
): Either[CoursierError, Array[AbsolutePath]] = { | ||
val dependencies = artifacts.map { artifact => | ||
import artifact._ | ||
val baseDep = coursierapi.Dependency.of(organization, module, version) | ||
if (resolveSources) baseDep.withClassifier("sources") | ||
else baseDep | ||
} | ||
resolveDependenciesWithErrors(dependencies, resolveSources, additionalRepositories) | ||
} | ||
|
||
/** | ||
* Resolve the specified dependencies and get all the files. By default, the | ||
* local ivy repository and Maven Central are included in resolution. This | ||
* resolution is pure and returns either some errors or some resolved jars. | ||
* | ||
* @param dependencies Dependencies to resolve. | ||
* @param additionalRepositories Additional repositories to include in resolution. | ||
* @return Either a coursier error or all the resolved files. | ||
*/ | ||
def resolveDependenciesWithErrors( | ||
dependencies: Seq[coursierapi.Dependency], | ||
resolveSources: Boolean = false, | ||
additionalRepositories: Seq[Repository] = Nil | ||
): Either[CoursierError, Array[AbsolutePath]] = { | ||
val fetch = coursierapi.Fetch | ||
.create() | ||
.withDependencies(dependencies: _*) | ||
if (resolveSources) | ||
fetch.addArtifactTypes("src", "jar") | ||
fetch.addRepositories(additionalRepositories: _*) | ||
|
||
try Right(fetch.fetch().asScala.toArray.map(f => AbsolutePath(f.toPath))) | ||
catch { | ||
case error: CoursierError => Left(error) | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
docs-gen/src/main/scala/ch/epfl/scala/profiling/docs/Sonatype.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package ch.epfl.scala.profiling.docs | ||
|
||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
import org.jsoup.Jsoup | ||
|
||
import scala.util.control.NonFatal | ||
import coursierapi.MavenRepository | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
final case class Release(version: String, lastModified: Date) | ||
|
||
object Sonatype { | ||
lazy val releaseScalacProfiling = fetchLatest("scalac-profiling_2.12.18") | ||
lazy val releaseSbtPlugin = fetchLatest("sbt-scalac-profiling_2.12_1.0") | ||
|
||
/** Returns the latest published snapshot release, or the current release if. */ | ||
private def fetchLatest(artifact: String): Release = { | ||
val artifacts = List( | ||
DependencyResolution.Artifact("ch.epfl.scala", artifact, "latest.release") | ||
) | ||
val resolvedJars = DependencyResolution.resolve( | ||
artifacts, | ||
additionalRepos = | ||
List(MavenRepository.of(s"https://oss.sonatype.org/content/repositories/staging")) | ||
) | ||
|
||
val latestStableVersion = resolvedJars.find(_.syntax.contains(artifact)) match { | ||
case None => sys.error(s"Missing jar for resolved artifact '$artifact'") | ||
case Some(jar) => | ||
val firstTry = | ||
jar.underlying | ||
.getFileName() | ||
.toString | ||
.stripSuffix(".jar") | ||
.stripPrefix(artifact + "-") | ||
|
||
if (!firstTry.endsWith("_2.12.18") && !firstTry.endsWith("_2.12_1.0")) | ||
firstTry | ||
else jar.getParent.getParent.underlying.getFileName.toString | ||
} | ||
|
||
val doc = Jsoup | ||
.connect( | ||
s"https://oss.sonatype.org/content/repositories/releases/ch/epfl/scala/$artifact/" | ||
) | ||
.get | ||
|
||
val dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm") | ||
val releases = doc | ||
.select("pre") | ||
.asScala | ||
.flatMap { versionRow => | ||
val elements = versionRow.getAllElements().asScala.filterNot(_.text().contains("../")) | ||
val nodes = versionRow.textNodes().asScala.filter(_.text().trim.nonEmpty) | ||
|
||
elements.zip(nodes).flatMap { | ||
case (element, node) => | ||
val version = element.text().stripSuffix("/") | ||
|
||
if (version.startsWith("maven-metadata")) Nil | ||
else { | ||
node.text().trim().split("\\s+").init.toList match { | ||
case List(date, time) => | ||
try { | ||
val parsedDate = dateTime.parse(s"$date $time") | ||
List(Release(version, parsedDate)) | ||
} catch { | ||
case NonFatal(_) => Nil | ||
} | ||
case _ => Nil | ||
} | ||
} | ||
} | ||
} | ||
|
||
releases.filter(_.version == latestStableVersion).maxBy(_.lastModified.getTime) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.