History

Add Q.js documentation

Constantine Kim committed 11 years ago

Commit a00e45e1 parent 955ef5d10 files · +92 −-2Browse files

Unified · Split

10 files
  1. assets/javascripts/views/pages/q.coffee +6 −0
  2. assets/stylesheets/application-dark.css.scss +1 −0
  3. assets/stylesheets/application.css.scss +1 −0
  4. assets/stylesheets/pages/_q.scss +5 −0
  5. lib/docs/filters/q/clean_html.rb +16 −0
  6. lib/docs/filters/q/entries.rb +42 −0
  7. lib/docs/scrapers/q.rb +22 −0
  8. public/icons/docs/q/16.png +0 −0
  9. public/icons/docs/q/16@2x.png +0 −0
  10. public/icons/docs/q/SOURCE +1 −0
assets/javascripts/views/pages/q.coffee+6−0
@@ -0,0 +1,6 @@
1+#= require views/pages/base
2+
3+class app.views.QPage extends app.views.BasePage
4+ afterRender: ->
5+ @highlightCode @findAll('.highlight-js > pre'), 'javascript'
6+ return
assets/stylesheets/application-dark.css.scss+1−0
@@ -59,6 +59,7 @@ · 58 unmodified lines
5959 'pages/php',
6060 'pages/phpunit',
6161 'pages/postgres',
62+ 'pages/q',
6263 'pages/rdoc',
6364 'pages/react',
6465 'pages/redis',
assets/stylesheets/application.css.scss+1−0
@@ -59,6 +59,7 @@ · 58 unmodified lines
5959 'pages/php',
6060 'pages/phpunit',
6161 'pages/postgres',
62+ 'pages/q',
6263 'pages/rdoc',
6364 'pages/react',
6465 'pages/redis',
assets/stylesheets/pages/_q.scss+5−0
@@ -0,0 +1,5 @@
1+._q {
2+ > h3 { @extend %block-heading; }
3+ > h4 { @extend %block-label, %label-blue; }
4+ code { @extend %label; }
5+}
lib/docs/filters/q/clean_html.rb+16−0
@@ -0,0 +1,16 @@
1+module Docs
2+ class Q
3+ class CleanHtmlFilter < Filter
4+ def call
5+ @doc = at_css('.markdown-body')
6+
7+ css('h3 > a, h4 > a').each do |node|
8+ node.parent['id'] = node['href'].remove('#')
9+ node.remove
10+ end
11+
12+ doc
13+ end
14+ end
15+ end
16+end
lib/docs/filters/q/entries.rb+42−0
@@ -0,0 +1,42 @@
1+module Docs
2+ class Q
3+ class EntriesFilter < Docs::EntriesFilter
4+ def additional_entries
5+ entries = []
6+
7+ type = ''
8+ entry = []
9+ css('h3, h4, em:contains("Alias")').each do |node|
10+
11+ if node.name == 'h3'
12+ type = node.content.strip
13+
14+ if type == "Q.defer()" # Q.defer() is a method, but it also plays a section title role.
15+ entries << ['Q.defer', 'qdefer', 'Q.defer()']
16+ end
17+ next
18+ end
19+
20+ if node.name == 'h4'
21+ name = node.content.strip.remove(/\(.*?\).*/)
22+ link = node['id']
23+ entry = [name, link, type]
24+
25+ entries << entry
26+ next
27+ end
28+
29+ if node.name == 'em' # for the aliases
30+ aliasEntry = entry.clone
31+ aliasEntry[0] = node.parent.at_css('code').content
32+ entries << aliasEntry
33+ next
34+ end
35+
36+ end
37+
38+ entries
39+ end
40+ end
41+ end
42+end
lib/docs/scrapers/q.rb+22−0
@@ -0,0 +1,22 @@
1+module Docs
2+ class Q < UrlScraper
3+ self.name = 'Q'
4+ self.slug = 'Q'
5+ self.type = 'Q'
6+ self.version = '1.4.1'
7+ self.base_url = "https://github.com/kriskowal/q/wiki/API-Reference"
8+ self.links = {
9+ home: 'https://github.com/kriskowal/q/',
10+ code: 'https://github.com/kriskowal/q/'
11+ }
12+
13+ html_filters.push 'q/clean_html', 'q/entries', 'title'
14+
15+ options[:title] = 'Q'
16+ options[:skip_links] = true
17+
18+ options[:attribution] = <<-HTML
19+ Licensed under the MIT License.
20+ HTML
21+ end
22+end
public/icons/docs/q/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/q/SOURCE+1−0
@@ -0,0 +1 @@
1+http://kriskowal.github.io/q/q.png