Browse Source

Refactor GitHub scraper code

Thibaut Courouble 9 years ago
parent
commit
c5caeff917

+ 4 - 1
assets/javascripts/views/pages/github.coffee

@@ -1,6 +1,9 @@
 #= require views/pages/base
 
 class app.views.GithubPage extends app.views.BasePage
+  LANGUAGE_RGX = /highlight-source-(\w+)/
+
   prepare: ->
-    @highlightCode @findAll('pre.highlight-source-lua'), 'lua'
+    for el in @findAll('pre.highlight')
+      @highlightCode(el, el.className.match(LANGUAGE_RGX)[1])
     return

+ 0 - 1
assets/javascripts/views/pages/javascript.coffee

@@ -26,7 +26,6 @@ app.views.MomentPage =
 app.views.MongoosePage =
 app.views.NodePage =
 app.views.PhaserPage =
-app.views.QPage =
 app.views.RamdaPage =
 app.views.RethinkdbPage =
 app.views.SinonPage =

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

@@ -45,6 +45,7 @@
         'pages/erlang',
         'pages/express',
         'pages/git',
+        'pages/github',
         'pages/go',
         'pages/haskell',
         'pages/jquery',
@@ -63,7 +64,6 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
-        'pages/q',
         'pages/ramda',
         'pages/rdoc',
         'pages/react',

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

@@ -45,6 +45,7 @@
         'pages/erlang',
         'pages/express',
         'pages/git',
+        'pages/github',
         'pages/go',
         'pages/haskell',
         'pages/jquery',
@@ -63,7 +64,6 @@
         'pages/php',
         'pages/phpunit',
         'pages/postgres',
-        'pages/q',
         'pages/ramda',
         'pages/rdoc',
         'pages/react',

+ 0 - 1
assets/stylesheets/pages/_base.scss

@@ -17,7 +17,6 @@
 }
 
 ._cordova,
-._github,
 ._grunt,
 ._less,
 ._lodash,

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

@@ -0,0 +1,5 @@
+._github {
+  @extend %simple;
+
+  h4 { @extend %block-label; }
+}

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

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

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

@@ -1,18 +0,0 @@
-module Docs
-  class Q
-    class CleanHtmlFilter < Filter
-      def call
-        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
-  end
-end

+ 2 - 3
lib/docs/scrapers/q.rb

@@ -1,7 +1,6 @@
 module Docs
-  class Q < UrlScraper
+  class Q < Github
     self.name = 'Q'
-    self.type = 'q'
     self.release = '1.4.1'
     self.base_url = 'https://github.com/kriskowal/q/wiki/'
     self.root_path = 'API-Reference'
@@ -10,7 +9,7 @@ module Docs
       code: 'https://github.com/kriskowal/q'
     }
 
-    html_filters.push 'q/clean_html', 'q/entries', 'title'
+    html_filters.push 'q/entries', 'title'
 
     options[:container] = '.markdown-body'
     options[:title] = 'Q'