Finish Q scraper

pull/241/head
Thibaut 10 years ago
parent a00e45e829
commit 999b61416d

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 83 KiB

@ -1,7 +1,7 @@
[ [
[ [
"2015-08-02", "2015-08-02",
"New documentation: <a href=\"/opentsdb/\">OpenTSDB</a>" "New documentations: <a href=\"/q/\">Q</a> and <a href=\"/opentsdb/\">OpenTSDB</a>"
], [ ], [
"2015-07-26", "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 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>.",

@ -304,6 +304,11 @@ credits = [
'1990-2015 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.', '1990-2015 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
'PSFL', 'PSFL',
'http://docs.python.org/3/license.html' 'http://docs.python.org/3/license.html'
], [
'Q',
'2009-2015 Kristopher Michael Kowal and contributors',
'MIT',
'https://raw.githubusercontent.com/kriskowal/q/v1/LICENSE'
], [ ], [
'React', 'React',
'2013-2015 Facebook Inc.', '2013-2015 Facebook Inc.',

@ -26,6 +26,7 @@ app.views.MomentPage =
app.views.MongoosePage = app.views.MongoosePage =
app.views.NodePage = app.views.NodePage =
app.views.PhaserPage = app.views.PhaserPage =
app.views.QPage =
app.views.RethinkdbPage = app.views.RethinkdbPage =
app.views.SinonPage = app.views.SinonPage =
app.views.UnderscorePage = app.views.UnderscorePage =

@ -1,6 +0,0 @@
#= require views/pages/base
class app.views.QPage extends app.views.BasePage
afterRender: ->
@highlightCode @findAll('.highlight-js > pre'), 'javascript'
return

@ -106,3 +106,4 @@
._icon-phaser:before { background-position: -2rem -8rem; } ._icon-phaser:before { background-position: -2rem -8rem; }
._icon-vue:before { background-position: -3rem -8rem; } ._icon-vue:before { background-position: -3rem -8rem; }
._icon-opentsdb:before { background-position: -4rem -8rem; } ._icon-opentsdb:before { background-position: -4rem -8rem; }
._icon-q:before { background-position: -5rem -8rem; }

@ -1,5 +1,5 @@
._q { ._q {
> h3 { @extend %block-heading; } > h2, > h3 { @extend %block-heading; }
> h4 { @extend %block-label, %label-blue; } > h4 { @extend %block-label, %label-blue; }
code { @extend %label; } code { @extend %label; }
} }

@ -2,13 +2,15 @@ module Docs
class Q class Q
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
@doc = at_css('.markdown-body') css('.anchor').each do |node|
css('h3 > a, h4 > a').each do |node|
node.parent['id'] = node['href'].remove('#') node.parent['id'] = node['href'].remove('#')
node.remove node.remove
end end
css('.highlight > pre').each do |node|
node.content = node.content.gsub(' ', ' ')
end
doc doc
end end
end end

@ -2,40 +2,30 @@ module Docs
class Q class Q
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def additional_entries def additional_entries
entries = [] entry = type = nil
type = '' css('h3, h4, em:contains("Alias")').each_with_object [] do |node, entries|
entry = [] case node.name
css('h3, h4, em:contains("Alias")').each do |node| when 'h3'
if node.name == 'h3'
type = node.content.strip type = node.content.strip
type.remove! %r{\(.+\)}
if type == "Q.defer()" # Q.defer() is a method, but it also plays a section title role. type.remove! ' Methods'
entries << ['Q.defer', 'qdefer', 'Q.defer()'] type.remove! ' API'
end entries << [type, node['id'], type] if type == 'Q.defer()'
next when 'h4'
end name = node.content.strip
name.sub! %r{\(.*?\).*}, '()'
if node.name == 'h4' id = node['id'] = name.parameterize
name = node.content.strip.remove(/\(.*?\).*/) entry = [name, id, type]
link = node['id']
entry = [name, link, type]
entries << entry entries << entry
next when 'em'
name = node.parent.at_css('code').content
name << '()' if entry[0].end_with?('()')
dup = entry.dup
dup[0] = name
entries << dup
end end
if node.name == 'em' # for the aliases
aliasEntry = entry.clone
aliasEntry[0] = node.parent.at_css('code').content
entries << aliasEntry
next
end end
end
entries
end end
end end
end end

@ -1,21 +1,23 @@
module Docs module Docs
class Q < UrlScraper class Q < UrlScraper
self.name = 'Q' self.name = 'Q'
self.slug = 'Q' self.type = 'q'
self.type = 'Q'
self.version = '1.4.1' self.version = '1.4.1'
self.base_url = "https://github.com/kriskowal/q/wiki/API-Reference" self.base_url = 'https://github.com/kriskowal/q/wiki/'
self.root_path = 'API-Reference'
self.links = { self.links = {
home: 'https://github.com/kriskowal/q/', home: 'http://documentup.com/kriskowal/q/',
code: 'https://github.com/kriskowal/q/' code: 'https://github.com/kriskowal/q'
} }
html_filters.push 'q/clean_html', 'q/entries', 'title' html_filters.push 'q/clean_html', 'q/entries', 'title'
options[:container] = '.markdown-body'
options[:title] = 'Q' options[:title] = 'Q'
options[:skip_links] = true options[:skip_links] = true
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2009&ndash;2015 Kristopher Michael Kowal and contributors<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Loading…
Cancel
Save