Unified · Split
| @@ -1,4 +1,8 @@ | |||
| 1 | [ | 1 | [ |
| 2 | [ | ||
| 3 | "2025-02-23", | ||
| 4 | "New documentation: <a href=\"/threejs/\">Three.js</a>" | ||
| 5 | ], | ||
| 2 | [ | 6 | [ |
| 3 | "2025-02-16", | 7 | "2025-02-16", |
| 4 | "New documentation: <a href=\"/openlayers/\">OpenLayers</a>" | 8 | "New documentation: <a href=\"/openlayers/\">OpenLayers</a>" |
| @@ -36,8 +36,8 @@ module Docs · 35 unmodified lines | |||
| 36 | def wrap_code_blocks | 36 | def wrap_code_blocks |
| 37 | css('code').each do |node| | 37 | css('code').each do |node| |
| 38 | next if node.parent.name == 'pre' | 38 | next if node.parent.name == 'pre' |
| 39 | pre = node.wrap('<pre>') | 39 | node.wrap('<pre>') |
| 40 | pre['data-language'] = pre['class'] = 'language-javascript' | 40 | node.parent['data-language'] = 'javascript' |
| 41 | end | 41 | end |
| 42 | end | 42 | end |
| 43 | 43 | ||
| @@ -45,7 +45,8 @@ module Docs · 1 unmodified line | |||
| 45 | # Handle source links | 45 | # Handle source links |
| 46 | css('h2').each do |node| | 46 | css('h2').each do |node| |
| 47 | next unless node.content.strip == 'Source' | 47 | next unless node.content.strip == 'Source' |
| 48 | handle_source_link(node) | 48 | node.next_element.remove |
| 49 | node.remove | ||
| 49 | end | 50 | end |
| 50 | 51 | ||
| 51 | # Handle method signatures and properties | 52 | # Handle method signatures and properties |
| @@ -65,17 +66,6 @@ module Docs · 13 unmodified lines | |||
| 65 | end | 66 | end |
| 66 | end | 67 | end |
| 67 | 68 | ||
| 68 | def handle_source_link(node) | ||
| 69 | content = node.next_element&.inner_html | ||
| 70 | return unless content | ||
| 71 | content = content.gsub(/<[^>]+>/, '') | ||
| 72 | if content =~ /src\/(.*?)\.js/ | ||
| 73 | path = "/#{$1}.js" | ||
| 74 | formatted_link = %Q(<a class="reference external" href="https://github.com/mrdoob/three.js/blob/master/src#{path}">src#{path}</a>) | ||
| 75 | node.next_element.inner_html = formatted_link if node.next_element | ||
| 76 | end | ||
| 77 | end | ||
| 78 | |||
| 79 | def handle_method_signatures(content) | 69 | def handle_method_signatures(content) |
| 80 | content | 70 | content |
| 81 | .gsub(PATTERNS[:method_this]) { format_method_signature('this', $1, $2) } | 71 | .gsub(PATTERNS[:method_this]) { format_method_signature('this', $1, $2) } |
| @@ -1,5 +1,5 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Threejs < FileScraper | 2 | class Threejs < UrlScraper |
| 3 | self.name = 'Three.js' | 3 | self.name = 'Three.js' |
| 4 | self.type = 'simple' | 4 | self.type = 'simple' |
| 5 | self.slug = 'threejs' | 5 | self.slug = 'threejs' |
| @@ -40,20 +40,18 @@ module Docs · 34 unmodified lines | |||
| 40 | Licensed under the MIT License. | 40 | Licensed under the MIT License. |
| 41 | HTML | 41 | HTML |
| 42 | 42 | ||
| 43 | version '171' do | 43 | self.release = '173' |
| 44 | self.release = '171' | 44 | self.base_url = "https://threejs.org/docs" |
| 45 | self.base_url = "https://threejs.org/docs" | ||
| 46 | end | ||
| 47 | 45 | ||
| 48 | def get_latest_version(opts) | 46 | def get_latest_version(opts) |
| 49 | get_latest_github_release('mrdoob', 'three.js', opts) | 47 | get_latest_github_release('mrdoob', 'three.js', opts)[1..] |
| 50 | end | 48 | end |
| 51 | 49 | ||
| 52 | def initial_paths | 50 | def initial_paths |
| 53 | paths = [] | 51 | paths = [] |
| 54 | json_path = File.expand_path("/tmp/list.json") | 52 | url = 'https://threejs.org/docs/list.json' |
| 55 | json_content = File.read(json_path) | 53 | response = Request.run(url) |
| 56 | json_data = JSON.parse(json_content) | 54 | json_data = JSON.parse(response.body) |
| 57 | 55 | ||
| 58 | # Process both API and manual sections | 56 | # Process both API and manual sections |
| 59 | process_documentation(json_data['en'], paths) | 57 | process_documentation(json_data['en'], paths) |