Browse Source

Update Bun documentation (1.3.4)

Simon Legner 6 days ago
parent
commit
03cd3ae85e
3 changed files with 17 additions and 13 deletions
  1. 11 8
      lib/docs/filters/bun/clean_html.rb
  2. 2 2
      lib/docs/filters/bun/entries.rb
  3. 4 3
      lib/docs/scrapers/bun.rb

+ 11 - 8
lib/docs/filters/bun/clean_html.rb

@@ -2,7 +2,8 @@ module Docs
   class Bun
     class CleanHtmlFilter < Filter
       def call
-        @doc = at_css('section > .w-full')
+        @doc = at_css('#content-area')
+        doc.children = css('#header, #content')
 
         header = at_css('header:has(h1)')
         if header
@@ -10,14 +11,15 @@ module Docs
           header.name = 'h1'
         end
 
-        css('.CodeBlockTab').remove
-        css('.CopyIcon').remove
+        css('*[aria-label="Navigate to header"]', '*[aria-label="Copy the contents from the code block"]').each do |node|
+          node.parent.remove
+        end
+        css('img').remove
         css('svg').remove
-        css('a:contains("Edit on GitHub")').remove
-        css('a:contains("Previous")').remove
-        css('a:contains("Next")').remove
-
-        css('pre').each do |node|
+        
+        css('.code-block *[data-component-part="code-block-header"]').remove
+        css('.code-block', '.code-group').each do |node|
+          node.name = 'pre'
           node.content = node.content
           node['data-language'] = 'typescript'
           node.remove_attribute('style')
@@ -25,6 +27,7 @@ module Docs
 
         css('.font-mono').each do |node|
           node.name = 'code'
+          node.content = node.content
         end
 
         css('.font-mono.text-blue-600').each do |node|

+ 2 - 2
lib/docs/filters/bun/entries.rb

@@ -11,12 +11,12 @@ module Docs
       end
 
       def additional_entries
-        if slug.start_with?('cli')
+        if slug.start_with?('pm/cli')
           css('h2[id]').each_with_object [] do |node, entries|
             name = get_name + " " + node.content.strip
             entries << [name, node['id']]
           end
-        elsif slug.start_with?('api')
+        elsif slug.start_with?('runtime')
           css('h2[id]').each_with_object [] do |node, entries|
             name = get_name + ": " + node.content.strip
             entries << [name, node['id']]

+ 4 - 3
lib/docs/scrapers/bun.rb

@@ -7,7 +7,7 @@ module Docs
       home: 'https://leafletjs.com/',
       code: 'https://github.com/oven-sh/bun'
     }
-    self.release = '1.3.0'
+    self.release = '1.3.4'
     self.base_url = "https://bun.com/docs/"
     self.root_path = 'installation'
 
@@ -19,14 +19,15 @@ module Docs
       Licensed under the MIT License.
     HTML
 
-    options[:skip_patterns] = [/^project/]
+    options[:download_images] = false
+    options[:skip_patterns] = [/^project/, /^feedback/]
     options[:fix_urls] = ->(url) do
       url.sub! %r{.md$}, ''
       url
     end
 
     def get_latest_version(opts)
-      tags = get_github_tags('oven-sh', 'bun', opts)
+      get_latest_github_release('oven-sh', 'bun', opts)[5..]
     end
   end
 end