Finish Godot scraper

pull/656/head
Thibaut Courouble 8 years ago
parent d69f4f6473
commit 854cebd257

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 31 KiB

@ -1,5 +1,8 @@
[
[
"2017-07-23",
"New documentation: <a href=\"/godot/\">Godot</a>"
], [
"2017-06-04",
"New documentations: <a href=\"/electron/\">Electron</a>, <a href=\"/pug/\">Pug</a>, and <a href=\"/falcon/\">Falcon</a>"
], [

@ -268,6 +268,11 @@ credits = [
'Google, Inc.',
'CC BY',
'https://creativecommons.org/licenses/by/3.0/'
], [
'Godot',
'2014-2017 Juan Linietsky, Ariel Manzur, Godot Engine contributors',
'MIT',
'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt'
], [
'Grunt',
'GruntJS Team',

@ -175,3 +175,4 @@
._icon-pug:before { background-position: -1rem -2rem; @extend %doc-icon-2; }
._icon-electron:before { background-position: -2rem -2rem; @extend %doc-icon-2; }
._icon-falcon:before { background-position: -3rem -2rem; @extend %doc-icon-2; }
._icon-godot:before { background-position: -4rem -2rem; @extend %doc-icon-2; }

@ -3,6 +3,7 @@
.admonition { @extend %note; }
.admonition.warning { @extend %note-orange; }
.admonition.tip { @extend %note-green; }
.admonition-title {
margin: 0 0 .25rem;
font-weight: $boldFontWeight;

@ -2,7 +2,23 @@ module Docs
class Godot
class CleanHtmlFilter < Filter
def call
@doc = at_css('.document .section')
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
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

@ -2,33 +2,43 @@ module Docs
class Godot
class EntriesFilter < Docs::EntriesFilter
def get_name
name = at_css('.document h1').content
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')
'Learning'
TYPE_BY_LEARNING_PATH[slug.split('/')[1]]
else
'API Reference'
name
end
end
def additional_entries
return [] unless slug.start_with?('classes')
class_name = at_css('h1').content
class_name.remove! "\u{00B6}" # Remove the pilcrow
entries = []
# Each page represents a class, and class methods are defined in
# individual sections.
css('.simple[id]').each do |node|
fn_name = node.at_css('strong')
entries << [class_name + '.' + fn_name + '()', node['id']]
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
entries
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

@ -87,9 +87,7 @@ module Docs
node.remove_attribute 'cellspacing'
end
css('code[class]').each do |node|
node.remove_attribute 'class'
end
css('code', 'tr').remove_attr('class')
css('h1').each do |node|
node.content = node.content

@ -8,18 +8,29 @@ module Docs
html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
# `learning/` contains the guided learning materials, and `classes/`
# contains the API reference.
options[:download_images] = false
options[:container] = '.document .section'
options[:only_patterns] = [/\Alearning\//, /\Aclasses\//]
options[:skip] = %w(classes/class_@global\ scope.html)
options[:attribution] = <<-HTML
&copy; Copyright 2014&ndash;2017, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0).
HTML
options[:attribution] = ->(filter) do
if filter.subpath.start_with?('classes')
<<-HTML
&copy; 2014&ndash;2017 Juan Linietsky, Ariel Manzur, Godot Engine contributors<br>
Licensed under the MIT License.
HTML
else
<<-HTML
&copy; 2014&ndash;2017 Juan Linietsky, Ariel Manzur and the Godot community<br>
Licensed under the Creative Commons Attribution Unported License v3.0.
HTML
end
end
version '2.1' do
self.release = '2.1'
self.base_url = "http://docs.godotengine.org/en/#{self.version}/"
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Loading…
Cancel
Save