History

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 committed 9 years ago

Commit d69f4f61 parent 1c6c7c06 files · +70 −-2Browse files

Unified · Split

6 files
  1. lib/docs/filters/godot/clean_html.rb +11 −0
  2. lib/docs/filters/godot/entries.rb +35 −0
  3. lib/docs/scrapers/godot.rb +25 −0
  4. public/icons/docs/godot/16.png +0 −0
  5. public/icons/docs/godot/16@2x.png +0 −0
  6. public/icons/docs/godot/SOURCE +1 −0
lib/docs/filters/godot/clean_html.rb+11−0
@@ -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
lib/docs/filters/godot/entries.rb+35−0
@@ -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
lib/docs/scrapers/godot.rb+25−0
@@ -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+ &copy; Copyright 2014&ndash;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
public/icons/docs/godot/16.png+0−0

Binary file not shown.

public/icons/docs/godot/16@2x.png+0−0

Binary file not shown.

public/icons/docs/godot/SOURCE+1−0
@@ -0,0 +1 @@
1+https://godotengine.org/themes/godotengine/assets/favicon.png