From c5caeff9179bcda3cec48d7d61b22a80d7baf5af Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 28 Feb 2016 12:07:06 -0500 Subject: [PATCH] Refactor GitHub scraper code --- assets/javascripts/views/pages/github.coffee | 5 ++++- .../javascripts/views/pages/javascript.coffee | 1 - assets/stylesheets/application-dark.css.scss | 2 +- assets/stylesheets/application.css.scss | 2 +- assets/stylesheets/pages/_base.scss | 1 - assets/stylesheets/pages/_github.scss | 5 +++++ assets/stylesheets/pages/_q.scss | 5 ----- lib/docs/filters/q/clean_html.rb | 18 ------------------ lib/docs/scrapers/q.rb | 5 ++--- 9 files changed, 13 insertions(+), 31 deletions(-) create mode 100644 assets/stylesheets/pages/_github.scss delete mode 100644 assets/stylesheets/pages/_q.scss delete mode 100644 lib/docs/filters/q/clean_html.rb diff --git a/assets/javascripts/views/pages/github.coffee b/assets/javascripts/views/pages/github.coffee index 8d65a2a4..d7f57e05 100644 --- a/assets/javascripts/views/pages/github.coffee +++ b/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 diff --git a/assets/javascripts/views/pages/javascript.coffee b/assets/javascripts/views/pages/javascript.coffee index ef8c99e2..619b5fe3 100644 --- a/assets/javascripts/views/pages/javascript.coffee +++ b/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 = diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 6e9a310f..48a664f4 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/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', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 35e24aac..e554c901 100644 --- a/assets/stylesheets/application.css.scss +++ b/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', diff --git a/assets/stylesheets/pages/_base.scss b/assets/stylesheets/pages/_base.scss index 21c8fb71..ef7d422d 100644 --- a/assets/stylesheets/pages/_base.scss +++ b/assets/stylesheets/pages/_base.scss @@ -17,7 +17,6 @@ } ._cordova, -._github, ._grunt, ._less, ._lodash, diff --git a/assets/stylesheets/pages/_github.scss b/assets/stylesheets/pages/_github.scss new file mode 100644 index 00000000..bda57d4c --- /dev/null +++ b/assets/stylesheets/pages/_github.scss @@ -0,0 +1,5 @@ +._github { + @extend %simple; + + h4 { @extend %block-label; } +} diff --git a/assets/stylesheets/pages/_q.scss b/assets/stylesheets/pages/_q.scss deleted file mode 100644 index 7f6e7c09..00000000 --- a/assets/stylesheets/pages/_q.scss +++ /dev/null @@ -1,5 +0,0 @@ -._q { - > h2, > 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 deleted file mode 100644 index 3f789414..00000000 --- a/lib/docs/filters/q/clean_html.rb +++ /dev/null @@ -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 diff --git a/lib/docs/scrapers/q.rb b/lib/docs/scrapers/q.rb index 87fefd5f..3d9b53c1 100644 --- a/lib/docs/scrapers/q.rb +++ b/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'