Skip to content

Commit 30f4e5b

Browse files
authored
Merge pull request #2372 from ruiiiijiiiiang/feature/update-deno-version
Updated deno version (1.27.0 -> 2.1.1)
2 parents 495e8b6 + de294da commit 30f4e5b

File tree

3 files changed

+56
-24
lines changed

3 files changed

+56
-24
lines changed

lib/docs/filters/deno/clean_html.rb

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@ module Docs
22
class Deno
33
class CleanHtmlFilter < Filter
44
def call
5-
if root_page?
6-
@doc = at_css('h2[id]').parent.parent
5+
if result[:path].start_with?('api/deno/')
6+
@doc = at_css('main')
77
else
8-
@doc = at_css('article')
8+
@doc = at_css('main article .markdown-body')
99
end
1010

11-
css('*[aria-label="Anchor"]').remove
12-
css('pre', '.tw-1nkr705').each do |node|
13-
node['data-language'] = 'typescript'
14-
node.name = 'pre'
11+
if at_css('.text-2xl')
12+
doc.prepend_child at_css('.text-2xl').remove
13+
at_css('.text-2xl').name = 'h1'
1514
end
16-
css('.tw-8ej7ai').each do |node|
17-
code = node.at_css('.font-mono')
18-
next unless code
19-
code.parent.name = 'blockquote'
20-
code.name = 'code'
15+
16+
css('code').each do |node|
17+
if node['class']
18+
lang = node['class'][/language-(\w+)/, 1]
19+
end
20+
node['data-language'] = lang || 'ts'
21+
node.remove_attribute('class')
22+
if node.parent.name == 'div'
23+
node.content = node.content.strip
24+
end
2125
end
22-
css('*[class]').remove_attribute('class')
23-
xpath('//a[text()="[src]"]').remove
24-
26+
27+
css('a.header-anchor').remove()
28+
2529
doc
2630
end
2731
end

lib/docs/filters/deno/entries.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@ class Deno
33
class EntriesFilter < Docs::EntriesFilter
44

55
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
711
end
812

913
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
1121
end
1222

1323
end

lib/docs/scrapers/deno.rb

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,40 @@ module Docs
22
class Deno < UrlScraper
33
self.name = 'Deno'
44
self.type = 'simple'
5-
self.release = '1.27.0'
6-
self.base_url = 'https://doc.deno.land/deno/stable/'
75
self.links = {
8-
home: 'https://deno.land/',
6+
home: 'https://deno.com/',
97
code: 'https://github.com/denoland/deno'
108
}
119

12-
html_filters.push 'deno/entries', 'deno/clean_html'
13-
1410
# https://github.com/denoland/manual/blob/main/LICENSE
1511
options[:attribution] = <<-HTML
16-
&copy; 2018–2022 the Deno authors
12+
&copy; 2018–2024 the Deno authors<br>
13+
Licensed under the MIT License.
1714
HTML
1815

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+
1937
def get_latest_version(opts)
2038
get_latest_github_release('denoland', 'deno', opts)
21-
end
39+
end
2240
end
2341
end

0 commit comments

Comments
 (0)