History

updated deno version

Rui Jiang committed 1 year ago

Commit 07337381 parent c07ccf53 files · +49 −25Browse files

Unified · Split

3 files
  1. lib/docs/filters/deno/clean_html.rb +12 −16
  2. lib/docs/filters/deno/entries.rb +12 −2
  3. lib/docs/scrapers/deno.rb +25 −7
lib/docs/filters/deno/clean_html.rb+12−16
@@ -2,26 +2,22 @@ module Docs · 1 unmodified line
2 class Deno2 class Deno
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if root_page?5 if result[:path].start_with?('api/deno/')
6 @doc = at_css('h2[id]').parent.parent6 @doc = at_css('main')
7 else7 else
8 @doc = at_css('article')8 @doc = at_css('main article .markdown-body')
9 end9 end
10 10
11 css('*[aria-label="Anchor"]').remove11 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 end17 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 code20
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 doc21 doc
26 end22 end
27 end23 end
lib/docs/filters/deno/entries.rb+12−2
@@ -3,11 +3,21 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 4
5 def get_name5 def get_name
6 at_css('h1').content6 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 end11 end
8 12
9 def get_type13 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 end21 end
12 22
13 end23 end
lib/docs/scrapers/deno.rb+25−7
@@ -2,22 +2,40 @@ module Docs · 1 unmodified line
2 class Deno < UrlScraper2 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/LICENSE10 # https://github.com/denoland/manual/blob/main/LICENSE
15 options[:attribution] = <<-HTML11 options[:attribution] = <<-HTML
16 &copy; 2018–2022 the Deno authors12 &copy; 2018–2024 the Deno authors<br>
13 Licensed under the MIT License.
17 HTML14 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 end39 end
22 end40 end
23end41end