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
3class 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
59 'pages/php',59 'pages/php',
60 'pages/phpunit',60 'pages/phpunit',
61 'pages/postgres',61 'pages/postgres',
62 'pages/q',
62 'pages/rdoc',63 'pages/rdoc',
63 'pages/react',64 'pages/react',
64 'pages/redis',65 'pages/redis',
assets/stylesheets/application.css.scss+1−0
@@ -59,6 +59,7 @@ · 58 unmodified lines
59 'pages/php',59 'pages/php',
60 'pages/phpunit',60 'pages/phpunit',
61 'pages/postgres',61 'pages/postgres',
62 'pages/q',
62 'pages/rdoc',63 'pages/rdoc',
63 'pages/react',64 'pages/react',
64 'pages/redis',65 '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 @@
1module 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
16end
lib/docs/filters/q/entries.rb+42−0
@@ -0,0 +1,42 @@
1module 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
42end
lib/docs/scrapers/q.rb+22−0
@@ -0,0 +1,22 @@
1module 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
22end
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 @@
1http://kriskowal.github.io/q/q.png