Skip to content

Commit

Permalink
Fix API after rebase conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkingBad committed Sep 29, 2021
1 parent 03aadc2 commit a3f7e1f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ object Build {
Seq(inkuireDestinationFile)
}.taskValue,
libraryDependencies ++= Dependencies.flexmarkDeps ++ Seq(
"nl.big-o" % "liqp" % "0.6.7",
"nl.big-o" % "liqp" % "0.6.8",
"org.jsoup" % "jsoup" % "1.13.1", // Needed to process .html files for static site
Dependencies.`jackson-dataformat-yaml`,

Expand Down
14 changes: 9 additions & 5 deletions project/scripts/genDocsScalaLang
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ git clone "https://github.com/scala/docs.scala-lang.git" $DOCS_SCALA_LANG_DIR
SBT="$SCRIPT_DIR/sbt"
mkdir -pv $SITE_OUT_DIR
env "scaladoc.projectFormat=md" "$SBT" "scaladoc/renderScaladocScalajsToFile $DOCS_SCALA_LANG_DIR/scripts/scaladoc-scalajs.js $DOCS_SCALA_LANG_DIR/resources/css code-snippets.css"
"dist/target/pack/bin/scaladoc" "-d" "$SITE_OUT_DIR" "-format" "md" "-siteroot" "docs" "/dev/null"
"bin/scaladoc" "-d" "$SITE_OUT_DIR" "-format" "md" "-siteroot" "docs" "/dev/null"

if [ ! -d "$SITE_OUT_DIR" ]; then
echo "Output directory did not exist: $SITE_OUT_DIR" 1>&2
Expand All @@ -30,12 +30,9 @@ fi
cp -rf "$SITE_OUT_DIR/docs/reference"/* "$DOCS_SCALA_LANG_DIR/_scala3-reference"
cp -rf "$SITE_OUT_DIR/docs/usage/scaladoc"/* "$DOCS_SCALA_LANG_DIR/_overviews/scala3-scaladoc"

cp -rf "$SITE_OUT_DIR/docs/reference/contextual/motivation.md" "$DOCS_SCALA_LANG_DIR/_scala3-reference/contextual.md"
cp -rf "$SITE_OUT_DIR/docs/reference/metaprogramming/toc.md" "$DOCS_SCALA_LANG_DIR/_scala3-reference/metaprogramming.md"
cp -rf "$SITE_OUT_DIR/docs/resources/talks.md" "$DOCS_SCALA_LANG_DIR/scala3/talks.md"
cp -rf "$SITE_OUT_DIR/docs/usage/getting-started.md" "$DOCS_SCALA_LANG_DIR/scala3/getting-started.md"
cp -rf "$SITE_OUT_DIR/docs/usage/language-versions.md" "$DOCS_SCALA_LANG_DIR/_scala3-reference/language-versions.md"
cp -rf "$SITE_OUT_DIR/docs/usage/worksheet-mode.md" "$DOCS_SCALA_LANG_DIR/_overviews/scala3-book/tools-worksheets.md"
cp -rf "$SITE_OUT_DIR/docs/usage/tools-worksheets.md" "$DOCS_SCALA_LANG_DIR/_overviews/scala3-book/tools-worksheets.md"


# Copy csses and html importing these assets
Expand All @@ -44,3 +41,10 @@ cp -f "$PWD/docs/docsScalaLangResources/scaladoc-assets.html" "$DOCS_SCALA_LANG_

# Hack inclusion of these assests by the docs.scala-lang jekyll builder
echo "{% include scaladoc-assets.html %}" >> "$DOCS_SCALA_LANG_DIR/_layouts/inner-page-parent-dropdown.html"

# Push changes to fork branch
cd $DOCS_SCALA_LANG_DIR
git remote add barkingbad git@github.com:BarkingBad/docs.scala-lang.git
git add .
git commit -m "Update docs from dotty repo"
git push -f barkingbad main:pregenerated-page
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ object FrontMatterRenderer:
def render(properties: Map[String, Object]): String =

def renderProperties(newProps: Map[String, Object]): List[String] = newProps.collect {
case (k: String, v: String) => s"$p: $v"
}
case (k: String, v: String) => s"$k: $v"
}.toList

val rows = renderProperties(properties) ++ renderProperties(properties("page"))
val rows = renderProperties(properties) ++ renderProperties(properties("page").asInstanceOf[Map[String, Object]])

rows.mkString("---\n", "\n", "\n---") + "\n\n<!-- THIS FILE HAS BEEN GENERATED BY SCALADOC PREPROCESSOR. " +
"NOTE THAT ANY CHANGES TO THIS FILE CAN BE OVERRIDEN IN THE FUTURE -->\n\n"
Expand Down
15 changes: 14 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/site/templates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import com.vladsch.flexmark.util.options.{DataHolder, MutableDataSet}
import com.vladsch.flexmark.html.HtmlRenderer
import com.vladsch.flexmark.formatter.Formatter
import liqp.Template
import liqp.TemplateContext
import liqp.tags.Tag
import liqp.nodes.LNode
import scala.collection.JavaConverters._

import scala.io.Source
Expand Down Expand Up @@ -101,7 +104,17 @@ case class TemplateFile(

// Library requires mutable maps..
val mutableProperties = new JHashMap(ctx.properties.transform((_, v) => asJavaElement(v)).asJava)
val rendered = Template.parse(this.rawCode).render(mutableProperties)

// Register escaping {% link ... %} in markdown
val tag = new Tag("link"):
override def render(context: TemplateContext, nodes: Array[? <: LNode]): Object =
val link = super.asString(nodes(0).render(context))
s"{% link $link %}"

val rendered = ssctx.args.projectFormat match
case "html" => Template.parse(this.rawCode).`with`(tag).render(mutableProperties)
case "md" => this.rawCode

// We want to render markdown only if next template is html
val code = if (isHtml || layoutTemplate.exists(!_.isHtml)) rendered else
// Snippet compiler currently supports markdown only
Expand Down

0 comments on commit a3f7e1f

Please sign in to comment.