Since v2 is included as one of the versions, I separated it into new files.
Unified · Split
| @@ -373,9 +373,9 @@ credits = [ · 372 unmodified lines | ||
| 373 | 373 | 'https://creativecommons.org/licenses/by/3.0/' |
| 374 | 374 | ], [ |
| 375 | 375 | '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/' | |
| 379 | 379 | ], [ |
| 380 | 380 | 'Graphite', |
| 381 | 381 | '2008-2012 Chris Davis<br>© 2011-2016 The Graphite Project', |
| @@ -4,7 +4,7 @@ module Docs · 3 unmodified lines | ||
| 4 | 4 | def call |
| 5 | 5 | if root_page? |
| 6 | 6 | at_css('h1').content = 'Godot Engine' |
| 7 | − at_css('.admonition.tip').remove | |
| 7 | + at_css('.admonition.note').remove | |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | css('ul[id].simple li:first-child:last-child').each do |node| |
| @@ -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 | |
| @@ -7,17 +7,11 @@ module Docs · 6 unmodified lines | ||
| 7 | 7 | name |
| 8 | 8 | 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 | 10 | 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 | |
| 21 | 15 | else |
| 22 | 16 | name |
| 23 | 17 | end |
| @@ -36,7 +30,7 @@ module Docs · 12 unmodified lines | ||
| 36 | 30 | end |
| 37 | 31 | |
| 38 | 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 | 34 | return false if subpath == 'classes/index.html' |
| 41 | 35 | true |
| 42 | 36 | end |
| @@ -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 | |
| @@ -6,41 +6,59 @@ module Docs · 5 unmodified lines | ||
| 6 | 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 | 9 | options[:container] = '.document .section' |
| 13 | 10 | |
| 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\//] | |
| 16 | 13 | |
| 17 | 14 | options[:attribution] = ->(filter) do |
| 18 | 15 | if filter.subpath.start_with?('classes') |
| 19 | 16 | <<-HTML |
| 20 | − © 2014–2021 Juan Linietsky, Ariel Manzur, Godot Engine contributors<br> | |
| 17 | + © 2014–2022 Juan Linietsky, Ariel Manzur, Godot Engine contributors<br> | |
| 21 | 18 | Licensed under the MIT License. |
| 22 | 19 | HTML |
| 23 | 20 | else |
| 24 | 21 | <<-HTML |
| 25 | − © 2014–2021 Juan Linietsky, Ariel Manzur and the Godot community<br> | |
| 22 | + © 2014–2022 Juan Linietsky, Ariel Manzur and the Godot community<br> | |
| 26 | 23 | Licensed under the Creative Commons Attribution Unported License v3.0. |
| 27 | 24 | HTML |
| 28 | 25 | end |
| 29 | 26 | 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 | 42 | version '3.3' do |
| 32 | 43 | self.release = '3.3.0' |
| 33 | 44 | self.base_url = "https://docs.godotengine.org/en/#{self.version}/" |
| 45 | + html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html' | |
| 34 | 46 | end |
| 35 | 47 | |
| 36 | 48 | version '3.2' do |
| 37 | 49 | self.release = '3.2.3' |
| 38 | 50 | self.base_url = "https://docs.godotengine.org/en/#{self.version}/" |
| 51 | + html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html' | |
| 39 | 52 | end |
| 40 | 53 | |
| 41 | 54 | version '2.1' do |
| 42 | 55 | self.release = '2.1.6' |
| 43 | 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 | 62 | end |
| 45 | 63 | |
| 46 | 64 | def get_latest_version(opts) |