Skip to content

Commit 0733738

Browse files
updated deno version
1 parent c07ccf5 commit 0733738

File tree

3 files changed

+49
-25
lines changed

3 files changed

+49
-25
lines changed

lib/docs/filters/deno/clean_html.rb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@ 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+
css('code').each do |node|
12+
if node['class']
13+
lang = node['class'][/language-(\w+)/, 1]
14+
end
15+
node['data-language'] = lang || 'ts'
16+
node.remove_attribute('class')
1517
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'
21-
end
22-
css('*[class]').remove_attribute('class')
23-
xpath('//a[text()="[src]"]').remove
24-
18+
19+
css('a.header-anchor').remove()
20+
2521
doc
2622
end
2723
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)