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 00000000..e78fa6a2 Binary files /dev/null and b/public/icons/docs/kotlin/16.png differ diff --git a/public/icons/docs/kotlin/16@2x.png b/public/icons/docs/kotlin/16@2x.png new file mode 100644 index 00000000..6cdef2e1 Binary files /dev/null and b/public/icons/docs/kotlin/16@2x.png differ 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