-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1853 from foo-dogsquared/update-godot-scraper
Add Godot v3.4 and v3.5
- Loading branch information
Showing
6 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Docs | ||
class Godot | ||
class CleanHtmlV2Filter < Filter | ||
def call | ||
if root_page? | ||
at_css('h1').content = 'Godot Engine' | ||
at_css('.admonition.tip').remove | ||
end | ||
|
||
css('ul[id].simple li:first-child:last-child').each do |node| | ||
heading = Nokogiri::XML::Node.new 'h3', doc.document | ||
heading['id'] = node.parent['id'] | ||
heading.children = node.children | ||
node.parent.before(heading).remove | ||
end | ||
|
||
css('h3 strong').each do |node| | ||
node.before(node.children).remove | ||
end | ||
|
||
css('a.reference').remove_attr('class') | ||
|
||
doc | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Docs | ||
class Godot | ||
class EntriesV2Filter < Docs::EntriesFilter | ||
def get_name | ||
name = at_css('h1').content | ||
name.remove! "\u{00B6}" # Remove the pilcrow | ||
name | ||
end | ||
|
||
TYPE_BY_LEARNING_PATH = { | ||
'step_by_step' => 'Guides: Step by step', | ||
'editor' => 'Guides: Editor', | ||
'features' => 'Guides: Engine features', | ||
'scripting' => 'Guides: Scripting', | ||
'workflow' => 'Guides: Project workflow' | ||
} | ||
|
||
def get_type | ||
if slug.start_with?('learning') | ||
TYPE_BY_LEARNING_PATH[slug.split('/')[1]] | ||
else | ||
name | ||
end | ||
end | ||
|
||
def additional_entries | ||
return [] unless slug.start_with?('classes') | ||
|
||
css('.simple[id]').each_with_object [] do |node, entries| | ||
name = node.at_css('strong').content | ||
next if name == self.name | ||
name.prepend "#{self.name}." | ||
name << '()' | ||
entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name } | ||
end | ||
end | ||
|
||
def include_default_entry? | ||
return false if subpath.start_with?('learning') && subpath.end_with?('index.html') | ||
return false if subpath == 'classes/index.html' | ||
true | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters