Skip to content

Commit

Permalink
Merge pull request #2372 from ruiiiijiiiiang/feature/update-deno-version
Browse files Browse the repository at this point in the history
Updated deno version (1.27.0 -> 2.1.1)
  • Loading branch information
simon04 authored Dec 7, 2024
2 parents 495e8b6 + de294da commit 30f4e5b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
34 changes: 19 additions & 15 deletions lib/docs/filters/deno/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ module Docs
class Deno
class CleanHtmlFilter < Filter
def call
if root_page?
@doc = at_css('h2[id]').parent.parent
if result[:path].start_with?('api/deno/')
@doc = at_css('main')
else
@doc = at_css('article')
@doc = at_css('main article .markdown-body')
end

css('*[aria-label="Anchor"]').remove
css('pre', '.tw-1nkr705').each do |node|
node['data-language'] = 'typescript'
node.name = 'pre'
if at_css('.text-2xl')
doc.prepend_child at_css('.text-2xl').remove
at_css('.text-2xl').name = 'h1'
end
css('.tw-8ej7ai').each do |node|
code = node.at_css('.font-mono')
next unless code
code.parent.name = 'blockquote'
code.name = 'code'

css('code').each do |node|
if node['class']
lang = node['class'][/language-(\w+)/, 1]
end
node['data-language'] = lang || 'ts'
node.remove_attribute('class')
if node.parent.name == 'div'
node.content = node.content.strip
end
end
css('*[class]').remove_attribute('class')
xpath('//a[text()="[src]"]').remove

css('a.header-anchor').remove()

doc
end
end
Expand Down
14 changes: 12 additions & 2 deletions lib/docs/filters/deno/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ class Deno
class EntriesFilter < Docs::EntriesFilter

def get_name
at_css('h1').content
if result[:path].start_with?('api/deno/')
at_css('main')['id'][/\Asymbol_([.\w]+)/, 1]
else
at_css('main article h1').content
end
end

def get_type
'Deno CLI APIs'
if result[:path].start_with?('api/deno/')
'API'
elsif result[:path].start_with?('runtime/reference/cli')
'CLI'
else
at_css('main article nav ul :first span').content
end
end

end
Expand Down
32 changes: 25 additions & 7 deletions lib/docs/scrapers/deno.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@ module Docs
class Deno < UrlScraper
self.name = 'Deno'
self.type = 'simple'
self.release = '1.27.0'
self.base_url = 'https://doc.deno.land/deno/stable/'
self.links = {
home: 'https://deno.land/',
home: 'https://deno.com/',
code: 'https://github.com/denoland/deno'
}

html_filters.push 'deno/entries', 'deno/clean_html'

# https://github.com/denoland/manual/blob/main/LICENSE
options[:attribution] = <<-HTML
&copy; 2018–2022 the Deno authors
&copy; 2018–2024 the Deno authors<br>
Licensed under the MIT License.
HTML


html_filters.push 'deno/entries', 'deno/clean_html'

version '2' do
self.release = '2.1.1'
self.base_url = 'https://docs.deno.com/'
self.root_path = 'runtime'
options[:only_patterns] = [/\Aruntime/, /\Aapi\/deno\/~/, /\Adeploy/, /\Asubhosting/]
options[:skip_patterns] = [
/\Aruntime\/manual/,
/\Aapi\/deno\/.+\.prototype\z/, # all prototype pages get redirected to the main page
/\Aapi\/deno\/~\/Deno\.jupyter\.MediaBundle.+/, # docs unavailable
/\Aapi\/deno\/~\/Deno\.OpMetrics/, # deprecated in deno 2
]
options[:trailing_slash] = false
end

version '1' do
self.release = '1.27.0'
end

def get_latest_version(opts)
get_latest_github_release('denoland', 'deno', opts)
end
end
end
end

0 comments on commit 30f4e5b

Please sign in to comment.