diff --git a/_layouts/multipage-overview.html b/_layouts/multipage-overview.html index 5d384433e7..ca65e57101 100644 --- a/_layouts/multipage-overview.html +++ b/_layouts/multipage-overview.html @@ -17,6 +17,12 @@ {% endif %} {% include version-specific-notice.html language=versionSpecificLang %} {% endif %} + {{content}} diff --git a/_layouts/singlepage-overview.html b/_layouts/singlepage-overview.html index e698d1183c..b39eafc05e 100644 --- a/_layouts/singlepage-overview.html +++ b/_layouts/singlepage-overview.html @@ -16,6 +16,12 @@ {% endif %} {% include version-specific-notice.html language=versionSpecificLang %} {% endif %} + {{content}} diff --git a/_overviews/scala3-book/taste-hello-world.md b/_overviews/scala3-book/taste-hello-world.md index e60f2ee7be..4bdf996f08 100644 --- a/_overviews/scala3-book/taste-hello-world.md +++ b/_overviews/scala3-book/taste-hello-world.md @@ -9,7 +9,6 @@ next-page: taste-repl --- > **Hint**: in the following examples try picking your preferred Scala version. -> ## Your First Scala Program @@ -149,7 +148,7 @@ import scala.io.StdIn.readLine In this code we save the result of `readLine` to a variable called `name`, we then -use the `+` operator on strings to join `"Hello, "` with `name` and `"!"`, making one single string value. +use the `+` operator on strings to join `"Hello, "` with `name` and `"!"`, making one single string value. > You can learn more about using `val` by reading [Variables and Data Types](/scala3/book/taste-vars-data-types.html). diff --git a/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb b/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb index b580d2f912..eee013d138 100644 --- a/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb +++ b/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb @@ -3,7 +3,7 @@ module Jekyll module Tabs - ScalaVersions = Set.new ['Scala 2', 'Scala 3'] + ScalaVersions = ['Scala 2', 'Scala 3'] def self.unquote(string) string.gsub(/^['"]|['"]$/, '') @@ -54,31 +54,73 @@ def render(context) allTabs = environment["tabs-#{@name}"] - seenTabs = Set.new + seenTabs = [] + + def joinScalaVersions() + Tabs::ScalaVersions.to_a.map{|item| "'#{item}'"}.join(", ") + end + + def errorNonScalaVersion(tab) + SyntaxError.new( + "Scala version tab label '#{tab.label}' is not valid for tabs '#{@name}' with " + + "class=tabs-scala-version. Valid tab labels are: #{joinScalaVersions()}") + end + + def errorScalaVersionWithoutClass(tab) + SyntaxError.new( + "Scala version tab label '#{tab.label}' is not valid for tabs '#{@name}' without " + + "class=tabs-scala-version") + end + + def errorMissingScalaVersion() + SyntaxError.new( + "Tabs '#{@name}' with class=tabs-scala-version must have exactly the following " + + "tab labels: #{joinScalaVersions()}") + end + + def errorDuplicateTab(tab) + SyntaxError.new("Duplicate tab label '#{tab.label}' in tabs '#{@name}'") + end + + def errorScalaVersionDefault(tab) + SyntaxError.new( + "Scala version tab label '#{tab.label}' should not be default for tabs '#{@name}' " + + "with class=tabs-scala-version") + end allTabs.each do | tab | if seenTabs.include? tab.label - raise SyntaxError.new("Duplicate tab label '#{tab.label}' in tabs '#{@name}'") + raise errorDuplicateTab(tab) end - seenTabs.add tab.label + seenTabs.push tab.label if tab.defaultTab foundDefault = true end + + isScalaTab = Tabs::ScalaVersions.include? tab.label + + if @is_scala_tabs + if !isScalaTab + raise errorNonScalaVersion(tab) + elsif tab.defaultTab + raise errorScalaVersionDefault(tab) + end + elsif !@is_scala_tabs and isScalaTab + raise errorScalaVersionWithoutClass(tab) + end end - if !foundDefault and allTabs.length > 0 - # set last tab to default - allTabs[-1].defaultTab = true + if @is_scala_tabs and seenTabs != Tabs::ScalaVersions + raise errorMissingScalaVersion() end - if @is_scala_tabs - allTabs.each do | tab | - if !Tabs::ScalaVersions.include?(tab.label) - joined_versions = Tabs::ScalaVersions.to_a.map{|item| "'#{item}'"}.join(", ") - raise SyntaxError.new( - "Scala version tab label '#{tab.label}' is not valid for tabs '#{@name}' with " + - "class=tabs-scala-version. Valid tab labels are: #{joined_versions}") - end + if !foundDefault and allTabs.length > 0 + if @is_scala_tabs + # set last tab to default ('Scala 3') + allTabs[-1].defaultTab = true + else + # set first tab to default + allTabs[0].defaultTab = true end end