Skip to content

Commit 0abe406

Browse files
Merge pull request #806 from scala/travissarles-master
WIP: merging look and feel of scala-lang with doc site
2 parents c54cfd4 + fb0793e commit 0abe406

File tree

1,569 files changed

+76093
-49569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,569 files changed

+76093
-49569
lines changed

.drone.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
pipeline:
22
build:
3-
image: scalaplatform/jdk8-ruby2-coursier:0.1
3+
image: scalacenter/scala-rvm-jvm-coursier:2.0
44
pull: true
55
commands:
6-
- bundle install
7-
- ./scripts/run-tut.sh
8-
- rm -r tut-tmp
9-
- bundle exec jekyll build
6+
- ./scripts/ci.sh

.drone.yml.sig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogc2NhbGFwbGF0Zm9ybS9qZGs4LXJ1YnkyLWNvdXJzaWVyOjAuMQogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.uCV-tIDp9xbL2u2y27B9id6SL89dBfiiiTvVXYxHAbw
1+
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogamRrLXJ2bS1jb3Vyc2llcjpsYXRlc3QKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIHNvdXJjZSB-Ly5wcm9maWxlCiAgICAgIC0gYnVuZGxlIGluc3RhbGwKICAgICAgLSAuL3NjcmlwdHMvcnVuLXR1dC5zaAogICAgICAtIHJtIC1yIHR1dC10bXAKICAgICAgLSBidW5kbGUgZXhlYyBqZWt5bGwgYnVpbGQK.7Rp37FEwRqAo85EdFYZh1PoyU8mxpFdEnpchWaQkHCc

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
_site
2+
.ruby-version
23
.DS_Store
34
.project
45
.settings
@@ -8,3 +9,4 @@ vendor/bundle
89
.idea/
910
/coursier
1011
/tut-tmp/
12+
.sass-cache/

Gemfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
source 'https://rubygems.org'
2-
gem 'github-pages', group: :jekyll_plugins
2+
gem 'jekyll-redirect-from'
3+
4+
# group :jekyll_plugins do
5+
# gem 'hawkins'
6+
# end
7+
8+
# ^ Useful for live reloading the site in your
9+
# browser during development. To use, uncomment
10+
# and do:
11+
# bundle exec jekyll liveserve --incremental

Gemfile.lock

Lines changed: 9 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,173 +1,34 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (4.2.8)
5-
i18n (~> 0.7)
6-
minitest (~> 5.1)
7-
thread_safe (~> 0.3, >= 0.3.4)
8-
tzinfo (~> 1.1)
94
addressable (2.5.1)
105
public_suffix (~> 2.0, >= 2.0.2)
11-
coffee-script (2.4.1)
12-
coffee-script-source
13-
execjs
14-
coffee-script-source (1.12.2)
156
colorator (1.1.0)
16-
ethon (0.10.1)
17-
ffi (>= 1.3.0)
18-
execjs (2.7.0)
19-
faraday (0.12.1)
20-
multipart-post (>= 1.2, < 3)
217
ffi (1.9.18)
228
forwardable-extended (2.6.0)
23-
gemoji (3.0.0)
24-
github-pages (143)
25-
activesupport (= 4.2.8)
26-
github-pages-health-check (= 1.3.4)
27-
jekyll (= 3.4.5)
28-
jekyll-avatar (= 0.4.2)
29-
jekyll-coffeescript (= 1.0.1)
30-
jekyll-default-layout (= 0.1.4)
31-
jekyll-feed (= 0.9.2)
32-
jekyll-gist (= 1.4.0)
33-
jekyll-github-metadata (= 2.4.0)
34-
jekyll-mentions (= 1.2.0)
35-
jekyll-optional-front-matter (= 0.1.2)
36-
jekyll-paginate (= 1.1.0)
37-
jekyll-readme-index (= 0.1.0)
38-
jekyll-redirect-from (= 0.12.1)
39-
jekyll-relative-links (= 0.4.1)
40-
jekyll-sass-converter (= 1.5.0)
41-
jekyll-seo-tag (= 2.2.3)
42-
jekyll-sitemap (= 1.0.0)
43-
jekyll-swiss (= 0.4.0)
44-
jekyll-theme-architect (= 0.0.4)
45-
jekyll-theme-cayman (= 0.0.4)
46-
jekyll-theme-dinky (= 0.0.4)
47-
jekyll-theme-hacker (= 0.0.4)
48-
jekyll-theme-leap-day (= 0.0.4)
49-
jekyll-theme-merlot (= 0.0.4)
50-
jekyll-theme-midnight (= 0.0.4)
51-
jekyll-theme-minimal (= 0.0.4)
52-
jekyll-theme-modernist (= 0.0.4)
53-
jekyll-theme-primer (= 0.3.0)
54-
jekyll-theme-slate (= 0.0.4)
55-
jekyll-theme-tactile (= 0.0.4)
56-
jekyll-theme-time-machine (= 0.0.4)
57-
jekyll-titles-from-headings (= 0.2.0)
58-
jemoji (= 0.8.0)
59-
kramdown (= 1.13.2)
60-
liquid (= 3.0.6)
61-
listen (= 3.0.6)
62-
mercenary (~> 0.3)
63-
minima (= 2.1.1)
64-
rouge (= 1.11.1)
65-
terminal-table (~> 1.4)
66-
github-pages-health-check (1.3.4)
67-
addressable (~> 2.3)
68-
net-dns (~> 0.8)
69-
octokit (~> 4.0)
70-
public_suffix (~> 2.0)
71-
typhoeus (~> 0.7)
72-
html-pipeline (2.6.0)
73-
activesupport (>= 2)
74-
nokogiri (>= 1.4)
75-
i18n (0.8.6)
76-
jekyll (3.4.5)
9+
jekyll (3.5.1)
7710
addressable (~> 2.4)
7811
colorator (~> 1.0)
7912
jekyll-sass-converter (~> 1.0)
8013
jekyll-watch (~> 1.1)
8114
kramdown (~> 1.3)
82-
liquid (~> 3.0)
15+
liquid (~> 4.0)
8316
mercenary (~> 0.3.3)
8417
pathutil (~> 0.9)
8518
rouge (~> 1.7)
8619
safe_yaml (~> 1.0)
87-
jekyll-avatar (0.4.2)
88-
jekyll (~> 3.0)
89-
jekyll-coffeescript (1.0.1)
90-
coffee-script (~> 2.2)
91-
jekyll-default-layout (0.1.4)
92-
jekyll (~> 3.0)
93-
jekyll-feed (0.9.2)
94-
jekyll (~> 3.3)
95-
jekyll-gist (1.4.0)
96-
octokit (~> 4.2)
97-
jekyll-github-metadata (2.4.0)
98-
jekyll (~> 3.1)
99-
octokit (~> 4.0, != 4.4.0)
100-
jekyll-mentions (1.2.0)
101-
activesupport (~> 4.0)
102-
html-pipeline (~> 2.3)
103-
jekyll (~> 3.0)
104-
jekyll-optional-front-matter (0.1.2)
105-
jekyll (~> 3.0)
106-
jekyll-paginate (1.1.0)
107-
jekyll-readme-index (0.1.0)
108-
jekyll (~> 3.0)
10920
jekyll-redirect-from (0.12.1)
11021
jekyll (~> 3.3)
111-
jekyll-relative-links (0.4.1)
112-
jekyll (~> 3.3)
11322
jekyll-sass-converter (1.5.0)
11423
sass (~> 3.4)
115-
jekyll-seo-tag (2.2.3)
116-
jekyll (~> 3.3)
117-
jekyll-sitemap (1.0.0)
118-
jekyll (~> 3.3)
119-
jekyll-swiss (0.4.0)
120-
jekyll-theme-architect (0.0.4)
121-
jekyll (~> 3.3)
122-
jekyll-theme-cayman (0.0.4)
123-
jekyll (~> 3.3)
124-
jekyll-theme-dinky (0.0.4)
125-
jekyll (~> 3.3)
126-
jekyll-theme-hacker (0.0.4)
127-
jekyll (~> 3.3)
128-
jekyll-theme-leap-day (0.0.4)
129-
jekyll (~> 3.3)
130-
jekyll-theme-merlot (0.0.4)
131-
jekyll (~> 3.3)
132-
jekyll-theme-midnight (0.0.4)
133-
jekyll (~> 3.3)
134-
jekyll-theme-minimal (0.0.4)
135-
jekyll (~> 3.3)
136-
jekyll-theme-modernist (0.0.4)
137-
jekyll (~> 3.3)
138-
jekyll-theme-primer (0.3.0)
139-
jekyll (~> 3.3)
140-
jekyll-theme-slate (0.0.4)
141-
jekyll (~> 3.3)
142-
jekyll-theme-tactile (0.0.4)
143-
jekyll (~> 3.3)
144-
jekyll-theme-time-machine (0.0.4)
145-
jekyll (~> 3.3)
146-
jekyll-titles-from-headings (0.2.0)
147-
jekyll (~> 3.3)
14824
jekyll-watch (1.5.0)
14925
listen (~> 3.0, < 3.1)
150-
jemoji (0.8.0)
151-
activesupport (~> 4.0)
152-
gemoji (~> 3.0)
153-
html-pipeline (~> 2.2)
154-
jekyll (>= 3.0)
155-
kramdown (1.13.2)
156-
liquid (3.0.6)
157-
listen (3.0.6)
158-
rb-fsevent (>= 0.9.3)
159-
rb-inotify (>= 0.9.7)
26+
kramdown (1.14.0)
27+
liquid (4.0.0)
28+
listen (3.0.8)
29+
rb-fsevent (~> 0.9, >= 0.9.4)
30+
rb-inotify (~> 0.9, >= 0.9.7)
16031
mercenary (0.3.6)
161-
mini_portile2 (2.1.0)
162-
minima (2.1.1)
163-
jekyll (~> 3.3)
164-
minitest (5.10.2)
165-
multipart-post (2.0.0)
166-
net-dns (0.8.0)
167-
nokogiri (1.6.8.1)
168-
mini_portile2 (~> 2.1.0)
169-
octokit (4.7.0)
170-
sawyer (~> 0.8.0, >= 0.5.3)
17132
pathutil (0.14.0)
17233
forwardable-extended (~> 2.6)
17334
public_suffix (2.0.5)
@@ -181,23 +42,12 @@ GEM
18142
sass-listen (4.0.0)
18243
rb-fsevent (~> 0.9, >= 0.9.4)
18344
rb-inotify (~> 0.9, >= 0.9.7)
184-
sawyer (0.8.1)
185-
addressable (>= 2.3.5, < 2.6)
186-
faraday (~> 0.8, < 1.0)
187-
terminal-table (1.8.0)
188-
unicode-display_width (~> 1.1, >= 1.1.1)
189-
thread_safe (0.3.6)
190-
typhoeus (0.8.0)
191-
ethon (>= 0.8.0)
192-
tzinfo (1.2.3)
193-
thread_safe (~> 0.1)
194-
unicode-display_width (1.3.0)
19545

19646
PLATFORMS
19747
ruby
19848

19949
DEPENDENCIES
200-
github-pages
50+
jekyll-redirect-from
20151

20252
BUNDLED WITH
203-
1.15.1
53+
1.15.3

_ba/cheatsheets/index.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
layout: cheatsheet
3+
title: Scalacheat
4+
5+
partof: cheatsheet
6+
7+
by: Brendan O'Connor
8+
about: Zahvaljujući <a href="http://brenocon.com/">Brendan O'Connor</a>u ovaj cheatsheet teži da bude kratki pregled sintakse Scale. Licenca pripada Brendan O'Connor-u, pod CC-BY-SA 3.0 licencom.
9+
10+
language: ba
11+
---
12+
13+
###### Doprinio {{ page.by }}
14+
{{ page.about }}
15+
16+
| <span id="variables" class="h2">varijable</span> | |
17+
| `var x = 5` | varijabla. |
18+
| <span class="label success">Dobro</span> `val x = 5`<br> <span class="label important">Loše</span> `x=6` | konstanta. |
19+
| `var x: Double = 5` | eksplicitni tip. |
20+
| <span id="functions" class="h2">funkcije</span> | |
21+
| <span class="label success">Dobro</span> `def f(x: Int) = { x*x }`<br> <span class="label important">Loše</span> `def f(x: Int) { x*x }` | definicija funkcije. <br> skrivena greška: bez `=` ovo je procedura koja vraća `Unit`; uzrokuje zabunu. |
22+
| <span class="label success">Dobro</span> `def f(x: Any) = println(x)`<br> <span class="label important">Loše</span> `def f(x) = println(x)` | definicija funkcije. <br> sintaksna greška: potrebni su tipovi za svaki argument. |
23+
| `type R = Double` | pseudonim za tip. |
24+
| `def f(x: R)` ili<br> `def f(x: => R)` | poziv-po-vrijednosti. <br> poziv-po-imenu (lijeni parameteri). |
25+
| `(x:R) => x*x` | anonimna funkcija. |
26+
| `(1 to 5).map(_*2)` ili<br> `(1 to 5).reduceLeft( _+_ )` | anonimna funkcija: donja crta odgovara argumentu po poziciji. |
27+
| `(1 to 5).map( x => x*x )` | anonimna funkcija: da bi koristili argument više od jednom, morate mu dati ime. |
28+
| <span class="label success">Dobro</span> `(1 to 5).map(2*)`<br> <span class="label important">Loše</span> `(1 to 5).map(*2)` | anonimna funkcija: vezana infiksna metoda. Koristite `2*_` zbog jasnoće. |
29+
| `(1 to 5).map { x => val y=x*2; println(y); y }` | anonimna funkcija: blokovski stil vraća vrijednost zadnjeg izraza. |
30+
| `(1 to 5) filter {_%2 == 0} map {_*2}` | anonimne funkcije: pipeline stil (može i sa oblim zagradama). |
31+
| `def compose(g:R=>R, h:R=>R) = (x:R) => g(h(x))` <br> `val f = compose({_*2}, {_-1})` | anonimne funkcije: da bi proslijedili više blokova, potrebne su dodatne zagrade. |
32+
| `val zscore = (mean:R, sd:R) => (x:R) => (x-mean)/sd` | curry-jevanje, očita sintaksa. |
33+
| `def zscore(mean:R, sd:R) = (x:R) => (x-mean)/sd` | curry-jevanje, očita sintaksa. |
34+
| `def zscore(mean:R, sd:R)(x:R) = (x-mean)/sd` | curry-jevanje, sintaksni šećer (kratica). Ali onda: |
35+
| `val normer = zscore(7, 0.4) _` | je potrebna prateća donja crta za parcijalnu primjenu, samo kod šećer (skraćene) verzije. |
36+
| `def mapmake[T](g:T=>T)(seq: List[T]) = seq.map(g)` | generički tip. |
37+
| `5.+(3); 5 + 3` <br> `(1 to 5) map (_*2)` | infiksni šećer. |
38+
| `def sum(args: Int*) = args.reduceLeft(_+_)` | varirajući broj argumenata (varargs). |
39+
| <span id="packages" class="h2">paketi</span> | |
40+
| `import scala.collection._` | džoker (wildcard) import. |
41+
| `import scala.collection.Vector` <br> `import scala.collection.{Vector, Sequence}` | selektivni import. |
42+
| `import scala.collection.{Vector => Vec28}` | preimenujući import. |
43+
| `import java.util.{Date => _, _}` | import svega iz `java.util` paketa osim `Date`. |
44+
| `package pkg` _na početku fajla_ <br> `package pkg { ... }` | deklaracija paketa. |
45+
| <span id="data_structures" class="h2">strukture podataka</span> | |
46+
| `(1,2,3)` | torka (tuple) literal (`Tuple3`). |
47+
| `var (x,y,z) = (1,2,3)` | destrukturirajuće vezivanje: otpakivanje torke podudaranjem uzoraka (pattern matching). |
48+
| <span class="label important">Loše</span>`var x,y,z = (1,2,3)` | skrivena greška: svim varijablama dodijeljena cijela torka. |
49+
| `var xs = List(1,2,3)` | lista (nepromjenjiva). |
50+
| `xs(2)` | indeksiranje zagradama ([slajdovi](http://www.slideshare.net/Odersky/fosdem-2009-1013261/27)). |
51+
| `1 :: List(2,3)` | cons. |
52+
| `1 to 5` _isto kao_ `1 until 6` <br> `1 to 10 by 2` | šećer za raspon (range). |
53+
| `()` _(prazne zagrade)_ | jedina instanca Unit tipa (slično kao u C/Java void). |
54+
| <span id="control_constructs" class="h2">kontrolne strukture</span> | |
55+
| `if (check) happy else sad` | uslov. |
56+
| `if (check) happy` _isto kao_ <br> `if (check) happy else ()` | sintaksni šećer za uslov. |
57+
| `while (x < 5) { println(x); x += 1}` | while petlja. |
58+
| `do { println(x); x += 1} while (x < 5)` | do while petlja. |
59+
| `import scala.util.control.Breaks._`<br>`breakable {`<br>` for (x <- xs) {`<br>` if (Math.random < 0.1) break`<br>` }`<br>`}`| break ([slajdovi](http://www.slideshare.net/Odersky/fosdem-2009-1013261/21)). |
60+
| `for (x <- xs if x%2 == 0) yield x*10` _isto kao_ <br>`xs.filter(_%2 == 0).map(_*10)` | for komprehensija: filter/map. |
61+
| `for ((x,y) <- xs zip ys) yield x*y` _isto kao_ <br>`(xs zip ys) map { case (x,y) => x*y }` | for komprehensija: destrukturirajuće vezivanje. |
62+
| `for (x <- xs; y <- ys) yield x*y` _isto kao_ <br>`xs flatMap {x => ys map {y => x*y}}` | for komprehensija: međuproizvod (vektorski proizvod). |
63+
| `for (x <- xs; y <- ys) {`<br> `println("%d/%d = %.1f".format(x, y, x/y.toFloat))`<br>`}` | for komprehensija: imperativ-asto.<br>[sprintf-stil.](http://java.sun.com/javase/6/docs/api/java/util/Formatter.html#syntax) |
64+
| `for (i <- 1 to 5) {`<br> `println(i)`<br>`}` | for komprehensija: iteracija uključujući gornju granicu. |
65+
| `for (i <- 1 until 5) {`<br> `println(i)`<br>`}` | for komprehensija: iteracija ne uključujući gornju granicu. |
66+
| <span id="pattern_matching" class="h2">podudaranje uzoraka (pattern matching)</span> | |
67+
| <span class="label success">Dobro</span> `(xs zip ys) map { case (x,y) => x*y }`<br> <span class="label important">Loše</span> `(xs zip ys) map( (x,y) => x*y )` | slučaj korištenja u argumentima funkcije. |
68+
| <span class="label important">Loše</span><br>`val v42 = 42`<br>`Some(3) match {`<br>` case Some(v42) => println("42")`<br>` case _ => println("Not 42")`<br>`}` | "v42" interpretira se kao ime koje odgovara bilo kojoj vrijednosti Int, i "42" se prikazuje. |
69+
| <span class="label success">Dobro</span><br>`val v42 = 42`<br>`Some(3) match {`<br>`` case Some(`v42`) => println("42")``<br>`case _ => println("Not 42")`<br>`}` | "\`v42\`" s kosim apostrofima interpretira se kao postojeća val `v42`, i "Not 42" se prikazuje. |
70+
| <span class="label success">Dobro</span><br>`val UppercaseVal = 42`<br>`Some(3) match {`<br>` case Some(UppercaseVal) => println("42")`<br>` case _ => println("Not 42")`<br>`}` | `UppercaseVal` tretira se kao postojeća val, a ne kao nova vrijednost uzorka, zato što počinje velikim slovom. Stoga, vrijednost u `UppercaseVal` se poredi sa `3`, i "Not 42" se prikazuje. |
71+
| <span id="object_orientation" class="h2">objektna orijentisanost</span> | |
72+
| `class C(x: R)` _isto kao_ <br>`class C(private val x: R)`<br>`var c = new C(4)` | parameteri konstruktora - privatni. |
73+
| `class C(val x: R)`<br>`var c = new C(4)`<br>`c.x` | parameteri konstruktora - javni. |
74+
| `class C(var x: R) {`<br>`assert(x > 0, "positive please")`<br>`var y = x`<br>`val readonly = 5`<br>`private var secret = 1`<br>`def this = this(42)`<br>`}`|<br>konstruktor je tijelo klase.<br>deklaracija javnog člana. <br> deklaracija dostupnog ali nepromjenjivog člana<br>deklaracija privatnog člana.<br>alternativni konstruktor.|
75+
| `new{ ... }` | anonimna klasa. |
76+
| `abstract class D { ... }` | definicija apstraktne klase (ne može se kreirati). |
77+
| `class C extends D { ... }` | definicija nasljedne klase. |
78+
| `class D(var x: R)`<br>`class C(x: R) extends D(x)` | nasljeđivanje i parameteri konstruktora (lista želja: automatsko prosljeđivanje parametara...).
79+
| `object O extends D { ... }` | definicija singletona (kao modul). |
80+
| `trait T { ... }`<br>`class C extends T { ... }`<br>`class C extends D with T { ... }` | trejtovi.<br>interfejs-s-implementacijom. Bez parametara konstruktora. [Miksabilan]({{ site.baseurl }}/tutorials/tour/mixin-class-composition.html).
81+
| `trait T1; trait T2`<br>`class C extends T1 with T2`<br>`class C extends D with T1 with T2` | više trejtova. |
82+
| `class C extends D { override def f = ...}` | moraju se deklarisati prebrisane metode. |
83+
| `new java.io.File("f")` | kreiranje objekta. |
84+
| <span class="label important">Loše</span> `new List[Int]`<br> <span class="label success">Dobro</span> `List(1,2,3)` | greška tipa: apstraktni tip. <br> umjesto toga, konvencija: fabrika istoimenog tipa. |
85+
| `classOf[String]` | literal za klasu. |
86+
| `x.isInstanceOf[String]` | provjera tipa (runtime). |
87+
| `x.asInstanceOf[String]` | kastovanje tipa (runtime). |
88+
| `x: String` | askripcija (compile time). |

0 commit comments

Comments
 (0)