diff --git a/lib/docs/filters/godot/clean_html.rb b/lib/docs/filters/godot/clean_html.rb new file mode 100644 index 00000000..8d9cc7e4 --- /dev/null +++ b/lib/docs/filters/godot/clean_html.rb @@ -0,0 +1,11 @@ +module Docs + class Godot + class CleanHtmlFilter < Filter + def call + @doc = at_css('.document .section') + + doc + end + end + end +end diff --git a/lib/docs/filters/godot/entries.rb b/lib/docs/filters/godot/entries.rb new file mode 100644 index 00000000..5f678a99 --- /dev/null +++ b/lib/docs/filters/godot/entries.rb @@ -0,0 +1,35 @@ +module Docs + class Godot + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('.document h1').content + name.remove! "\u{00B6}" # Remove the pilcrow + name + end + + def get_type + if slug.start_with?('learning') + 'Learning' + else + 'API Reference' + 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']] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/godot.rb b/lib/docs/scrapers/godot.rb new file mode 100644 index 00000000..34cfc9eb --- /dev/null +++ b/lib/docs/scrapers/godot.rb @@ -0,0 +1,25 @@ +module Docs + class Godot < UrlScraper + self.type = 'sphinx_simple' + self.links = { + home: 'https://godotengine.org/', + code: 'https://github.com/godotengine/godot' + } + + html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html' + + # `learning/` contains the guided learning materials, and `classes/` + # contains the API reference. + options[:only_patterns] = [/\Alearning\//, /\Aclasses\//] + + options[:attribution] = <<-HTML + © Copyright 2014–2017, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0). + HTML + + version '2.1' do + self.release = '2.1' + self.base_url = "http://docs.godotengine.org/en/#{self.version}/" + end + + end +end diff --git a/public/icons/docs/godot/16.png b/public/icons/docs/godot/16.png new file mode 100644 index 00000000..bd947c25 Binary files /dev/null and b/public/icons/docs/godot/16.png differ diff --git a/public/icons/docs/godot/16@2x.png b/public/icons/docs/godot/16@2x.png new file mode 100644 index 00000000..4411cbae Binary files /dev/null and b/public/icons/docs/godot/16@2x.png differ diff --git a/public/icons/docs/godot/SOURCE b/public/icons/docs/godot/SOURCE new file mode 100644 index 00000000..6cdf24b9 --- /dev/null +++ b/public/icons/docs/godot/SOURCE @@ -0,0 +1 @@ +https://godotengine.org/themes/godotengine/assets/favicon.png