From 637c888b8fad660464fc1b35d40279c3482cab65 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 17 Jan 2017 16:20:17 +0100 Subject: Add `genDocs` command to sbt in order to generate docs --- doc-tool/src/dotty/tools/dottydoc/DocDriver.scala | 6 ++--- .../tools/dottydoc/core/MiniPhaseTransform.scala | 2 +- .../tools/dottydoc/core/SortMembersPhase.scala | 10 ++++++++- .../dottydoc/model/comment/BodyEntities.scala | 4 ++-- .../tools/dottydoc/model/comment/HtmlParsers.scala | 8 +++---- .../tools/dottydoc/model/comment/WikiParser.scala | 26 +++++++++++----------- .../src/dotty/tools/dottydoc/staticsite/Site.scala | 4 ++-- 7 files changed, 33 insertions(+), 27 deletions(-) (limited to 'doc-tool') diff --git a/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala b/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala index 0225b3c5e..e5a2cc266 100644 --- a/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala +++ b/doc-tool/src/dotty/tools/dottydoc/DocDriver.scala @@ -54,7 +54,7 @@ class DocDriver extends Driver { override def main(args: Array[String]): Unit = { implicit val (filesToDocument, ctx) = setup(args, initCtx.fresh) - doCompile(newCompiler(ctx), filesToDocument)(ctx) + val reporter = doCompile(newCompiler(ctx), filesToDocument)(ctx) val docs = ctx.docbase.packages val siteRoot = new java.io.File(ctx.settings.siteRoot.value) @@ -68,9 +68,7 @@ class DocDriver extends Driver { .generateHtmlFiles() .generateBlog() - // FIXME: liqp templates are compiled by threadpools, for some reason it - // is not shutting down :-( - System.exit(0) + System.exit(if (reporter.hasErrors) 1 else 0) } } } diff --git a/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala b/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala index d87cdf098..b6fbe0238 100644 --- a/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala +++ b/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala @@ -204,7 +204,7 @@ object transform { trait DocMiniPhase { phase => private def identity[E]: PartialFunction[E, E] = { - case id => id + case id: E @unchecked => id } def transformPackage(implicit ctx: Context): PartialFunction[Package, Package] = identity diff --git a/doc-tool/src/dotty/tools/dottydoc/core/SortMembersPhase.scala b/doc-tool/src/dotty/tools/dottydoc/core/SortMembersPhase.scala index 29898b140..a281558d4 100644 --- a/doc-tool/src/dotty/tools/dottydoc/core/SortMembersPhase.scala +++ b/doc-tool/src/dotty/tools/dottydoc/core/SortMembersPhase.scala @@ -10,9 +10,17 @@ import model.internal._ /** This DocMiniPhase sorts the members of all classes, traits, objects and packages */ class SortMembers extends DocMiniPhase { + private implicit val EntityOrdering: Ordering[Entity] = new Ordering[Entity] { + def compare(x: Entity, y: Entity): Int = { + val nameComp = x.name.compareTo(y.name) + if (nameComp == 0) x.kind.compareTo(y.kind) + else nameComp + } + } + private def sort(xs: List[Entity]): List[Entity] = { def sortOrNil(xs: Option[List[Entity]]*) = - xs.map(_.getOrElse(Nil)).reduceLeft(_ ++ _).sortBy(_.name) + xs.map(_.getOrElse(Nil)).reduceLeft(_ ++ _).sorted val map = xs.groupBy(_.kind) diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/BodyEntities.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/BodyEntities.scala index 29fe48de3..1d49a4f4f 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/BodyEntities.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/BodyEntities.scala @@ -32,8 +32,8 @@ final case class Body(blocks: Seq[Block]) { } (blocks flatMap summaryInBlock).toList match { case Nil => None - case inline :: Nil => Some(Body(Seq(Paragraph(inline)))) - case inlines => Some(Body(Seq(Paragraph(Chain(inlines))))) + case inl :: Nil => Some(Body(Seq(Paragraph(inl)))) + case inls => Some(Body(Seq(Paragraph(Chain(inls))))) } } } diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala index a44c2fc1d..475157dce 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala @@ -104,8 +104,8 @@ object HtmlParsers { item match { case OrderedList(_, _) | UnorderedList(_) => // html requires sub ULs to be put into the last LI list + s"
  • ${blockToHtml(item)}
  • " - case Paragraph(inline) => - list + s"
  • ${inlineToHtml(inline)}
  • " // LIs are blocks, no need to use Ps + case Paragraph(inl) => + list + s"
  • ${inlineToHtml(inl)}
  • " // LIs are blocks, no need to use Ps case block => list + s"
  • ${blockToHtml(block)}
  • " } @@ -116,12 +116,12 @@ object HtmlParsers { } case class InlineToHtml(origin: Entity) { - def apply(inline: Inline) = toHtml(inline) + def apply(inl: Inline) = toHtml(inl) def relativePath(target: Entity) = util.traversing.relativePath(origin, target) - def toHtml(inline: Inline): String = inline match { + def toHtml(inl: Inline): String = inl match { case Chain(items) => (items map toHtml).mkString case Italic(in) => s"${toHtml(in)}" case Bold(in) => s"${toHtml(in)}" diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala index 92174f74f..13d74d4b3 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala @@ -82,7 +82,7 @@ private[comment] final class WikiParser( else { jumpWhitespace() jump(style) - val p = Paragraph(inline(isInlineEnd = false)) + val p = Paragraph(getInline(isInlineEnd = false)) blockEnded("end of list line ") Some(p) } @@ -121,7 +121,7 @@ private[comment] final class WikiParser( def title(): Block = { jumpWhitespace() val inLevel = repeatJump('=') - val text = inline(check("=" * inLevel)) + val text = getInline(check("=" * inLevel)) val outLevel = repeatJump('=', inLevel) if (inLevel != outLevel) reportError(pos, "unbalanced or unclosed heading") @@ -141,11 +141,11 @@ private[comment] final class WikiParser( def para(): Block = { val p = if (summaryParsed) - Paragraph(inline(isInlineEnd = false)) + Paragraph(getInline(isInlineEnd = false)) else { val s = summary() val r = - if (checkParaEnded()) List(s) else List(s, inline(isInlineEnd = false)) + if (checkParaEnded()) List(s) else List(s, getInline(isInlineEnd = false)) summaryParsed = true Paragraph(Chain(r)) } @@ -193,7 +193,7 @@ private[comment] final class WikiParser( list mkString "" } - def inline(isInlineEnd: => Boolean): Inline = { + def getInline(isInlineEnd: => Boolean): Inline = { def inline0(): Inline = { if (char == safeTagMarker) { @@ -264,35 +264,35 @@ private[comment] final class WikiParser( def bold(): Inline = { jump("'''") - val i = inline(check("'''")) + val i = getInline(check("'''")) jump("'''") Bold(i) } def italic(): Inline = { jump("''") - val i = inline(check("''")) + val i = getInline(check("''")) jump("''") Italic(i) } def monospace(): Inline = { jump("`") - val i = inline(check("`")) + val i = getInline(check("`")) jump("`") Monospace(i) } def underline(): Inline = { jump("__") - val i = inline(check("__")) + val i = getInline(check("__")) jump("__") Underline(i) } def superscript(): Inline = { jump("^") - val i = inline(check("^")) + val i = getInline(check("^")) if (jump("^")) { Superscript(i) } else { @@ -302,13 +302,13 @@ private[comment] final class WikiParser( def subscript(): Inline = { jump(",,") - val i = inline(check(",,")) + val i = getInline(check(",,")) jump(",,") Subscript(i) } def summary(): Inline = { - val i = inline(checkSentenceEnded()) + val i = getInline(checkSentenceEnded()) Summary( if (jump(".")) Chain(List(i, Text("."))) @@ -326,7 +326,7 @@ private[comment] final class WikiParser( val title = if (!check(stop)) Some({ jumpWhitespaceOrNewLine() - inline(check(stop)) + getInline(check(stop)) }) else None jump(stop) diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala index e991148d6..6cdff2f22 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala @@ -257,9 +257,9 @@ case class Site(val root: JFile, val projectTitle: String, val documentation: Ma root .listFiles .find(dir => dir.getName == "blog" && dir.isDirectory) - .map(_.listFiles).getOrElse(Array.empty) + .map(_.listFiles).getOrElse(Array.empty[JFile]) //FIXME: remove [JFile] once #1907 is fixed .find(dir => dir.getName == "_posts" && dir.isDirectory) - .map(_.listFiles).getOrElse(Array.empty) + .map(_.listFiles).getOrElse(Array.empty[JFile]) //FIXME: remove [JFile] once #1907 is fixed .flatMap(collectPosts) } -- cgit v1.2.3