devdocs/lib/docs/scrapers/kotlin.rb

73 lines
2 KiB
Ruby
Raw Permalink 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
2023-01-11 21:04:37 +01:00
&copy; 2010&ndash;2023 JetBrains s.r.o. and Kotlin Programming Language contributors<br>
Licensed under the Apache License, Version 2.0.
HTML
2023-07-26 09:17:44 +02:00
version '1.9' do
self.release = '1.9.0'
self.headers = { 'User-Agent' => 'devdocs.io' , 'Cookie' => 'x-ab-test-spring-boot-learning-path=0; userToken=r33dgpe8x3q5vswekg16a' }
end
2023-01-11 21:04:37 +01:00
version '1.8' do
self.release = '1.8.0'
self.headers = { 'User-Agent' => 'devdocs.io' , 'Cookie' => 'x-ab-test-spring-boot-learning-path=0; userToken=r33dgpe8x3q5vswekg16a' }
end
2022-07-04 22:56:16 +02:00
version '1.7' do
2022-09-30 20:54:03 +02:00
self.release = '1.7.20'
2022-07-04 22:56:16 +02:00
end
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