From 90de24157cfa2d9c95f191df92b6b97852349d53 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 30 May 2017 15:13:39 +0200 Subject: [PATCH 1/2] Add include for rendering sidebar in docs --- doc-tool/resources/_includes/sidebar.html | 2 +- .../dottydoc/staticsite/DefaultParams.scala | 25 ++++++++++++++++--- .../tools/dottydoc/staticsite/tags.scala | 6 +++-- docs/_includes/table-of-contents.html | 15 +++++++++++ docs/docs/index.md | 11 +++++--- 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 docs/_includes/table-of-contents.html diff --git a/doc-tool/resources/_includes/sidebar.html b/doc-tool/resources/_includes/sidebar.html index 24f0292538e5..e1ac5d94a665 100644 --- a/doc-tool/resources/_includes/sidebar.html +++ b/doc-tool/resources/_includes/sidebar.html @@ -1,7 +1,7 @@
diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/DefaultParams.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/DefaultParams.scala index 4ddd2449a010..0fcc6d22591b 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/DefaultParams.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/DefaultParams.scala @@ -43,7 +43,7 @@ case class DefaultParams( "root" -> site.root ).asJava, - "sidebar" -> sidebar.titles.asJava + "sidebar" -> sidebar.toMap ) val entityMap = entity match { case NonEntity => Map.empty @@ -79,7 +79,11 @@ case class SiteInfo( root: String ) -case class Sidebar(titles: List[Title]) +case class Sidebar(titles: List[Title]) { + import model.JavaConverters._ + def toMap: JMap[String, _] = + Map("titles" -> titles.map(_.toMap).asJava).asJava +} object Sidebar { def apply(map: HashMap[String, AnyRef]): Option[Sidebar] = Option(map.get("sidebar")).map { @@ -91,7 +95,15 @@ object Sidebar { def empty: Sidebar = Sidebar(Nil) } -case class Title(title: String, url: Option[String], subsection: List[Title]) +case class Title(title: String, url: Option[String], subsection: List[Title], description: Option[String]) { + import model.JavaConverters._ + def toMap: JMap[String, _] = Map( + "title" -> title, + "url" -> url.getOrElse(null), // ugh, Java + "subsection" -> subsection.map(_.toMap).asJava, + "description" -> description.getOrElse(null) + ).asJava +} object Title { def apply(map: JMap[String, AnyRef]): Option[Title] = { @@ -101,13 +113,18 @@ object Title { val url = Option(map.get("url")).collect { case s: String => s } + + val description = Option(map.get("description")).collect { + case s: String => s + } + val subsection = Option(map.get("subsection")).collect { case xs: JList[JMap[String, AnyRef]] @unchecked => xs.asScala.map(Title.apply).toList.flatMap(x => x) }.getOrElse(Nil) title.map { - case title: String => Title(title, url, subsection) + case title: String => Title(title, url, subsection, description) } } } diff --git a/doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala b/doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala index 0a8427c32012..5dde8261ac73 100644 --- a/doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala +++ b/doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala @@ -184,8 +184,10 @@ object tags { override def render(ctx: TemplateContext, nodes: LNode*): AnyRef = (nodes(0).render(ctx), nodes(1).render(ctx)) match { - case (t: Title, parent: String) => renderTitle(t, parent) - case (t: Title, _) => renderTitle(t, "./") // file is in top dir + case (map: JMap[String, AnyRef] @unchecked, parent: String) => + Title(map).map(renderTitle(_, parent)).getOrElse(null) + case (map: JMap[String, AnyRef] @unchecked, _) => + Title(map).map(renderTitle(_, "./")).getOrElse(null) // file is in top dir case _ => null } } diff --git a/docs/_includes/table-of-contents.html b/docs/_includes/table-of-contents.html new file mode 100644 index 000000000000..ff43e1356818 --- /dev/null +++ b/docs/_includes/table-of-contents.html @@ -0,0 +1,15 @@ + diff --git a/docs/docs/index.md b/docs/docs/index.md index 3a65e20c4142..3e0d5be6ce38 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -3,10 +3,15 @@ layout: doc-page title: "Dotty Documentation" --- -Dotty is a platform to try out new language concepts and compiler technologies for Scala. -The focus is mainly on simplification. We remove extraneous syntax (e.g. no XML literals), -and try to boil down Scala’s types into a smaller set of more fundamental constructors. +Dotty is a platform to try out new language concepts and compiler technologies for Scala. +The focus is mainly on simplification. We remove extraneous syntax (e.g. no XML literals), +and try to boil down Scala’s types into a smaller set of more fundamental constructors. The theory behind these constructors is researched in DOT, a calculus for dependent object types. In this documentation you will find information on how to use the Dotty compiler on your machine, navigate through the code, setup Dotty with your favorite IDE and more! + +Table of Contents +================= +{% assign titles = sidebar.titles %} +{% include "table-of-contents" %} From 939e9aa8d82933554dc9d7f30e4ce95ec8575f68 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 30 May 2017 22:01:46 +0200 Subject: [PATCH 2/2] Move "Usage" section up before "Reference" --- docs/sidebar.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/sidebar.yml b/docs/sidebar.yml index 42bc9da7b42b..175ac99c0018 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -1,6 +1,18 @@ sidebar: - title: Blog url: blog/index.html + - title: Usage + subsection: + - title: sbt-projects + url: docs/usage/sbt-projects.html + - title: IDE support for Dotty + url: docs/usage/ide-support.html + - title: cbt-projects + url: docs/usage/cbt-projects.html + - title: Dottydoc + url: docs/usage/dottydoc.html + - title: Migrating + url: docs/usage/migrating.html - title: Reference subsection: - title: New Types @@ -71,18 +83,6 @@ sidebar: url: docs/reference/dropped/limit22.html - title: XML literals url: docs/reference/dropped/xml.html - - title: Usage - subsection: - - title: sbt-projects - url: docs/usage/sbt-projects.html - - title: IDE support for Dotty - url: docs/usage/ide-support.html - - title: cbt-projects - url: docs/usage/cbt-projects.html - - title: Dottydoc - url: docs/usage/dottydoc.html - - title: Migrating - url: docs/usage/migrating.html - title: Contributing subsection: - title: Getting Started