diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 2c393d97..b6c061b0 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2025-02-23", + "New documentation: Three.js" + ], [ "2025-02-16", "New documentation: OpenLayers" diff --git a/lib/docs/filters/threejs/clean_html.rb b/lib/docs/filters/threejs/clean_html.rb index 9b0de324..01f43bc4 100644 --- a/lib/docs/filters/threejs/clean_html.rb +++ b/lib/docs/filters/threejs/clean_html.rb @@ -36,8 +36,8 @@ module Docs def wrap_code_blocks css('code').each do |node| next if node.parent.name == 'pre' - pre = node.wrap('
')
-          pre['data-language'] = pre['class'] = 'language-javascript'
+          node.wrap('
')
+          node.parent['data-language'] = 'javascript'
         end
       end
 
@@ -45,7 +45,8 @@ module Docs
         # Handle source links
         css('h2').each do |node|
           next unless node.content.strip == 'Source'
-          handle_source_link(node)
+          node.next_element.remove
+          node.remove
         end
 
         # Handle method signatures and properties
@@ -65,17 +66,6 @@ module Docs
         end
       end
 
-      def handle_source_link(node)
-        content = node.next_element&.inner_html
-        return unless content
-        content = content.gsub(/<[^>]+>/, '')
-        if content =~ /src\/(.*?)\.js/
-          path = "/#{$1}.js"
-          formatted_link = %Q(src#{path})
-          node.next_element.inner_html = formatted_link if node.next_element
-        end
-      end
-
       def handle_method_signatures(content)
         content
           .gsub(PATTERNS[:method_this]) { format_method_signature('this', $1, $2) }
diff --git a/lib/docs/scrapers/threejs.rb b/lib/docs/scrapers/threejs.rb
index e596e034..c3ef9bc2 100644
--- a/lib/docs/scrapers/threejs.rb
+++ b/lib/docs/scrapers/threejs.rb
@@ -1,5 +1,5 @@
 module Docs
-  class Threejs < FileScraper
+  class Threejs < UrlScraper
     self.name = 'Three.js'
     self.type = 'simple'
     self.slug = 'threejs'
@@ -40,20 +40,18 @@ module Docs
       Licensed under the MIT License.
     HTML
 
-    version '171' do
-      self.release = '171'
-      self.base_url = "https://threejs.org/docs"
-    end
+    self.release = '173'
+    self.base_url = "https://threejs.org/docs"
 
     def get_latest_version(opts)
-      get_latest_github_release('mrdoob', 'three.js', opts)
+      get_latest_github_release('mrdoob', 'three.js', opts)[1..]
     end
 
     def initial_paths
       paths = []
-      json_path = File.expand_path("/tmp/list.json")
-      json_content = File.read(json_path)
-      json_data = JSON.parse(json_content)
+      url = 'https://threejs.org/docs/list.json'
+      response = Request.run(url)
+      json_data = JSON.parse(response.body)
 
       # Process both API and manual sections
       process_documentation(json_data['en'], paths)