Update Kotlin documentation (1.6.0)

pull/1663/head
Simon Legner 3 years ago
parent 2fa27c3404
commit 1378b3878e

@ -2,7 +2,6 @@ module Docs
class Kotlin class Kotlin
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
@doc = at_css('.page-content')
subpath.start_with?('api') ? api_page : doc_page subpath.start_with?('api') ? api_page : doc_page
doc doc
end end
@ -14,6 +13,13 @@ module Docs
node.parent.before(node.parent.content).remove node.parent.before(node.parent.content).remove
end end
css('div.code-block').each do |node|
node.name = 'pre'
node['data-language'] = node['data-lang']
node.content = node.content
# FIXME: newlines in code-block are lost because of <div>? (on https://kotlinlang.org/docs/typecasts.html for instance)
end
css('pre').each do |node| css('pre').each do |node|
node['data-language'] = 'kotlin' if node.at_css('code.language-kotlin') node['data-language'] = 'kotlin' if node.at_css('code.language-kotlin')
node['data-language'] = 'groovy' if node.at_css('code.language-groovy') node['data-language'] = 'groovy' if node.at_css('code.language-groovy')

@ -6,25 +6,26 @@ module Docs
breadcrumbs[1..-1].join('.') breadcrumbs[1..-1].join('.')
else else
node = (at_css('h1') || at_css('h2')) node = (at_css('h1') || at_css('h2'))
return node.content unless node.nil? return [breadcrumbs[1..], [node.content]].flatten.join(': ') unless node.nil?
subpath[/\/([a-z0-9_-]+)\./][1..-2].titleize.sub('Faq', 'FAQ')
end end
end end
def get_type def get_type
if subpath.start_with?('api') if subpath.start_with?('api')
breadcrumbs[1] breadcrumbs[1]
elsif subpath.start_with?('docs/tutorials') else
'Tutorials' breadcrumbs[0]
elsif subpath.start_with?('docs/reference')
'Reference'
end end
end end
private private
def breadcrumbs def breadcrumbs
if subpath.start_with?('api')
@breadcrumbs ||= css('.api-docs-breadcrumbs a').map(&:content).map(&:strip) @breadcrumbs ||= css('.api-docs-breadcrumbs a').map(&:content).map(&:strip)
else
@breadcrumbs ||= doc.document.at_css('body')['data-breadcrumbs'].split('///')
end
end end
end end
end end

@ -1,7 +1,6 @@
module Docs module Docs
class Kotlin < UrlScraper class Kotlin < UrlScraper
self.type = 'kotlin' self.type = 'kotlin'
self.release = '1.4.10'
self.base_url = 'https://kotlinlang.org/' self.base_url = 'https://kotlinlang.org/'
self.root_path = 'api/latest/jvm/stdlib/index.html' self.root_path = 'api/latest/jvm/stdlib/index.html'
self.links = { self.links = {
@ -11,9 +10,8 @@ module Docs
html_filters.push 'kotlin/entries', 'kotlin/clean_html' html_filters.push 'kotlin/entries', 'kotlin/clean_html'
options[:container] = '.global-content' options[:container] = 'article'
options[:only_patterns] = [/\Adocs\//, /\Aapi\/latest\/jvm\/stdlib\//]
options[:only_patterns] = [/\Adocs\/tutorials\//, /\Adocs\/reference\//, /\Aapi\/latest\/jvm\/stdlib\//]
options[:skip_patterns] = [/stdlib\/org\./] options[:skip_patterns] = [/stdlib\/org\./]
options[:skip] = %w( options[:skip] = %w(
api/latest/jvm/stdlib/alltypes/index.html api/latest/jvm/stdlib/alltypes/index.html
@ -22,23 +20,34 @@ module Docs
docs/events.html docs/events.html
docs/resources.html docs/resources.html
docs/reference/grammar.html) docs/reference/grammar.html)
options[:replace_paths] = {
'api/latest/jvm/stdlib/' => 'api/latest/jvm/stdlib/index.html', options[:fix_urls] = ->(url) do
'docs/reference/coroutines.html' => 'docs/reference/coroutines-overview.html', url.sub! %r{/docs/reference/}, '/docs/'
'api/latest/jvm/stdlib/kotlin/fold.html' => 'api/latest/jvm/stdlib/kotlin.collections/fold.html', url
'api/latest/jvm/stdlib/kotlin/get-or-else.html' => 'api/latest/jvm/stdlib/kotlin.collections/get-or-else.html', end
'api/latest/jvm/stdlib/kotlin/map.html' => 'api/latest/jvm/stdlib/kotlin.collections/map.html',
'docs/tutorials/native/targeting-multiple-platforms.html' => 'docs/tutorials/native/basic-kotlin-native-app.html',
'api/latest/jvm/stdlib/kotlin/-throwable/print-stack-trace.html' => 'api/latest/jvm/stdlib/kotlin/print-stack-trace.html',
}
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2010&ndash;2020 JetBrains s.r.o. and Kotlin Programming Language contributors<br> &copy; 2010&ndash;2021 JetBrains s.r.o. and Kotlin Programming Language contributors<br>
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
version '1.6' do
self.release = '1.6.0'
end
version '1.4' do
self.release = '1.4.10'
end
def get_latest_version(opts) def get_latest_version(opts)
get_latest_github_release('JetBrains', 'kotlin', opts) get_latest_github_release('JetBrains', 'kotlin', opts)
end end
private
def process_response?(response)
return false unless super
response.body !~ /http-equiv="refresh"/i
end
end end
end end

Loading…
Cancel
Save