From 999a927bd03b0f6aa6f255c45727ce2522d4519d Mon Sep 17 00:00:00 2001 From: John Zeringue Date: Thu, 26 May 2016 22:00:28 -0400 Subject: [PATCH] Add Kotlin documentation Added documentation for the Kotlin programming language. The documentation comes from the [Kotlin Standard Library documentation](https://kotlinlang.org/api/latest/jvm/stdlib/index.html) at the [official Kotlin website](https://kotlinlang.org). It is all licensed under the [Apache License, Version 2.0](https://github.com/JetBrains/kotlin-web-site/blob/master/LICENSE). --- lib/docs/filters/kotlin/clean_html.rb | 9 +++++ lib/docs/filters/kotlin/entries.rb | 51 ++++++++++++++++++++++++++ lib/docs/scrapers/kotlin.rb | 21 +++++++++++ public/icons/docs/kotlin/16.png | Bin 0 -> 1238 bytes public/icons/docs/kotlin/16@2x.png | Bin 0 -> 2562 bytes public/icons/docs/kotlin/SOURCE | 1 + 6 files changed, 82 insertions(+) create mode 100644 lib/docs/filters/kotlin/clean_html.rb create mode 100644 lib/docs/filters/kotlin/entries.rb create mode 100644 lib/docs/scrapers/kotlin.rb create mode 100644 public/icons/docs/kotlin/16.png create mode 100644 public/icons/docs/kotlin/16@2x.png create mode 100644 public/icons/docs/kotlin/SOURCE diff --git a/lib/docs/filters/kotlin/clean_html.rb b/lib/docs/filters/kotlin/clean_html.rb new file mode 100644 index 00000000..5ac568dc --- /dev/null +++ b/lib/docs/filters/kotlin/clean_html.rb @@ -0,0 +1,9 @@ +module Docs + class Kotlin + class CleanHtmlFilter < Filter + def call + doc + end + end + end +end diff --git a/lib/docs/filters/kotlin/entries.rb b/lib/docs/filters/kotlin/entries.rb new file mode 100644 index 00000000..7874797f --- /dev/null +++ b/lib/docs/filters/kotlin/entries.rb @@ -0,0 +1,51 @@ +module Docs + class Kotlin + class EntriesFilter < Docs::EntriesFilter + def get_name + if at_css('h1') + name = at_css('h1').text + module_name = breadcrumbs[1] + + "#{module_name}.#{name}" + elsif at_css('h2') + at_css('h2').text.gsub 'Package ', '' + elsif at_css('h3') + at_css('h3').text + end + end + + def get_type + if package? || top_level? && !extensions? + breadcrumbs[1] + else + "miscellaneous" + end + end + + private + + def breadcrumbs + container = at_css('.api-docs-breadcrumbs') + + if container + links = container.children.select.with_index { |_, i| i.even? } + links.map &:text + else + [] + end + end + + def top_level? + breadcrumbs.size == 3 + end + + def extensions? + get_name.start_with? 'Extensions' + end + + def package? + breadcrumbs.size == 2 + end + end + end +end diff --git a/lib/docs/scrapers/kotlin.rb b/lib/docs/scrapers/kotlin.rb new file mode 100644 index 00000000..e657b144 --- /dev/null +++ b/lib/docs/scrapers/kotlin.rb @@ -0,0 +1,21 @@ +module Docs + class Kotlin < UrlScraper + self.type = 'kotlin' + self.release = '1.0.2' + self.base_url = 'https://kotlinlang.org/api/latest/jvm/stdlib/' + self.root_path = 'index.html' + self.links = { + home: 'https://kotlinlang.org/', + code: 'https://github.com/JetBrains/kotlin' + } + + html_filters.push 'kotlin/entries', 'kotlin/clean_html' + + options[:container] = '.page-content' + + options[:attribution] = <<-HTML + © 2016 JetBrains
+ Licensed under the Apache License, Version 2.0. + HTML + end +end diff --git a/public/icons/docs/kotlin/16.png b/public/icons/docs/kotlin/16.png new file mode 100644 index 0000000000000000000000000000000000000000..e78fa6a2f6429e521c5f997237f0b3204ed015c5 GIT binary patch literal 1238 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z8pn}NEkcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5O0c3d|4@L;p!@;Rg)$-uxY=IP=XVj&ni z**7C3T;%xw@Ap3MGcrEelR3FeXGUXN(5jH8*-n|fPUf+iYs)VB3QkmOJTl2cb6Zcw z7S@ZG^6r#8UKWt4skCFW@{y>QVL^f-_DQRSa-XH9)yRKeoUX>QhX0=R_kF+X{{P?k zevUSqzwW;eNz0C{?u?Q=qr#icG}TAZOtEa5{^PZm{450KNH+-RG6wKn=Ucd{#VL1M zn9cT^t9h>fc`DKPe(@BpHLIAuvD81j+nCSDdVrTPNz%aXytRWtk570%tMK&m6DM}a zKk-k{^lXZ`z#4euWrAS-@81)bn=f!Z>si=8mzno^QorKFnG<&wyn4ks?b)3*3QIX$ zjlQIZEI7QQHTI|AguRU{vmHP2|Y39ro@ANG9m(rYw=Ga>6i48|PHt*16_DSZP zzvRB+Ch>_Y48!UVtghu*FZ5G-V&K~VgN+4yUcagP70`J%eQQnc*Zfrs)t^&+?ChF@ zidg;cS~vJ6#2)n!4}8F{yzrua^U2nq=?Rx*PrueW;{KB>P3~Wh*K;W=iR2pxZZL9B z);iyPVUhW(iy@C+d@k^R@c2u7&A;!iJV&oz6kBhkv%q(M@{Ia(3b#y(R+!ZO`ykbm zcgyzqyFJwx&%9+@72&3nt#G#~?C*!W%J*g*kbfySr+U*`o}3r8Hv4`^hbQkbkE=iN zD68vCn8j;`Thn%2o72*LL^Qm7|Ca3uCxSO0x8MD{Ry^a%@zTBTGGyPm&0KJ%K>o1n z2HQEj8y9?g>~5~+nYwN5Y=bNIru7M(ySY|eKl=ad6w|prpZ`PO1kX9>O-$Neyj}>)8$l|R2^b@`AjlL6kM2#0(RM#a7F{PtE?tIx%zcn!cNs4}XM2olQTz^wQEox$NhQnB&ji{ht=w z614w9eeP=wwQj9DGd3^Pzwm@P=n_-PwRdwCr>jWjPK;_jQUCM7#^&#A_iz6_wfxKP zjLJl_9OjuBZaV|`ck-X&;T9{D;XT}TJgPZ5h9kGt@A8e;!jH}#TmOI0fBC@KIVbbX Ru5*A28&6k1mvv4FO#p5a2@U`N literal 0 HcmV?d00001 diff --git a/public/icons/docs/kotlin/16@2x.png b/public/icons/docs/kotlin/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6cdef2e158945fb18c4d0f1741707a269a99156d GIT binary patch literal 2562 zcmY*bc{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30ZKk5@4hn8 z8iioF_6t;1db5xCr^EZ&JKJT`>Dyr`c{YR*nQWKg;(Z*PfAQp66BwQ5WF~w@#HQ8h z&ibv}#r@0GnF_g8{a*Ch-E+uMSn2L+Q*kq0z`%2y)j`v_7&nN5WE-QAr#2KuubH{8 zu^$3>ty&Uv(p|Ht^7FEWg=$V2ZCm$vbYUFPnrYhT8;ZBHhIj-XhJO$lei9Y#k*ABA zTPz+stehE};c^w~5S0}2RmYO8lk{#6QcBiWE5zduSIi9(03Ff;bDHrHE~Zg=^HMc= zS7+)h)o+p{`l9DqVVj|^(!?6#Bd`K1m>hWX(!hk8L|B{2tg~{*9ZO~iRk@KInJRrk zBB~Z1{j#ZL&7v}U-NDH@Kwf_u%KRm1-A-UDYIJ|qhfjhg2L{VR_0TuYm5*~*u}2y8 zi6pqk1u=gj$=zLq>DD~cOHJErE9##1(luE<0LOsyH@wb;k=L3YB~A;2@l}n;9dx_v z>3cuVG#&(bW9!$c4oLi46*eY~{%zTM;dzMVkGfqrW47fuRTmg)CP zUps+eLvg(ib~vKnZ|P-6Q59|?gk(Xs^cFt5N9-bXYfBRCaAdDcABS0)jYI^|TaA;m z3qk%v)9>=0vS^a$-m(QvlRoGzfUtUz`kntIsh%yIJQfApKi}81Xz|Ww$f}3C@cmWgKj=$sGxmW3CBvngM+a-$ zWUzzD`fy?5HrOk!h`Am?5mG)~G_>qLSydOXUIp`7Y+D3nrdCv}k8cRF9CSIp@2Qar z+-SypJ-qz$0c~u5WHfMLd#5C=f&5ey?>no2GG;5YK)oI)u%kM1dhE|ck$o*|wc74(lbd75 OA2Y1Ji5?a082N9>-=6~j literal 0 HcmV?d00001 diff --git a/public/icons/docs/kotlin/SOURCE b/public/icons/docs/kotlin/SOURCE new file mode 100644 index 00000000..9b2016ac --- /dev/null +++ b/public/icons/docs/kotlin/SOURCE @@ -0,0 +1 @@ +https://upload.wikimedia.org/wikipedia/commons/b/b5/Kotlin-logo.png