History

Add Godot v3.4 and v3.5

Since v2 is included as one of the versions, I separated it into new files.

Gabriel Arazas committed 4 years ago

Commit 05244ef1 parent 3b2daf16 files · +106 −22Browse files

Unified · Split

6 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +3 −3
  2. lib/docs/filters/godot/clean_html.rb +1 −1
  3. lib/docs/filters/godot/clean_html_v2.rb +27 −0
  4. lib/docs/filters/godot/entries.rb +5 −11
  5. lib/docs/filters/godot/entries_v2.rb +45 −0
  6. lib/docs/scrapers/godot.rb +25 −7
assets/javascripts/templates/pages/about_tmpl.coffee+3−3
@@ -373,9 +373,9 @@ credits = [ · 372 unmodified lines
373373 'https://creativecommons.org/licenses/by/3.0/'
374374 ], [
375375 'Godot',
376− '2014-2021 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
377− 'MIT',
378− 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'
376+ '2014-2022 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
377+ 'CC BY 3.0',
378+ 'https://creativecommons.org/licenses/by/3.0/'
379379 ], [
380380 'Graphite',
381381 '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',
lib/docs/filters/godot/clean_html.rb+1−1
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
44 def call
55 if root_page?
66 at_css('h1').content = 'Godot Engine'
7− at_css('.admonition.tip').remove
7+ at_css('.admonition.note').remove
88 end
99
1010 css('ul[id].simple li:first-child:last-child').each do |node|
lib/docs/filters/godot/clean_html_v2.rb+27−0
@@ -0,0 +1,27 @@
1+module Docs
2+ class Godot
3+ class CleanHtmlV2Filter < Filter
4+ def call
5+ if root_page?
6+ at_css('h1').content = 'Godot Engine'
7+ at_css('.admonition.tip').remove
8+ end
9+
10+ css('ul[id].simple li:first-child:last-child').each do |node|
11+ heading = Nokogiri::XML::Node.new 'h3', doc.document
12+ heading['id'] = node.parent['id']
13+ heading.children = node.children
14+ node.parent.before(heading).remove
15+ end
16+
17+ css('h3 strong').each do |node|
18+ node.before(node.children).remove
19+ end
20+
21+ css('a.reference').remove_attr('class')
22+
23+ doc
24+ end
25+ end
26+ end
27+end
lib/docs/filters/godot/entries.rb+5−11
@@ -7,17 +7,11 @@ module Docs · 6 unmodified lines
77 name
88 end
99
10− TYPE_BY_LEARNING_PATH = {
11− 'step_by_step' => 'Guides: Step by step',
12− 'editor' => 'Guides: Editor',
13− 'features' => 'Guides: Engine features',
14− 'scripting' => 'Guides: Scripting',
15− 'workflow' => 'Guides: Project workflow'
16− }
17−
1810 def get_type
19− if slug.start_with?('learning')
20− TYPE_BY_LEARNING_PATH[slug.split('/')[1]]
11+ if slug.start_with?('getting_started')
12+ # Getting started sections are different even between different minor
13+ # versions from v3 so we're programmatically generating them instead.
14+ "Getting started: " + slug.split('/')[1].tr_s('_', ' ').capitalize
2115 else
2216 name
2317 end
@@ -36,7 +30,7 @@ module Docs · 12 unmodified lines
3630 end
3731
3832 def include_default_entry?
39− return false if subpath.start_with?('learning') && subpath.end_with?('index.html')
33+ return false if subpath.start_with?('getting_started') && subpath.end_with?('index.html')
4034 return false if subpath == 'classes/index.html'
4135 true
4236 end
lib/docs/filters/godot/entries_v2.rb+45−0
@@ -0,0 +1,45 @@
1+module Docs
2+ class Godot
3+ class EntriesV2Filter < Docs::EntriesFilter
4+ def get_name
5+ name = at_css('h1').content
6+ name.remove! "\u{00B6}" # Remove the pilcrow
7+ name
8+ end
9+
10+ TYPE_BY_LEARNING_PATH = {
11+ 'step_by_step' => 'Guides: Step by step',
12+ 'editor' => 'Guides: Editor',
13+ 'features' => 'Guides: Engine features',
14+ 'scripting' => 'Guides: Scripting',
15+ 'workflow' => 'Guides: Project workflow'
16+ }
17+
18+ def get_type
19+ if slug.start_with?('learning')
20+ TYPE_BY_LEARNING_PATH[slug.split('/')[1]]
21+ else
22+ name
23+ end
24+ end
25+
26+ def additional_entries
27+ return [] unless slug.start_with?('classes')
28+
29+ css('.simple[id]').each_with_object [] do |node, entries|
30+ name = node.at_css('strong').content
31+ next if name == self.name
32+ name.prepend "#{self.name}."
33+ name << '()'
34+ entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
35+ end
36+ end
37+
38+ def include_default_entry?
39+ return false if subpath.start_with?('learning') && subpath.end_with?('index.html')
40+ return false if subpath == 'classes/index.html'
41+ true
42+ end
43+ end
44+ end
45+end
lib/docs/scrapers/godot.rb+25−7
@@ -6,41 +6,59 @@ module Docs · 5 unmodified lines
66 code: 'https://github.com/godotengine/godot'
77 }
88
9− html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
10−
11− options[:download_images] = false
129 options[:container] = '.document .section'
1310
14− options[:only_patterns] = [/\Alearning\//, /\Aclasses\//]
15− options[:skip] = %w(classes/class_@global\ scope.html)
11+ options[:download_images] = false
12+ options[:only_patterns] = [/\Agetting_started\//, /\Aclasses\//]
1613
1714 options[:attribution] = ->(filter) do
1815 if filter.subpath.start_with?('classes')
1916 <<-HTML
20− &copy; 2014&ndash;2021 Juan Linietsky, Ariel Manzur, Godot Engine contributors<br>
17+ &copy; 2014&ndash;2022 Juan Linietsky, Ariel Manzur, Godot Engine contributors<br>
2118 Licensed under the MIT License.
2219 HTML
2320 else
2421 <<-HTML
25− &copy; 2014&ndash;2021 Juan Linietsky, Ariel Manzur and the Godot community<br>
22+ &copy; 2014&ndash;2022 Juan Linietsky, Ariel Manzur and the Godot community<br>
2623 Licensed under the Creative Commons Attribution Unported License v3.0.
2724 HTML
2825 end
2926 end
3027
28+ version '3.5' do
29+ self.release = '3.5.1'
30+ self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
31+ options[:container] = '.document > [itemprop="articleBody"] > section[id]'
32+ html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
33+ end
34+
35+ version '3.4' do
36+ self.release = '3.4.5'
37+ self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
38+ options[:container] = '.document > [itemprop="articleBody"] > section[id]'
39+ html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
40+ end
41+
3142 version '3.3' do
3243 self.release = '3.3.0'
3344 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
45+ html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
3446 end
3547
3648 version '3.2' do
3749 self.release = '3.2.3'
3850 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
51+ html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
3952 end
4053
4154 version '2.1' do
4255 self.release = '2.1.6'
4356 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
57+
58+ options[:skip] = %w(classes/class_@global\ scope.html)
59+ options[:only_patterns] = [/\Alearning\//, /\Aclasses\//]
60+
61+ html_filters.push 'godot/entries_v2', 'godot/clean_html_v2', 'sphinx/clean_html'
4462 end
4563
4664 def get_latest_version(opts)