Skip to content

Commit

Permalink
Add table of contents to section indexes. Hide version dropdown in re…
Browse files Browse the repository at this point in the history
…ference documentation.
  • Loading branch information
pikinier20 committed Mar 15, 2022
1 parent ba57cdd commit 4babac0
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 31 deletions.
4 changes: 4 additions & 0 deletions docs/_docs/contributing/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
layout: index
title: Contributing
---
8 changes: 2 additions & 6 deletions docs/_docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: doc-page
redirectFrom: docs/index.html
layout: index
redirectFrom: /docs/index.html
---

Dotty is the project name for technologies that are considered for inclusion in Scala 3. Scala has
Expand All @@ -16,7 +16,3 @@ be a big step towards realizing the full potential of these ideas. Its main obje
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" %}
5 changes: 5 additions & 0 deletions docs/_docs/internals/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: index
title: Internals
---

2 changes: 1 addition & 1 deletion docs/_docs/reference/changed-features/changed-features.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Other Changed Features"
movedTo: https://docs.scala-lang.org/scala3/reference/changed-features.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/contextual/contextual.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Contextual Abstractions"
movedTo: https://docs.scala-lang.org/scala3/reference/contextual.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/dropped-features/dropped-features.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Dropped Features"
movedTo: https://docs.scala-lang.org/scala3/reference/dropped-features.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/enums/enums-index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Enums"
movedTo: https://docs.scala-lang.org/scala3/reference/enums.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/experimental/named-typeargs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: doc-page
title: "Named Type Arguments"
redirectFrom: reference/other-new-features/named-typeargs.html
redirectFrom: /docs/reference/other-new-features/named-typeargs.html
movedTo: https://docs.scala-lang.org/scala3/reference/experimental/named-typeargs.html
---

Expand Down
3 changes: 2 additions & 1 deletion docs/_docs/reference/experimental/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
layout: doc-page
title: "Overview"
title: "Experimental"
movedTo: https://docs.scala-lang.org/scala3/reference/experimental/overview.html
redirectFrom: overview.html
---

### Experimental language features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Language Versions"
---

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/metaprogramming/metaprogramming.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Metaprogramming"
movedTo: https://docs.scala-lang.org/scala3/reference/metaprogramming.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/new-types/new-types.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "New Types"
movedTo: https://docs.scala-lang.org/scala3/reference/new-types.html
---
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/other-new-features/other-new-types.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Other New Features"
movedTo: https://docs.scala-lang.org/scala3/reference/other-new-features.html
---
Expand Down
3 changes: 2 additions & 1 deletion docs/_docs/reference/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
layout: doc-page
title: "Overview"
title: "Reference"
movedTo: https://docs.scala-lang.org/scala3/reference/overview.html
redirectFrom: overview.html
---

Scala 3 implements many language changes and improvements over Scala 2.
Expand Down
4 changes: 4 additions & 0 deletions docs/_docs/usage/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
layout: index
title: Usage
---
2 changes: 1 addition & 1 deletion docs/_docs/usage/scaladoc/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: doc-page
layout: index
title: "Scaladoc"
---

Expand Down
15 changes: 13 additions & 2 deletions docs/_layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
layout: main
layout: static-site-main
---
<h1>{{ content }}</h1>
<h1>{{ page.title }}</h1>

{{ content }}

<h2>Table of Contents</h2>
<ul class="table-of-contents">
{% for child in site.posts %}
<li>
<a href="{{ child.url }}">{{ child.title }}</a>
</li>
{% endfor %}
</ul>
7 changes: 5 additions & 2 deletions docs/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ index: index.md
subsection:
- title: Usage
directory: docs/usage
index: usage/index.md
subsection:
- page: usage/sbt-projects.md
- page: usage/ide-support.md
Expand All @@ -17,8 +18,8 @@ subsection:
- page: usage/scaladoc/static-site.md
- title: Reference
directory: docs/reference
index: reference/overview.md
subsection:
- page: reference/overview.md
- title: New Types
index: reference/new-types/new-types.md
subsection:
Expand Down Expand Up @@ -137,8 +138,8 @@ subsection:
- page: reference/dropped-features/wildcard-init.md
- title: Experimental Features
directory: experimental
index: reference/experimental/overview.md
subsection:
- page: reference/experimental/overview.md
- page: reference/experimental/canthrow.md
- page: reference/experimental/erased-defs.md
- page: reference/experimental/erased-defs-spec.md
Expand All @@ -157,6 +158,7 @@ subsection:
- page: reference/features-classification.md
- title: Contributing
directory: docs/contributing
index: contributing/index.md
subsection:
- page: contributing/contribute-knowledge.md
- page: contributing/getting-started.md
Expand All @@ -175,6 +177,7 @@ subsection:
- page: contributing/procedures/vulpix.md
- title: Internals
directory: docs/internals
index: internals/index.md
subsection:
- page: internals/backend.md
- page: internals/classpaths.md
Expand Down
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ object Build {
.add(OutputDir("scaladoc/output/reference"))
.add(SiteRoot(s"${temp.getAbsolutePath}/docs"))
.add(ProjectName("Scala 3 Reference"))
.remove[VersionsDictionaryUrl]
.add(SourceLinks(List(
dottySrcLink(referenceVersion, temp.getAbsolutePath + "=")
)))
Expand Down
5 changes: 2 additions & 3 deletions project/resources/referenceReplacements/sidebar.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
index: reference/overview.md
subsection:
- page: reference/overview.md
- title: New Types
index: reference/new-types/new-types.md
subsection:
Expand Down Expand Up @@ -119,8 +118,8 @@ subsection:
- page: reference/dropped-features/wildcard-init.md
- title: Experimental Features
directory: experimental
index: reference/experimental/overview.md
subsection:
- page: reference/experimental/overview.md
- page: reference/experimental/canthrow.md
- page: reference/experimental/erased-defs.md
- page: reference/experimental/erased-defs-spec.md
Expand All @@ -136,4 +135,4 @@ subsection:
- page: reference/language-versions/source-compatibility.md
- page: reference/language-versions/binary-compatibility.md
- page: reference/soft-modifier.md
- page: reference/features-classification.md
- page: reference/features-classification.md
4 changes: 2 additions & 2 deletions scaladoc-testcases/docs/_docs/docs/f1.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: static-site-main
redirectFrom:
- docs/fr.html
- docs/my-custom-link
- /docs/fr.html
- /docs/my-custom-link
---
F1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ case class LoadedTemplate(
)

def resolveToHtml(ctx: StaticSiteContext): ResolvedPage =
val posts = children.map(_.lazyTemplateProperties(ctx))
val posts = children.filterNot(_.hidden).map(_.lazyTemplateProperties(ctx))
def getMap(key: String) = templateFile.settings.getOrElse(key, Map.empty).asInstanceOf[Map[String, Object]]

val sourceLinks = if !file.exists() then Nil else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class StaticSiteContext(
allTemplates.flatMap { loadedTemplate =>
val redirectFrom = loadedTemplate.templateFile.settings.getOrElse("page", Map.empty).asInstanceOf[Map[String, Object]].get("redirectFrom")
def redirectToTemplate(redirectFrom: String) =
val fakeFile = new File(docsPath.toFile, redirectFrom)
val driFrom = driFor(fakeFile.toPath)
val path = if redirectFrom.startsWith("/")
then relativizeFrom.resolve(redirectFrom.drop(1))
else loadedTemplate.file.toPath.resolveSibling(redirectFrom)
val driFrom = driFor(path)
val driTo = driFor(loadedTemplate.file.toPath)
(LoadedTemplate(layouts("redirect"), List.empty, fakeFile), driFrom, driTo)
(LoadedTemplate(layouts("redirect"), List.empty, path.toFile), driFrom, driTo)
redirectFrom.map {
case redirectFrom: String => Seq(redirectToTemplate(redirectFrom))
case redirects: List[?] => redirects.asInstanceOf[List[String]].map(redirectToTemplate)
Expand Down

0 comments on commit 4babac0

Please sign in to comment.