diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-02-02 15:46:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 15:46:39 +0100 |
commit | 3e65cff0caf4c671d3cf98da347792c85a4ac2de (patch) | |
tree | 415cfd9ac0601ceef6856e8873dcb384bb00abc3 /project | |
parent | fc031140ec00f2bfdc79456e1de9e15ae7df8d9a (diff) | |
parent | 6a2d1e0eb1005aa2e3567f256c6e259ede2f6ea7 (diff) | |
download | dotty-3e65cff0caf4c671d3cf98da347792c85a4ac2de.tar.gz dotty-3e65cff0caf4c671d3cf98da347792c85a4ac2de.tar.bz2 dotty-3e65cff0caf4c671d3cf98da347792c85a4ac2de.zip |
Merge pull request #1874 from dotty-staging/topic/dottydoc-markdown
[doctool] Add markdown support && Static site generation
Diffstat (limited to 'project')
-rw-r--r-- | project/Build.scala | 42 | ||||
-rwxr-xr-x | project/scripts/genDocs | 68 |
2 files changed, 108 insertions, 2 deletions
diff --git a/project/Build.scala b/project/Build.scala index 778492624..a6505a12c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -52,6 +52,15 @@ object DottyBuild extends Build { lazy val dotr = inputKey[Unit]("run compiled binary using the correct classpath, or the user supplied classpath") + // Compiles the documentation and static site + lazy val genDocs = inputKey[Unit]("run dottydoc to generate static documentation site") + + /** Dottydoc deps */ + lazy val dottydocDeps = SettingKey[Seq[ModuleID]]( + "dottydocDeps", + "dottydoc dependencies, should be moved to a dottydoc sbt subproject eventually" + ) + override def settings: Seq[Setting[_]] = { super.settings ++ Seq( scalaVersion in Global := scalacVersion, @@ -177,16 +186,28 @@ object DottyBuild extends Build { //http://stackoverflow.com/questions/10472840/how-to-attach-sources-to-sbt-managed-dependencies-in-scala-ide#answer-11683728 com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys.withSource := true, + dottydocDeps := Seq( + "com.vladsch.flexmark" % "flexmark" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-gfm-tasklist" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-gfm-tables" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-autolink" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-anchorlink" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-emoji" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-gfm-strikethrough" % "0.11.1", + "com.vladsch.flexmark" % "flexmark-ext-yaml-front-matter" % "0.11.1", + "com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % "2.8.6", + "nl.big-o" % "liqp" % "0.6.7" + ), + // get libraries onboard partestDeps := Seq(scalaCompiler, "org.scala-lang" % "scala-reflect" % scalacVersion, "org.scala-lang" % "scala-library" % scalacVersion % "test"), libraryDependencies ++= partestDeps.value, + libraryDependencies ++= dottydocDeps.value, libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1", "org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test", - dottyOrganization % "dottydoc-client" % "0.1.0", "com.novocode" % "junit-interface" % "0.11" % "test", - "com.github.spullara.mustache.java" % "compiler" % "0.9.3", "com.typesafe.sbt" % "sbt-interface" % sbtVersion.value), // enable improved incremental compilation algorithm incOptions := incOptions.value.withNameHashing(true), @@ -204,6 +225,21 @@ object DottyBuild extends Build { ) }.evaluated, + genDocs := Def.inputTaskDyn { + val dottyLib = packageAll.value("dotty-library") + val dottyInterfaces = packageAll.value("dotty-interfaces") + val otherDeps = (dependencyClasspath in Compile).value.map(_.data).mkString(":") + val sources = (managedSources in (Compile, compile)).value ++ (unmanagedSources in (Compile, compile)).value + val args: Seq[String] = Seq( + "-siteroot", "docs", + "-project", "Dotty", + "-classpath", s"$dottyLib:$dottyInterfaces:$otherDeps" + ) + (runMain in Compile).toTask( + s""" dotty.tools.dottydoc.Main ${args.mkString(" ")} ${sources.mkString(" ")}""" + ) + }.evaluated, + // Override run to be able to run compiled classfiles dotr := { val args: Seq[String] = spaceDelimited("<arg>").parsed @@ -369,6 +405,8 @@ object DottyBuild extends Build { // project, for sbt integration // FIXME: note part of dottyCompilerSettings because the doc-tool does not // compile with dotty + unmanagedResourceDirectories in Compile := Seq((resourceDirectory in Compile).value), + unmanagedResourceDirectories in Compile += baseDirectory.value / ".." / "doc-tool" / "resources", unmanagedSourceDirectories in Compile := Seq((scalaSource in Compile).value), unmanagedSourceDirectories in Compile += baseDirectory.value / ".." / "doc-tool" / "src", unmanagedSourceDirectories in Test := Seq((scalaSource in Test).value), diff --git a/project/scripts/genDocs b/project/scripts/genDocs new file mode 100755 index 000000000..b8d0ba254 --- /dev/null +++ b/project/scripts/genDocs @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Usage: ./genDocs <test variable> <dotty-bot password> + +set -e +# set extended glob, needed for rm everything but x +shopt -s extglob + +if [ "$1" = "test" ]; then + + # make sure that BOT_PASS is set + if [ -z ${2+x} ]; then + echo "BOT_PASS unset, unable to push without password" 1>&2 + exit 1 + else + BOT_PASS=$2 + fi + + echo "Working directory: $PWD" + + # this command will generate docs in $PWD/docs/_site + sbt -J-Xmx4096m \ + -J-XX:ReservedCodeCacheSize=512m \ + -J-XX:MaxMetaspaceSize=1024m \ + -Ddotty.drone.mem=4096m \ + -ivy /var/cache/drone/ivy2 \ + "genDocs" + + # make sure that the previous command actually succeeded + if [ ! -d "$PWD/docs/_site" ]; then + echo "Output directory did not exist: $PWD/docs/_site" 1>&2 + exit 1 + fi + + # save current head for commit message in gh-pages + GIT_HEAD=$(git rev-parse HEAD) + + # check out correct branch + git fetch origin gh-pages:gh-pages + git checkout gh-pages + + # move newly generated _site dir to $PWD + mv $PWD/docs/_site . + + # remove everything BUT _site dir + rm -rf !(_site) + + # copy new contents to $PWD + mv _site/* . + + # remove now empty _site dir + rm -rf _site + + # set github credentials + git config user.name "dotty-bot" + git config user.email "felix.mulder@epfl.ch" + + # add all contents of $PWD to commit + git add -A + git commit -m "Update gh-pages site for $GIT_HEAD" + + # push using dotty-bot to origin + git push https://dotty-bot:$BOT_PASS@github.com/lampepfl/dotty.git +else + # wrong parameter passed, should only generate docs if argument is "test" + # to avoid multiple site gens + echo "Not generating docs for $1" +fi |