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",
"New documentation: <a href=\"/opentsdb/\">OpenTSDB</a>"
"New documentations: <a href=\"/q/\">Q</a> and <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>.",

@ -304,6 +304,11 @@ credits = [
'1990-2015 Python Software Foundation<br>Python is a trademark of the Python Software Foundation.',
'PSFL',
'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',
'2013-2015 Facebook Inc.',

@ -26,6 +26,7 @@ app.views.MomentPage =
app.views.MongoosePage =
app.views.NodePage =
app.views.PhaserPage =
app.views.QPage =
app.views.RethinkdbPage =
app.views.SinonPage =
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-vue:before { background-position: -3rem -8rem; }
._icon-opentsdb:before { background-position: -4rem -8rem; }
._icon-q:before { background-position: -5rem -8rem; }

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

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

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

@ -1,22 +1,24 @@
module Docs
class Q < UrlScraper
self.name = 'Q'
self.slug = 'Q'
self.type = 'Q'
self.type = 'q'
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 = {
home: 'https://github.com/kriskowal/q/',
code: 'https://github.com/kriskowal/q/'
home: 'http://documentup.com/kriskowal/q/',
code: 'https://github.com/kriskowal/q'
}
html_filters.push 'q/clean_html', 'q/entries', 'title'
options[:container] = '.markdown-body'
options[:title] = 'Q'
options[:skip_links] = true
options[:attribution] = <<-HTML
Licensed under the MIT License.
&copy; 2009&ndash;2015 Kristopher Michael Kowal and contributors<br>
Licensed under the MIT License.
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