Przeglądaj źródła

Add Q.js documentation

Constantine Kim 10 lat temu
rodzic
commit
a00e45e829

+ 6 - 0
assets/javascripts/views/pages/q.coffee

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

+ 1 - 0
assets/stylesheets/application-dark.css.scss

@@ -59,6 +59,7 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
+        'pages/q',
         'pages/rdoc',
         'pages/react',
         'pages/redis',

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -59,6 +59,7 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
+        'pages/q',
         'pages/rdoc',
         'pages/react',
         'pages/redis',

+ 5 - 0
assets/stylesheets/pages/_q.scss

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

+ 16 - 0
lib/docs/filters/q/clean_html.rb

@@ -0,0 +1,16 @@
+module Docs
+  class Q
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.markdown-body')
+
+        css('h3 > a, h4 > a').each do |node|
+          node.parent['id'] = node['href'].remove('#')
+          node.remove
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 42 - 0
lib/docs/filters/q/entries.rb

@@ -0,0 +1,42 @@
+module Docs
+  class Q
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        entries = []
+
+        type = ''
+        entry = []
+        css('h3, h4, em:contains("Alias")').each do |node|
+
+          if node.name == '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]
+
+            entries << entry
+            next
+          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
+end

+ 22 - 0
lib/docs/scrapers/q.rb

@@ -0,0 +1,22 @@
+module Docs
+  class Q < UrlScraper
+    self.name = 'Q'
+    self.slug = 'Q'
+    self.type = 'Q'
+    self.version = '1.4.1'
+    self.base_url = "https://github.com/kriskowal/q/wiki/API-Reference"
+    self.links = {
+      home: 'https://github.com/kriskowal/q/',
+      code: 'https://github.com/kriskowal/q/'
+    }
+
+    html_filters.push 'q/clean_html', 'q/entries', 'title'
+
+    options[:title] = 'Q'
+    options[:skip_links] = true
+
+    options[:attribution] = <<-HTML
+        Licensed under the MIT License.
+    HTML
+  end
+end

BIN
public/icons/docs/q/16.png


BIN
public/icons/docs/q/16@2x.png


+ 1 - 0
public/icons/docs/q/SOURCE

@@ -0,0 +1 @@
+http://kriskowal.github.io/q/q.png