2016-05-27 04:00:28 +02:00
|
|
|
module Docs
|
|
|
|
class Kotlin < UrlScraper
|
|
|
|
self.type = 'kotlin'
|
2016-06-05 17:54:30 +02:00
|
|
|
self.base_url = 'https://kotlinlang.org/'
|
|
|
|
self.root_path = 'api/latest/jvm/stdlib/index.html'
|
2016-05-27 04:00:28 +02:00
|
|
|
self.links = {
|
|
|
|
home: 'https://kotlinlang.org/',
|
|
|
|
code: 'https://github.com/JetBrains/kotlin'
|
|
|
|
}
|
|
|
|
|
|
|
|
html_filters.push 'kotlin/entries', 'kotlin/clean_html'
|
|
|
|
|
2021-11-18 04:01:43 +01:00
|
|
|
options[:container] = 'article'
|
|
|
|
options[:only_patterns] = [/\Adocs\//, /\Aapi\/latest\/jvm\/stdlib\//]
|
2017-03-12 20:45:13 +01:00
|
|
|
options[:skip_patterns] = [/stdlib\/org\./]
|
2016-06-05 17:54:30 +02:00
|
|
|
options[:skip] = %w(
|
|
|
|
api/latest/jvm/stdlib/alltypes/index.html
|
|
|
|
docs/
|
|
|
|
docs/videos.html
|
|
|
|
docs/events.html
|
|
|
|
docs/resources.html
|
|
|
|
docs/reference/grammar.html)
|
2021-11-18 04:01:43 +01:00
|
|
|
|
|
|
|
options[:fix_urls] = ->(url) do
|
|
|
|
url.sub! %r{/docs/reference/}, '/docs/'
|
|
|
|
url
|
|
|
|
end
|
2016-05-27 04:00:28 +02:00
|
|
|
|
|
|
|
options[:attribution] = <<-HTML
|
2022-04-04 22:46:32 +02:00
|
|
|
© 2010–2022 JetBrains s.r.o. and Kotlin Programming Language contributors<br>
|
2016-05-27 04:00:28 +02:00
|
|
|
Licensed under the Apache License, Version 2.0.
|
|
|
|
HTML
|
2019-03-09 02:36:05 +01:00
|
|
|
|
2021-11-18 04:01:43 +01:00
|
|
|
version '1.6' do
|
2022-04-04 22:46:32 +02:00
|
|
|
self.release = '1.6.20'
|
2021-11-18 04:01:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
version '1.4' do
|
|
|
|
self.release = '1.4.10'
|
|
|
|
end
|
|
|
|
|
2019-03-10 03:02:24 +01:00
|
|
|
def get_latest_version(opts)
|
2019-06-20 21:40:15 +02:00
|
|
|
get_latest_github_release('JetBrains', 'kotlin', opts)
|
2019-03-09 02:36:05 +01:00
|
|
|
end
|
2021-11-18 04:01:43 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def process_response?(response)
|
|
|
|
return false unless super
|
|
|
|
response.body !~ /http-equiv="refresh"/i
|
|
|
|
end
|
2022-04-08 21:25:35 +02:00
|
|
|
|
|
|
|
def parse(response)
|
|
|
|
response.body.gsub! %r{<div\ class="code-block" data-lang="([^"]+)"[^>]*>([\W\w]+?)</div>}, '<pre class="code" data-language="\1">\2</pre>'
|
|
|
|
super
|
|
|
|
end
|
2016-05-27 04:00:28 +02:00
|
|
|
end
|
|
|
|
end
|