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.
Unified · Split
| @@ -0,0 +1,11 @@ | ||
| 1 | +module Docs | |
| 2 | + class Godot | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + @doc = at_css('.document .section') | |
| 6 | + | |
| 7 | + doc | |
| 8 | + end | |
| 9 | + end | |
| 10 | + end | |
| 11 | +end | |
| @@ -0,0 +1,35 @@ | ||
| 1 | +module Docs | |
| 2 | + class Godot | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('.document h1').content | |
| 6 | + name.remove! "\u{00B6}" # Remove the pilcrow | |
| 7 | + name | |
| 8 | + end | |
| 9 | + | |
| 10 | + def get_type | |
| 11 | + if slug.start_with?('learning') | |
| 12 | + 'Learning' | |
| 13 | + else | |
| 14 | + 'API Reference' | |
| 15 | + end | |
| 16 | + end | |
| 17 | + | |
| 18 | + def additional_entries | |
| 19 | + return [] unless slug.start_with?('classes') | |
| 20 | + class_name = at_css('h1').content | |
| 21 | + class_name.remove! "\u{00B6}" # Remove the pilcrow | |
| 22 | + entries = [] | |
| 23 | + | |
| 24 | + # Each page represents a class, and class methods are defined in | |
| 25 | + # individual sections. | |
| 26 | + css('.simple[id]').each do |node| | |
| 27 | + fn_name = node.at_css('strong') | |
| 28 | + entries << [class_name + '.' + fn_name + '()', node['id']] | |
| 29 | + end | |
| 30 | + | |
| 31 | + entries | |
| 32 | + end | |
| 33 | + end | |
| 34 | + end | |
| 35 | +end | |
| @@ -0,0 +1,25 @@ | ||
| 1 | +module Docs | |
| 2 | + class Godot < UrlScraper | |
| 3 | + self.type = 'sphinx_simple' | |
| 4 | + self.links = { | |
| 5 | + home: 'https://godotengine.org/', | |
| 6 | + code: 'https://github.com/godotengine/godot' | |
| 7 | + } | |
| 8 | + | |
| 9 | + html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html' | |
| 10 | + | |
| 11 | + # `learning/` contains the guided learning materials, and `classes/` | |
| 12 | + # contains the API reference. | |
| 13 | + options[:only_patterns] = [/\Alearning\//, /\Aclasses\//] | |
| 14 | + | |
| 15 | + options[:attribution] = <<-HTML | |
| 16 | + © Copyright 2014–2017, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0). | |
| 17 | + HTML | |
| 18 | + | |
| 19 | + version '2.1' do | |
| 20 | + self.release = '2.1' | |
| 21 | + self.base_url = "http://docs.godotengine.org/en/#{self.version}/" | |
| 22 | + end | |
| 23 | + | |
| 24 | + end | |
| 25 | +end | |
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | ||
| 1 | +https://godotengine.org/themes/godotengine/assets/favicon.png | |