diff --git a/_config.yml b/_config.yml index 008a39325a..4f559b2295 100644 --- a/_config.yml +++ b/_config.yml @@ -22,8 +22,6 @@ scala-3-version: 3.1.2 collections: contribute_resources: output: false - install_tabs: - output: false style: output: true overviews: diff --git a/_fr/getting-started/index.md b/_fr/getting-started/index.md index 0228e5ea0b..4b73224c27 100644 --- a/_fr/getting-started/index.md +++ b/_fr/getting-started/index.md @@ -27,14 +27,43 @@ L'installateur Scala est un outil nommé [Coursier](https://get-coursier.io/docs Il s'assure que la JVM est les outils standards de Scala sont installés sur votre système. Installez-le sur votre système avec les instructions suivantes. -
- -
+ +{% tabs install-cs-setup-tabs class=platform-os-options %} + + +{% tab macOS for=install-cs-setup-tabs %} +{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +{% altDetails cs-setup-macos-nobrew "Alternativement, si vous n'utilisez pas Homebrew:" %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +{% endaltDetails %} +{% endtab %} + + + +{% tab Linux for=install-cs-setup-tabs %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +{% endtab %} + + + +{% tab Windows for=install-cs-setup-tabs %} + Téléchargez et exécutez [l'intallateur Scala pour Windows]({{site.data.setup-scala.windows-link}}) basé sur Coursier. +{% endtab %} + + + +{% tab Other for=install-cs-setup-tabs defaultTab %} + + Suivez + [les instructions pour installer la commande `cs`](https://get-coursier.io/docs/cli-installation) + puis exécutez `./cs setup`. +{% endtab %} + + +{% endtabs %} + En plus de gérer les JVMs, `cs setup` installe aussi des utilitaires en ligne de commande : diff --git a/_includes/_ja/getting-started.md b/_includes/_ja/getting-started.md index 4faa2e2a35..f200bcb759 100644 --- a/_includes/_ja/getting-started.md +++ b/_includes/_ja/getting-started.md @@ -17,14 +17,41 @@ Scala をインストールすると、コンパイラやビルドツールな Scala のインストーラーは[Coursier](https://get-coursier.io/docs/cli-overview)というツールで、コマンドは`cs`です。このツールを使うと、JVM と標準 Scala ツールがシステムにインストールされます。 以下の手順でお使いのシステムにインストールしてください。 -
- -
+ +{% tabs install-cs-setup-tabs class=platform-os-options %} + + +{% tab macOS for=install-cs-setup-tabs %} +{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +{% altDetails cs-setup-macos-nobrew "または、Homebrewを使用しない場合は" %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +{% endaltDetails %} +{% endtab %} + + + +{% tab Linux for=install-cs-setup-tabs %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +{% endtab %} + + + +{% tab Windows for=install-cs-setup-tabs %} + [the Scala installer for Windows]({{site.data.setup-scala.windows-link}})を、ダウンロードして実行してください。 +{% endtab %} + + + +{% tab Other for=install-cs-setup-tabs defaultTab %} + + [手順に従って `cs` ランチャーをインストール](https://get-coursier.io/docs/cli-installation)し、その次に以下を実行します。`./cs setup` +{% endtab %} + + +{% endtabs %} + `cs setup` は JVM の管理だけでなく、便利なコマンドラインツールもインストールします: diff --git a/_includes/alt-details.html b/_includes/alt-details.html deleted file mode 100644 index fc2d94c85e..0000000000 --- a/_includes/alt-details.html +++ /dev/null @@ -1,7 +0,0 @@ -
- - -
- {{include.detail}} -
-
diff --git a/_includes/getting-started.md b/_includes/getting-started.md index 4a900782ff..491859f405 100644 --- a/_includes/getting-started.md +++ b/_includes/getting-started.md @@ -20,30 +20,56 @@ The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli- It ensures that a JVM and standard Scala tools are installed on your system. Install it on your system with the following instructions. -{% capture scalaDemo %}$ scala -version -Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL{% endcapture %} - -
- -
+ +{% tabs install-cs-setup-tabs class=platform-os-options %} + + +{% tab macOS for=install-cs-setup-tabs %} +Run the following command in your terminal, following the on-screen instructions: +{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +{% altDetails cs-setup-macos-nobrew "Alternatively, if you don't use Homebrew:" %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +{% endaltDetails %} +{% endtab %} + + + +{% tab Linux for=install-cs-setup-tabs %} + Run the following command in your terminal, following the on-screen instructions: + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +{% endtab %} + + + +{% tab Windows for=install-cs-setup-tabs %} + Download and execute [the Scala installer for Windows]({{site.data.setup-scala.windows-link}}) + based on Coursier, and follow the on-screen instructions. +{% endtab %} + + + +{% tab Other for=install-cs-setup-tabs defaultTab %} + + Follow the documentation from Coursier on + [how to install and run `cs setup`](https://get-coursier.io/docs/cli-installation). +{% endtab %} + + +{% endtabs %} + + + +{% altDetails testing-your-setup 'Testing your setup' %} +Check your setup with the command `scala -version`, which should output: +```bash +$ scala -version +Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL +``` +If that does not work, you may need to log out and log back in (or reboot) in order for the changes to take effect. +{% endaltDetails %} + Along with managing JVMs, `cs setup` also installs useful command-line tools: diff --git a/_includes/tabsection.html b/_includes/tabsection.html deleted file mode 100644 index f779ce2efb..0000000000 --- a/_includes/tabsection.html +++ /dev/null @@ -1,32 +0,0 @@ -
- {% for tabRoot in include.collection %} - {% if tabRoot.language == include.language %} - - {% endif %} - {% endfor %} - -
- {% for tabRoot in include.collection %} - {% if tabRoot.language == include.language %} -
- {{tabRoot.content}} -
- {% endif %} - {% endfor %} -
-
diff --git a/_install_tabs/1-macos.html b/_install_tabs/1-macos.html deleted file mode 100644 index f8caa80c19..0000000000 --- a/_install_tabs/1-macos.html +++ /dev/null @@ -1,21 +0,0 @@ ---- -tabId: osx -tabLabel: macOS -language: en ---- -
-
-

Run the following command in your terminal, following the on-screen instructions:

- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} - {% capture homebrewDetail %} -
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} -
- {% endcapture %} - {% include alt-details.html - id='cs-setup-macos-nobrew' - title="Alternatively, if you don't use Homebrew:" - detail=homebrewDetail - %} -
-
diff --git a/_install_tabs/2-linux.html b/_install_tabs/2-linux.html deleted file mode 100644 index 5f29b25c2b..0000000000 --- a/_install_tabs/2-linux.html +++ /dev/null @@ -1,11 +0,0 @@ ---- -tabId: linux -tabLabel: Linux -language: en ---- -
-
-

Run the following command in your terminal, following the on-screen instructions:

- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} -
-
diff --git a/_install_tabs/3-windows.html b/_install_tabs/3-windows.html deleted file mode 100644 index 01da9c604b..0000000000 --- a/_install_tabs/3-windows.html +++ /dev/null @@ -1,11 +0,0 @@ ---- -tabId: windows -tabLabel: Windows -language: en ---- -
-
-

Download and execute the Scala - installer for Windows based on Coursier, and follow the on-screen instructions.

-
-
diff --git a/_install_tabs/4-other.html b/_install_tabs/4-other.html deleted file mode 100644 index 8332bba359..0000000000 --- a/_install_tabs/4-other.html +++ /dev/null @@ -1,15 +0,0 @@ ---- -tabId: other -tabLabel: Other -defaultTab: true -language: en ---- -
-
- -

Follow the documentation from Coursier on how to install and run cs setup.

-
-
diff --git a/_install_tabs/fr-1-macos.html b/_install_tabs/fr-1-macos.html deleted file mode 100644 index 99fc4aaa34..0000000000 --- a/_install_tabs/fr-1-macos.html +++ /dev/null @@ -1,20 +0,0 @@ ---- -tabId: osx -tabLabel: macOS -language: fr ---- -
-
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} - {% capture homebrewDetail %} -
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} -
- {% endcapture %} - {% include alt-details.html - id='cs-setup-macos-nobrew' - title="Alternativement, si vous n'utilisez pas Homebrew:" - detail=homebrewDetail - %} -
-
diff --git a/_install_tabs/fr-2-linux.html b/_install_tabs/fr-2-linux.html deleted file mode 100644 index df2e1ccdba..0000000000 --- a/_install_tabs/fr-2-linux.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -tabId: linux -tabLabel: Linux -language: fr ---- -
-
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} -
-
diff --git a/_install_tabs/fr-3-windows.html b/_install_tabs/fr-3-windows.html deleted file mode 100644 index 7da64e60a0..0000000000 --- a/_install_tabs/fr-3-windows.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -tabId: windows -tabLabel: Windows -language: fr ---- -
-
-

Téléchargez et exécutez l'intallateur Scala pour Windows basé sur Coursier

-
-
diff --git a/_install_tabs/fr-4-other.html b/_install_tabs/fr-4-other.html deleted file mode 100644 index c54fd24c27..0000000000 --- a/_install_tabs/fr-4-other.html +++ /dev/null @@ -1,15 +0,0 @@ ---- -tabId: other -tabLabel: Other -defaultTab: true -language: fr ---- -
-
- -

Suivez les instructions pour installer la commande - cspuis exécutez ./cs setup.

-
-
diff --git a/_install_tabs/ja-1-macos.html b/_install_tabs/ja-1-macos.html deleted file mode 100644 index 553508b039..0000000000 --- a/_install_tabs/ja-1-macos.html +++ /dev/null @@ -1,20 +0,0 @@ ---- -tabId: osx -tabLabel: macOS -language: ja ---- -
-
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} - {% capture homebrewDetail %} -
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} -
- {% endcapture %} - {% include alt-details.html - id='cs-setup-macos-nobrew' - title="または、Homebrewを使用しない場合は" - detail=homebrewDetail - %} -
-
diff --git a/_install_tabs/ja-2-linux.html b/_install_tabs/ja-2-linux.html deleted file mode 100644 index 42b98e6a67..0000000000 --- a/_install_tabs/ja-2-linux.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -tabId: linux -tabLabel: Linux -language: ja ---- -
-
- {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} -
-
diff --git a/_install_tabs/ja-3-windows.html b/_install_tabs/ja-3-windows.html deleted file mode 100644 index f70ffba026..0000000000 --- a/_install_tabs/ja-3-windows.html +++ /dev/null @@ -1,10 +0,0 @@ ---- -tabId: windows -tabLabel: Windows -language: ja ---- -
-
-

the Scala installer for Windowsを、ダウンロードして実行してください。

-
-
diff --git a/_install_tabs/ja-4-other.html b/_install_tabs/ja-4-other.html deleted file mode 100644 index b923a3b164..0000000000 --- a/_install_tabs/ja-4-other.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -tabId: other -tabLabel: Other -defaultTab: true -language: ja ---- -
-
- -

手順に従って cs ランチャーをインストールし、その次に以下を実行します。./cs setup

-
-
diff --git a/_plugins/alt-details-lib/alt-details.rb b/_plugins/alt-details-lib/alt-details.rb new file mode 100644 index 0000000000..4ddbee64f4 --- /dev/null +++ b/_plugins/alt-details-lib/alt-details.rb @@ -0,0 +1,39 @@ +require 'erb' + +module Jekyll + module AltDetails + class AltDetailsBlock < Liquid::Block + SYNTAX = /^\s*(#{Liquid::QuotedFragment})\s+(#{Liquid::QuotedFragment})/o + Syntax = SYNTAX + + alias_method :render_block, :render + + def unquote(string) + string.gsub(/^['"]|['"]$/, '') + end + + def initialize(block_name, markup, tokens) + super + + if markup =~ SYNTAX + @name = unquote($1) + @title = unquote($2) + else + raise SyntaxError.new("Block #{block_name} requires an id and a title") + end + end + + def render(context) + site = context.registers[:site] + converter = site.find_converter_instance(::Jekyll::Converters::Markdown) + altDetailsContent = converter.convert(render_block(context)) + currentDirectory = File.dirname(__FILE__) + templateFile = File.read(currentDirectory + '/template.erb') + template = ERB.new(templateFile) + template.result(binding) + end + end + end +end + +Liquid::Template.register_tag('altDetails', Jekyll::AltDetails::AltDetailsBlock) diff --git a/_plugins/alt-details-lib/alt-details/version.rb b/_plugins/alt-details-lib/alt-details/version.rb new file mode 100644 index 0000000000..147e33df9c --- /dev/null +++ b/_plugins/alt-details-lib/alt-details/version.rb @@ -0,0 +1,5 @@ +module Jekyll + module AltDetails + VERSION = "1.1.1" + end +end diff --git a/_plugins/alt-details-lib/template.erb b/_plugins/alt-details-lib/template.erb new file mode 100644 index 0000000000..6aba6f127f --- /dev/null +++ b/_plugins/alt-details-lib/template.erb @@ -0,0 +1,11 @@ +
+
+ + +
+
+ <%= altDetailsContent %> +
+
+
+
diff --git a/_plugins/alt_details.rb b/_plugins/alt_details.rb new file mode 100644 index 0000000000..57d2420105 --- /dev/null +++ b/_plugins/alt_details.rb @@ -0,0 +1 @@ +require_relative "alt-details-lib/alt-details" diff --git a/_plugins/jekyll-tabs-lib/LICENCE b/_plugins/jekyll-tabs-lib/LICENCE new file mode 100644 index 0000000000..43ae840e30 --- /dev/null +++ b/_plugins/jekyll-tabs-lib/LICENCE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2022 Baptiste Bouchereau +Copyright (c) 2022 LAMP/EPFL + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/_plugins/jekyll-tabs-lib/README.md b/_plugins/jekyll-tabs-lib/README.md new file mode 100644 index 0000000000..4e84712723 --- /dev/null +++ b/_plugins/jekyll-tabs-lib/README.md @@ -0,0 +1,8 @@ +originally sourced from https://github.com/Ovski4/jekyll-tabs. + +changes: +- template.erb adapted to match the pre-existing tab html structure for docs.scala-lang.org +- `tabs` do not use secure random uuid as the id, the `tabs` name parameter is used instead. +- for the `tabs` block, add an optional second `class='foo bar'` parameter to allow custom classes for the tabs. +- for the `tab` block, reorder the parameters: the tab label comes first, followed by the name of the parent `tabs`. +- addition of a third `defaultTab` attribute for `tab`, which defaults to the final tab if not set. diff --git a/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb b/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb new file mode 100644 index 0000000000..c9a829f07f --- /dev/null +++ b/_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb @@ -0,0 +1,97 @@ +require 'erb' + +module Jekyll + module Tabs + + def self.unquote(string) + string.gsub(/^['"]|['"]$/, '') + end + + def self.asAnchor(title) + title.gsub(/[^a-zA-Z0-9\-_]/, '-').gsub(/-{2,}/, '-').downcase + end + + TabDetails = Struct.new(:label, :anchor, :defaultTab, :content, keyword_init: true) + + class TabsBlock < Liquid::Block + SYNTAX = /^\s*(#{Liquid::QuotedFragment})(?=\s+class=(#{Liquid::QuotedFragment}))?/o + Syntax = SYNTAX + + def initialize(block_name, markup, tokens) + super + + if markup =~ SYNTAX + @name = Tabs::unquote($1) + @css_classes = "" + if $2 + # append $2 to @css_classes + @css_classes = "#{@css_classes} #{Tabs::unquote($2)}" + end + else + raise SyntaxError.new("Block #{block_name} requires 1 attribute") + end + end + + def render(context) + environment = context.environments.first + environment["tabs-#{@name}"] = [] # reset every time (so page translations can use the same name) + super + + foundDefault = false + + allTabs = environment["tabs-#{@name}"] + + allTabs.each do | tab | + if tab.defaultTab + foundDefault = true + end + end + + if !foundDefault and allTabs.length > 0 + # set last tab to default + allTabs[-1].defaultTab = true + end + + currentDirectory = File.dirname(__FILE__) + templateFile = File.read(currentDirectory + '/template.erb') + template = ERB.new(templateFile) + template.result(binding) + end + end + + class TabBlock < Liquid::Block + alias_method :render_block, :render + + SYNTAX = /^\s*(#{Liquid::QuotedFragment})\s+(?:for=(#{Liquid::QuotedFragment}))(?:\s+(defaultTab))?/o + Syntax = SYNTAX + + def initialize(block_name, markup, tokens) + super + + if markup =~ SYNTAX + @tab = Tabs::unquote($1) + @name = Tabs::unquote($2) + @anchor = Tabs::asAnchor(@tab) + if $3 + @defaultTab = true + end + else + raise SyntaxError.new("Block #{block_name} requires at least 2 attributes") + end + end + + def render(context) + site = context.registers[:site] + converter = site.find_converter_instance(::Jekyll::Converters::Markdown) + content = converter.convert(render_block(context)) + tabcontent = TabDetails.new(label: @tab, anchor: @anchor, defaultTab: @defaultTab, content: content) + environment = context.environments.first + environment["tabs-#{@name}"] ||= [] + environment["tabs-#{@name}"] << tabcontent + end + end + end +end + +Liquid::Template.register_tag('tab', Jekyll::Tabs::TabBlock) +Liquid::Template.register_tag('tabs', Jekyll::Tabs::TabsBlock) diff --git a/_plugins/jekyll-tabs-lib/jekyll-tabs/version.rb b/_plugins/jekyll-tabs-lib/jekyll-tabs/version.rb new file mode 100644 index 0000000000..498949a13d --- /dev/null +++ b/_plugins/jekyll-tabs-lib/jekyll-tabs/version.rb @@ -0,0 +1,5 @@ +module Jekyll + module Tabs + VERSION = "1.1.1" + end +end diff --git a/_plugins/jekyll-tabs-lib/template.erb b/_plugins/jekyll-tabs-lib/template.erb new file mode 100644 index 0000000000..0d2e2ec147 --- /dev/null +++ b/_plugins/jekyll-tabs-lib/template.erb @@ -0,0 +1,29 @@ +
+
+ <% environment["tabs-#{@name}"].each do | tab | %> + > + <% end %> + +
+ <% environment["tabs-#{@name}"].each do | tab | %> +
+
+ <%= tab.content %> +
+
+ <% end %> +
+
+
diff --git a/_plugins/jekyll_tabs_4scala.rb b/_plugins/jekyll_tabs_4scala.rb new file mode 100644 index 0000000000..7470d622a7 --- /dev/null +++ b/_plugins/jekyll_tabs_4scala.rb @@ -0,0 +1 @@ +require_relative "jekyll-tabs-lib/jekyll-tabs-4scala" diff --git a/_sass/base/helper.scss b/_sass/base/helper.scss index 7f13553247..d0f6281ea0 100755 --- a/_sass/base/helper.scss +++ b/_sass/base/helper.scss @@ -19,6 +19,12 @@ @include padding(20px 0); } +.wrap-tab { + @extend .wrap-narrow; + margin-top: 20px; + margin-bottom: 20px; +} + .wrap-narrow { @include outer-container; @include padding(0 10px); diff --git a/resources/js/functions.js b/resources/js/functions.js index d6524a72f4..7bd39db251 100644 --- a/resources/js/functions.js +++ b/resources/js/functions.js @@ -386,7 +386,7 @@ $(document).ready(function() { function getOS() { var osname = "linux"; if (navigator.appVersion.indexOf("Win") != -1) osname = "windows"; - if (navigator.appVersion.indexOf("Mac") != -1) osname = "osx"; + if (navigator.appVersion.indexOf("Mac") != -1) osname = "macos"; if (navigator.appVersion.indexOf("Linux") != -1) osname = "linux"; if (navigator.appVersion.indexOf("X11") != -1) osname = "unix"; return osname; @@ -407,12 +407,13 @@ $(document).ready(function () { $(document).ready(function () { // click the get-started tab corresponding to the users OS. - if ($(".main-download").length) { + var platformOSOptions = $(".tabsection.platform-os-options"); + if (platformOSOptions.length) { var os = getOS(); if (os === 'unix') { os = 'linux'; } - $("#install-cs-setup-tabs").find('input[data-target=' + os + ']').prop("checked", true); + platformOSOptions.find('input[data-target=' + os + ']').prop("checked", true); } });