History

OpenTSDB 2.1 Documentation

Yosi Attias committed 11 years ago

Commit f6df8471 parent b9a038d8 files · +77 −0Browse files

Showing the changes to lib/docs (3 of 8 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/opentsdb/clean_html.rb +16 −0
  2. lib/docs/filters/opentsdb/entries.rb +35 −0
  3. lib/docs/scrapers/opentsdb.rb +19 −0
lib/docs/filters/opentsdb/clean_html.rb+16−0
@@ -0,0 +1,16 @@
1+module Docs
2+ class Opentsdb
3+ class CleanHtmlFilter < Filter
4+ def call
5+ # Reset the page scope to the body,
6+ # we needed the rest of the page for the entries filter.
7+ @doc = at_css(".documentwrapper > .bodywrapper > .body > .section")
8+
9+ # Remove table borders
10+ css('table').each { |table| table.delete 'border' }
11+
12+ doc
13+ end
14+ end
15+ end
16+end
lib/docs/filters/opentsdb/entries.rb+35−0
@@ -0,0 +1,35 @@
1+module Docs
2+ class Opentsdb
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def get_name
6+ header = css(".section > h1").first
7+ return header.content.strip unless header.nil?
8+ end
9+
10+ def get_type
11+ return nil if breadcrumbs.length < 2
12+
13+ # This is time for a little bit of cheating
14+ return breadcrumbs[1] if breadcrumbs.include? "HTTP API"
15+
16+ breadcrumbs.last
17+ end
18+
19+ def additional_entries
20+ []
21+ end
22+
23+
24+ def breadcrumbs
25+ nav_links = css(".related").first.css("li")
26+ breadcrumbs = nav_links.reject do |node|
27+ node['class'] == "right"
28+ end
29+
30+ breadcrumbs.map { |node| node.at_css("a").content }
31+ .reject { |link| link.empty? }
32+ end
33+ end
34+ end
35+end
lib/docs/scrapers/opentsdb.rb+19−0
@@ -0,0 +1,19 @@
1+module Docs
2+ class Opentsdb < UrlScraper
3+ self.name = 'OpenTSDB'
4+ self.type = 'opentsdb'
5+ self.version = '2.1'
6+ self.base_url = 'http://opentsdb.net/docs/build/html/'
7+ self.root_path = 'index.html'
8+
9+ html_filters.push 'opentsdb/entries', 'opentsdb/clean_html'
10+
11+
12+ options[:skip] = %w(genindex.html search.html)
13+
14+
15+ options[:attribution] = <<-HTML
16+ &copy; 2015 OpenTSDB
17+ HTML
18+ end
19+end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t