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
373 'https://creativecommons.org/licenses/by/3.0/'373 'https://creativecommons.org/licenses/by/3.0/'
374 ], [374 ], [
375 'Godot',375 'Godot',
376 '2014-2021 Juan Linietsky, Ariel Manzur, Godot Engine contributors',376 '2014-2022 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
377 'MIT',377 'CC BY 3.0',
378 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'378 'https://creativecommons.org/licenses/by/3.0/'
379 ], [379 ], [
380 'Graphite',380 'Graphite',
381 '2008-2012 Chris Davis<br>&copy; 2011-2016 The Graphite Project',381 '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
4 def call4 def call
5 if root_page?5 if root_page?
6 at_css('h1').content = 'Godot Engine'6 at_css('h1').content = 'Godot Engine'
7 at_css('.admonition.tip').remove7 at_css('.admonition.note').remove
8 end8 end
9 9
10 css('ul[id].simple li:first-child:last-child').each do |node|10 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 @@
1module 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
27end
lib/docs/filters/godot/entries.rb+5−11
@@ -7,17 +7,11 @@ module Docs · 6 unmodified lines
7 name7 name
8 end8 end
9 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_type10 def get_type
19 if slug.start_with?('learning')11 if slug.start_with?('getting_started')
20 TYPE_BY_LEARNING_PATH[slug.split('/')[1]]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
21 else15 else
22 name16 name
23 end17 end
@@ -36,7 +30,7 @@ module Docs · 12 unmodified lines
36 end30 end
37 31
38 def include_default_entry?32 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')
40 return false if subpath == 'classes/index.html'34 return false if subpath == 'classes/index.html'
41 true35 true
42 end36 end
lib/docs/filters/godot/entries_v2.rb+45−0
@@ -0,0 +1,45 @@
1module 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
45end
lib/docs/scrapers/godot.rb+25−7
@@ -6,41 +6,59 @@ module Docs · 5 unmodified lines
6 code: 'https://github.com/godotengine/godot'6 code: 'https://github.com/godotengine/godot'
7 }7 }
8 8
9 html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
10
11 options[:download_images] = false
12 options[:container] = '.document .section'9 options[:container] = '.document .section'
13 10
14 options[:only_patterns] = [/\Alearning\//, /\Aclasses\//]11 options[:download_images] = false
15 options[:skip] = %w(classes/class_@global\ scope.html)12 options[:only_patterns] = [/\Agetting_started\//, /\Aclasses\//]
16 13
17 options[:attribution] = ->(filter) do14 options[:attribution] = ->(filter) do
18 if filter.subpath.start_with?('classes')15 if filter.subpath.start_with?('classes')
19 <<-HTML16 <<-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>
21 Licensed under the MIT License.18 Licensed under the MIT License.
22 HTML19 HTML
23 else20 else
24 <<-HTML21 <<-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>
26 Licensed under the Creative Commons Attribution Unported License v3.0.23 Licensed under the Creative Commons Attribution Unported License v3.0.
27 HTML24 HTML
28 end25 end
29 end26 end
30 27
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
31 version '3.3' do42 version '3.3' do
32 self.release = '3.3.0'43 self.release = '3.3.0'
33 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"44 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
45 html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
34 end46 end
35 47
36 version '3.2' do48 version '3.2' do
37 self.release = '3.2.3'49 self.release = '3.2.3'
38 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"50 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
51 html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
39 end52 end
40 53
41 version '2.1' do54 version '2.1' do
42 self.release = '2.1.6'55 self.release = '2.1.6'
43 self.base_url = "https://docs.godotengine.org/en/#{self.version}/"56 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'
44 end62 end
45 63
46 def get_latest_version(opts)64 def get_latest_version(opts)