Finish OpenTSDB scraper

pull/241/head
Thibaut 10 years ago
parent f6df847e86
commit 955ef5de95

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 81 KiB

@ -1,5 +1,8 @@
[
[
"2015-08-02",
"New documentation: <a href=\"/opentsdb/\">OpenTSDB</a>"
], [
"2015-07-26",
"Added search abbreviations (e.g. <code class=\"_label\">$</code> is an alias for <code class=\"_label\">jQuery</code>).\n<a href=\"/help#abbreviations\">Click here</a> to see the full list. Feel free to suggest more on <a href=\"https://github.com/Thibaut/devdocs/issues/new\" target=\"_blank\">GitHub</a>.",
"Added <code class=\"_label\">shift + &darr;/&uarr;</code> shortcut for scrolling (same as <code class=\"_label\">alt + &darr;/&uarr;</code>)."

@ -274,6 +274,11 @@ credits = [
'npm, Inc. and Contributors<br>npm is a trademark of npm, Inc.',
'npm',
'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
], [
'OpenTSDB',
'2010-2015 The OpenTSDB Authors',
'LGPLv2.1',
'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'
], [
'Phaser',
'2015 Richard Davey, Photon Storm Ltd.',

@ -105,3 +105,4 @@
._icon-webpack:before { background-position: -1rem -8rem; @extend %darkIconFix !optional; }
._icon-phaser:before { background-position: -2rem -8rem; }
._icon-vue:before { background-position: -3rem -8rem; }
._icon-opentsdb:before { background-position: -4rem -8rem; }

@ -1,7 +1,10 @@
._opentsdb .section {
> h2 { @extend %block-heading; }
> h3 { @extend %block-label, %label-blue; }
> h4 { font-size: 1em; }
._opentsdb {
@extend %simple;
.admonition { @extend %note; }
.admonition.warning { @extend %note-orange; }
.admonition-title {
margin: 0 0 .25rem;
font-weight: bold;
}
}

@ -1,13 +1,24 @@
module Docs
class Opentsdb
class Opentsdb
class CleanHtmlFilter < Filter
def call
# Reset the page scope to the body,
# we needed the rest of the page for the entries filter.
@doc = at_css(".documentwrapper > .bodywrapper > .body > .section")
@doc = at_css('.documentwrapper > .bodywrapper > .body > .section')
# Remove table borders
css('table').each { |table| table.delete 'border' }
css('> .section').each do |node|
node.before(node.children).remove
end
css('tt.literal').each do |node|
node.name = 'code'
node.content = node.content
end
css('div[class*=highlight] .highlight pre').each do |node|
node.parent.parent.before(node)
node.content = node.content.gsub(' ', ' ')
end
css('table').remove_attr('border')
doc
end

@ -1,34 +1,24 @@
module Docs
class Opentsdb
class Opentsdb
class EntriesFilter < Docs::EntriesFilter
def get_name
header = css(".section > h1").first
return header.content.strip unless header.nil?
at_css('.section > h1').content
end
def get_type
return nil if breadcrumbs.length < 2
# This is time for a little bit of cheating
return breadcrumbs[1] if breadcrumbs.include? "HTTP API"
breadcrumbs.last
end
def additional_entries
[]
if subpath.start_with?('api_http')
'HTTP API'
elsif slug.end_with?('/index')
[breadcrumbs[1], name].compact.join(': ')
elsif breadcrumbs.length < 2
'Miscellaneous'
else
breadcrumbs[1..2].join(': ')
end
end
def breadcrumbs
nav_links = css(".related").first.css("li")
breadcrumbs = nav_links.reject do |node|
node['class'] == "right"
end
breadcrumbs.map { |node| node.at_css("a").content }
.reject { |link| link.empty? }
@breakcrumbs ||= at_css('.related').css('li:not(.right) a').map(&:content).reject(&:blank?)
end
end
end

@ -2,18 +2,21 @@ module Docs
class Opentsdb < UrlScraper
self.name = 'OpenTSDB'
self.type = 'opentsdb'
self.version = '2.1'
self.version = '2.1.0'
self.base_url = 'http://opentsdb.net/docs/build/html/'
self.root_path = 'index.html'
self.links = {
home: 'http://opentsdb.net/',
code: 'https://github.com/OpenTSDB/opentsdb'
}
html_filters.push 'opentsdb/entries', 'opentsdb/clean_html'
options[:skip] = %w(genindex.html search.html)
options[:attribution] = <<-HTML
&copy; 2015 OpenTSDB
&copy; 2010&ndash;2015 The OpenTSDB Authors<br>
Licensed under the GNU LGPLv2.1+ and GPLv3+ licenses.
HTML
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Loading…
Cancel
Save