diff --git a/assets/javascripts/views/pages/q.coffee b/assets/javascripts/views/pages/q.coffee new file mode 100644 index 00000000..67637560 --- /dev/null +++ b/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 diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index dd9de3d5..20c2fc1e 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -59,6 +59,7 @@ 'pages/php', 'pages/phpunit', 'pages/postgres', + 'pages/q', 'pages/rdoc', 'pages/react', 'pages/redis', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 1045542e..dcb6b623 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -59,6 +59,7 @@ 'pages/php', 'pages/phpunit', 'pages/postgres', + 'pages/q', 'pages/rdoc', 'pages/react', 'pages/redis', diff --git a/assets/stylesheets/pages/_q.scss b/assets/stylesheets/pages/_q.scss new file mode 100644 index 00000000..7b0af99c --- /dev/null +++ b/assets/stylesheets/pages/_q.scss @@ -0,0 +1,5 @@ +._q { + > h3 { @extend %block-heading; } + > h4 { @extend %block-label, %label-blue; } + code { @extend %label; } +} diff --git a/lib/docs/filters/q/clean_html.rb b/lib/docs/filters/q/clean_html.rb new file mode 100644 index 00000000..54d45564 --- /dev/null +++ b/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 diff --git a/lib/docs/filters/q/entries.rb b/lib/docs/filters/q/entries.rb new file mode 100644 index 00000000..35b861ac --- /dev/null +++ b/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 diff --git a/lib/docs/scrapers/q.rb b/lib/docs/scrapers/q.rb new file mode 100644 index 00000000..78de5b1b --- /dev/null +++ b/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 diff --git a/public/icons/docs/q/16.png b/public/icons/docs/q/16.png new file mode 100644 index 00000000..9568cd73 Binary files /dev/null and b/public/icons/docs/q/16.png differ diff --git a/public/icons/docs/q/16@2x.png b/public/icons/docs/q/16@2x.png new file mode 100644 index 00000000..799b8d9c Binary files /dev/null and b/public/icons/docs/q/16@2x.png differ diff --git a/public/icons/docs/q/SOURCE b/public/icons/docs/q/SOURCE new file mode 100644 index 00000000..b26818c3 --- /dev/null +++ b/public/icons/docs/q/SOURCE @@ -0,0 +1 @@ +http://kriskowal.github.io/q/q.png