devdocs/lib/docs/scrapers/kotlin.rb

59 lines
1.5 KiB
Ruby
Raw Normal View History

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'
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
options[:attribution] = <<-HTML
2022-04-04 22:46:32 +02:00
&copy; 2010&ndash;2022 JetBrains s.r.o. and Kotlin Programming Language contributors<br>
Licensed under the Apache License, Version 2.0.
HTML
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)
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
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
end
end