Selaa lähdekoodia

Add Godot documentation.

The associated filter categorizes all API docs under a single "API
reference" type. I originally had a separate type per class (the godot
API docs are organized by class), but that resulted in >300 types.
Zaven Muradyan 8 vuotta sitten
vanhempi
commit
d69f4f6473

+ 11 - 0
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

+ 35 - 0
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

+ 25 - 0
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
+      &copy; Copyright 2014&ndash;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

BIN
public/icons/docs/godot/16.png


BIN
public/icons/docs/godot/16@2x.png


+ 1 - 0
public/icons/docs/godot/SOURCE

@@ -0,0 +1 @@
+https://godotengine.org/themes/godotengine/assets/favicon.png