Unified · Split
| @@ -2,26 +2,22 @@ module Docs · 1 unmodified line | |||
| 2 | class Deno | 2 | class Deno |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | if root_page? | 5 | if result[:path].start_with?('api/deno/') |
| 6 | @doc = at_css('h2[id]').parent.parent | 6 | @doc = at_css('main') |
| 7 | else | 7 | else |
| 8 | @doc = at_css('article') | 8 | @doc = at_css('main article .markdown-body') |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | css('*[aria-label="Anchor"]').remove | 11 | css('code').each do |node| |
| 12 | css('pre', '.tw-1nkr705').each do |node| | 12 | if node['class'] |
| 13 | node['data-language'] = 'typescript' | 13 | lang = node['class'][/language-(\w+)/, 1] |
| 14 | node.name = 'pre' | 14 | end |
| 15 | node['data-language'] = lang || 'ts' | ||
| 16 | node.remove_attribute('class') | ||
| 15 | end | 17 | end |
| 16 | css('.tw-8ej7ai').each do |node| | 18 | |
| 17 | code = node.at_css('.font-mono') | 19 | css('a.header-anchor').remove() |
| 18 | next unless code | 20 | |
| 19 | code.parent.name = 'blockquote' | ||
| 20 | code.name = 'code' | ||
| 21 | end | ||
| 22 | css('*[class]').remove_attribute('class') | ||
| 23 | xpath('//a[text()="[src]"]').remove | ||
| 24 | |||
| 25 | doc | 21 | doc |
| 26 | end | 22 | end |
| 27 | end | 23 | end |
| @@ -3,11 +3,21 @@ module Docs · 2 unmodified lines | |||
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | ||
| 5 | def get_name | 5 | def get_name |
| 6 | at_css('h1').content | 6 | if result[:path].start_with?('api/deno/') |
| 7 | at_css('main')['id'][/\Asymbol_([.\w]+)/, 1] | ||
| 8 | else | ||
| 9 | at_css('main article h1').content | ||
| 10 | end | ||
| 7 | end | 11 | end |
| 8 | 12 | ||
| 9 | def get_type | 13 | def get_type |
| 10 | 'Deno CLI APIs' | 14 | if result[:path].start_with?('api/deno/') |
| 15 | 'API' | ||
| 16 | elsif result[:path].start_with?('runtime/reference/cli') | ||
| 17 | 'CLI' | ||
| 18 | else | ||
| 19 | at_css('main article nav ul :first span').content | ||
| 20 | end | ||
| 11 | end | 21 | end |
| 12 | 22 | ||
| 13 | end | 23 | end |
| @@ -2,22 +2,40 @@ module Docs · 1 unmodified line | |||
| 2 | class Deno < UrlScraper | 2 | class Deno < UrlScraper |
| 3 | self.name = 'Deno' | 3 | self.name = 'Deno' |
| 4 | self.type = 'simple' | 4 | self.type = 'simple' |
| 5 | self.release = '1.27.0' | ||
| 6 | self.base_url = 'https://doc.deno.land/deno/stable/' | ||
| 7 | self.links = { | 5 | self.links = { |
| 8 | home: 'https://deno.land/', | 6 | home: 'https://deno.com/', |
| 9 | code: 'https://github.com/denoland/deno' | 7 | code: 'https://github.com/denoland/deno' |
| 10 | } | 8 | } |
| 11 | 9 | ||
| 12 | html_filters.push 'deno/entries', 'deno/clean_html' | ||
| 13 | |||
| 14 | # https://github.com/denoland/manual/blob/main/LICENSE | 10 | # https://github.com/denoland/manual/blob/main/LICENSE |
| 15 | options[:attribution] = <<-HTML | 11 | options[:attribution] = <<-HTML |
| 16 | © 2018–2022 the Deno authors | 12 | © 2018–2024 the Deno authors<br> |
| 13 | Licensed under the MIT License. | ||
| 17 | HTML | 14 | HTML |
| 18 | 15 | ||
| 16 | |||
| 17 | html_filters.push 'deno/entries', 'deno/clean_html' | ||
| 18 | |||
| 19 | version '2' do | ||
| 20 | self.release = '2.1.1' | ||
| 21 | self.base_url = 'https://docs.deno.com/' | ||
| 22 | self.root_path = 'runtime' | ||
| 23 | options[:only_patterns] = [/\Aruntime/, /\Aapi\/deno\/~/, /\Adeploy/, /\Asubhosting/] | ||
| 24 | options[:skip_patterns] = [ | ||
| 25 | /\Aruntime\/manual/, | ||
| 26 | /\Aapi\/deno\/.+\.prototype\z/, # all prototype pages get redirected to the main page | ||
| 27 | /\Aapi\/deno\/~\/Deno\.jupyter\.MediaBundle.+/, # docs unavailable | ||
| 28 | /\Aapi\/deno\/~\/Deno\.OpMetrics/, # deprecated in deno 2 | ||
| 29 | ] | ||
| 30 | options[:trailing_slash] = false | ||
| 31 | end | ||
| 32 | |||
| 33 | version '1' do | ||
| 34 | self.release = '1.27.0' | ||
| 35 | end | ||
| 36 | |||
| 19 | def get_latest_version(opts) | 37 | def get_latest_version(opts) |
| 20 | get_latest_github_release('denoland', 'deno', opts) | 38 | get_latest_github_release('denoland', 'deno', opts) |
| 21 | end | 39 | end |
| 22 | end | 40 | end |
| 23 | end | 41 | end |