Skip to content

Commit 6dbe834

Browse files
committed
Update Three.js documentation (173)
1 parent 74aa661 commit 6dbe834

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

assets/javascripts/news.json

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
[
3+
"2025-02-23",
4+
"New documentation: <a href=\"/threejs/\">Three.js</a>"
5+
],
26
[
37
"2025-02-16",
48
"New documentation: <a href=\"/openlayers/\">OpenLayers</a>"

lib/docs/filters/threejs/clean_html.rb

+4-14
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ def remove_unnecessary_elements
3636
def wrap_code_blocks
3737
css('code').each do |node|
3838
next if node.parent.name == 'pre'
39-
pre = node.wrap('<pre>')
40-
pre['data-language'] = pre['class'] = 'language-javascript'
39+
node.wrap('<pre>')
40+
node.parent['data-language'] = 'javascript'
4141
end
4242
end
4343

4444
def process_sections
4545
# Handle source links
4646
css('h2').each do |node|
4747
next unless node.content.strip == 'Source'
48-
handle_source_link(node)
48+
node.next_element.remove
49+
node.remove
4950
end
5051

5152
# Handle method signatures and properties
@@ -65,17 +66,6 @@ def process_sections
6566
end
6667
end
6768

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-
7969
def handle_method_signatures(content)
8070
content
8171
.gsub(PATTERNS[:method_this]) { format_method_signature('this', $1, $2) }

lib/docs/scrapers/threejs.rb

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Docs
2-
class Threejs < FileScraper
2+
class Threejs < UrlScraper
33
self.name = 'Three.js'
44
self.type = 'simple'
55
self.slug = 'threejs'
@@ -40,20 +40,18 @@ class Threejs < FileScraper
4040
Licensed under the MIT License.
4141
HTML
4242

43-
version '171' do
44-
self.release = '171'
45-
self.base_url = "https://threejs.org/docs"
46-
end
43+
self.release = '173'
44+
self.base_url = "https://threejs.org/docs"
4745

4846
def get_latest_version(opts)
49-
get_latest_github_release('mrdoob', 'three.js', opts)
47+
get_latest_github_release('mrdoob', 'three.js', opts)[1..]
5048
end
5149

5250
def initial_paths
5351
paths = []
54-
json_path = File.expand_path("/tmp/list.json")
55-
json_content = File.read(json_path)
56-
json_data = JSON.parse(json_content)
52+
url = 'https://threejs.org/docs/list.json'
53+
response = Request.run(url)
54+
json_data = JSON.parse(response.body)
5755

5856
# Process both API and manual sections
5957
process_documentation(json_data['en'], paths)

0 commit comments

Comments
 (0)