1
0
Эх сурвалжийг харах

Merge pull request #2372 from ruiiiijiiiiang/feature/update-deno-version

Updated deno version (1.27.0 -> 2.1.1)
Simon Legner 1 жил өмнө
parent
commit
30f4e5b41b

+ 19 - 15
lib/docs/filters/deno/clean_html.rb

@@ -2,26 +2,30 @@ module Docs
   class Deno
   class Deno
     class CleanHtmlFilter < Filter
     class CleanHtmlFilter < Filter
       def call
       def call
-        if root_page?
-          @doc = at_css('h2[id]').parent.parent
+        if result[:path].start_with?('api/deno/')
+          @doc = at_css('main')
         else
         else
-          @doc = at_css('article')
+          @doc = at_css('main article .markdown-body')
         end
         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
         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
         end
-        css('*[class]').remove_attribute('class')
-        xpath('//a[text()="[src]"]').remove
-        
+
+        css('a.header-anchor').remove()
+
         doc
         doc
       end
       end
     end
     end

+ 12 - 2
lib/docs/filters/deno/entries.rb

@@ -3,11 +3,21 @@ module Docs
     class EntriesFilter < Docs::EntriesFilter
     class EntriesFilter < Docs::EntriesFilter
 
 
       def get_name
       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
       end
 
 
       def get_type
       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
 
 
     end
     end

+ 25 - 7
lib/docs/scrapers/deno.rb

@@ -2,22 +2,40 @@ module Docs
   class Deno < UrlScraper
   class Deno < UrlScraper
     self.name = 'Deno'
     self.name = 'Deno'
     self.type = 'simple'
     self.type = 'simple'
-    self.release = '1.27.0'
-    self.base_url = 'https://doc.deno.land/deno/stable/'
     self.links = {
     self.links = {
-      home: 'https://deno.land/',
+      home: 'https://deno.com/',
       code: 'https://github.com/denoland/deno'
       code: 'https://github.com/denoland/deno'
     }
     }
 
 
-    html_filters.push 'deno/entries', 'deno/clean_html'
-
     # https://github.com/denoland/manual/blob/main/LICENSE
     # https://github.com/denoland/manual/blob/main/LICENSE
     options[:attribution] = <<-HTML
     options[:attribution] = <<-HTML
-      &copy; 2018–2022 the Deno authors
+      &copy; 2018–2024 the Deno authors<br>
+      Licensed under the MIT License.
     HTML
     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)
     def get_latest_version(opts)
       get_latest_github_release('denoland', 'deno', opts)
       get_latest_github_release('denoland', 'deno', opts)
-      end
+    end
   end
   end
 end
 end