History

Finish ESLint scraper

Thibaut Courouble committed 8 years ago

Commit 66d32281 parent 9fdaf0712 files · +39 −35Browse files

Unified · Split

12 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/eslint/clean_html.rb +18 −0
  7. lib/docs/filters/eslint/entries.rb +10 −12
  8. lib/docs/scrapers/eslint.rb +7 −9
  9. public/icons/docs/eslint/16.png +0 −0
  10. public/icons/docs/eslint/16@2x.png +0 −0
  11. public/icons/docs/eslint/SOURCE +1 −0
  12. public/icons/docs/eslint/SOURCE. +0 −17
assets/images/docs-2.png+0−0

Binary file not shown.

assets/images/docs-2@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
1[1[
2 [2 [
3 "2017-11-26",3 "2017-11-26",
4 "New documentation: <a href=\"/bluebird/\">Bluebird</a>"4 "New documentations: <a href=\"/bluebird/\">Bluebird</a> and <a href=\"/eslint/\">ESLint</a>"
5 ], [5 ], [
6 "2017-11-18",6 "2017-11-18",
7 "Added print & PDF stylesheet.\nFeedback welcome on <a href=\"https://twitter.com/DevDocs\" target=\"_blank\" rel=\"noopener\">Twitter</a> and <a href=\"https://github.com/Thibaut/devdocs\" target=\"_blank\" rel=\"noopener\">GitHub</a>."7 "Added print & PDF stylesheet.\nFeedback welcome on <a href=\"https://twitter.com/DevDocs\" target=\"_blank\" rel=\"noopener\">Twitter</a> and <a href=\"https://github.com/Thibaut/devdocs\" target=\"_blank\" rel=\"noopener\">GitHub</a>."
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -247,6 +247,11 @@ credits = [ · 246 unmodified lines
247 '2010-2017 Ericsson AB',247 '2010-2017 Ericsson AB',
248 'Apache',248 'Apache',
249 'https://raw.githubusercontent.com/erlang/otp/maint/LICENSE.txt'249 'https://raw.githubusercontent.com/erlang/otp/maint/LICENSE.txt'
250 ], [
251 'ESLint',
252 'JS Foundation and other contributors',
253 'MIT',
254 'https://raw.githubusercontent.com/eslint/eslint/master/LICENSE'
250 ], [255 ], [
251 'Express',256 'Express',
252 '2017 StrongLoop, IBM, and other expressjs.com contributors.',257 '2017 StrongLoop, IBM, and other expressjs.com contributors.',
assets/stylesheets/global/_icons.scss+1−0
@@ -165,3 +165,4 @@ · 164 unmodified lines
165._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }165._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
166._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }166._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }
167._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }167._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
168._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }
lib/docs/filters/eslint/clean_html.rb+18−0
@@ -3,6 +3,24 @@ module Docs · 2 unmodified lines
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('.doc') if at_css('.doc')5 @doc = at_css('.doc') if at_css('.doc')
6
7 css('.glyphicon').remove
8 css('hr', 'colgroup', 'td:empty').remove
9
10 css('.container').each do |node|
11 node.before(node.children).remove
12 end
13
14 css('div.highlighter-rouge').each do |node|
15 lang = node['class'][/language-(\w+)/, 1]
16 node['data-language'] = lang if lang
17 node.content = node.content.strip
18 node.name = 'pre'
19 node.remove_attribute('class')
20 end
21
22 css('code', 'p').remove_attr('class')
23
6 doc24 doc
7 end25 end
8 end26 end
lib/docs/filters/eslint/entries.rb+10−12
@@ -2,24 +2,22 @@ module Docs · 1 unmodified line
2 class Eslint2 class Eslint
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 at_css('h1').content5 name = at_css('h1').content.strip
6
7 if subpath.start_with?('rules/') && subpath != 'rules/'
8 name = name[/\(([\w\-]+?)\)\z/, 1] || name[/\A([\w\-]+?):/, 1]
9 end
10
11 name
6 end12 end
7 13
8 def get_type14 def get_type
9 if subpath.start_with?('docs/developer-guide/')15 if subpath.include?('guide')
10 type = 'Developer Guide'16 type = 'Guide'
11 elsif subpath.start_with?('docs/user-guide/')17 elsif subpath.start_with?('rules')
12 type = 'User Guide'
13 elsif subpath.start_with?('docs/rules')
14 type = 'Rules'18 type = 'Rules'
15 elsif subpath.start_with?('docs/about')
16 type = 'User Guide'
17 else
18 type = nil
19 end19 end
20 type
21 end20 end
22
23 end21 end
24 end22 end
25end23end
lib/docs/scrapers/eslint.rb+7−9
@@ -1,11 +1,10 @@
1module Docs1module Docs
2 class Eslint < UrlScraper2 class Eslint < UrlScraper
3 self.name = 'ESLint'3 self.name = 'ESLint'
4 self.type = 'eslint'4 self.type = 'simple'
5 self.release = '4.9.0'5 self.release = '4.12.0'
6 self.base_url = 'https://eslint.org/'6 self.base_url = 'https://eslint.org/docs/'
7 self.root_path = 'docs/user-guide/getting-started'7 self.root_path = 'user-guide/getting-started'
8
9 self.links = {8 self.links = {
10 home: 'https://eslint.org/',9 home: 'https://eslint.org/',
11 code: 'https://github.com/eslint/eslint'10 code: 'https://github.com/eslint/eslint'
@@ -13,12 +12,11 @@ module Docs · 1 unmodified line
13 12
14 html_filters.push 'eslint/entries', 'eslint/clean_html'13 html_filters.push 'eslint/entries', 'eslint/clean_html'
15 14
16 options[:container] = 'body' 15 options[:skip_patterns] = [/developer-guide/, /maintainer-guide/]
17 16 options[:skip] = %w(about about/ rules)
18 options[:skip_patterns] = [/\Ablog/, /\Ademo/, /\Aparser/, /formatters\//]
19 17
20 options[:attribution] = <<-HTML18 options[:attribution] = <<-HTML
21 &copy; Copyright JS Foundation and other contributors, https://js.foundation/<br>19 &copy; JS Foundation and other contributors<br>
22 Licensed under the MIT License.20 Licensed under the MIT License.
23 HTML21 HTML
24 end22 end
public/icons/docs/eslint/16.png+0−0

Binary file not shown.

public/icons/docs/eslint/16@2x.png+0−0

Binary file not shown.

public/icons/docs/eslint/SOURCE+1−0
@@ -0,0 +1 @@
1https://github.com/eslint/eslint.github.io/tree/master/img
public/icons/docs/eslint/SOURCE.+0−17
@@ -1,17 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 294.825 258.982"
5 xml:space="preserve">
6<g>
7 <path fill="#8080F2" d="M97.021,99.016l48.432-27.962c1.212-0.7,2.706-0.7,3.918,0l48.433,27.962
8 c1.211,0.7,1.959,1.993,1.959,3.393v55.924c0,1.399-0.748,2.693-1.959,3.394l-48.433,27.962c-1.212,0.7-2.706,0.7-3.918,0
9 l-48.432-27.962c-1.212-0.7-1.959-1.994-1.959-3.394v-55.924C95.063,101.009,95.81,99.716,97.021,99.016"/>
10 <path fill="#4B32C3" d="M273.336,124.488L215.469,23.816c-2.102-3.64-5.985-6.325-10.188-6.325H89.545
11 c-4.204,0-8.088,2.685-10.19,6.325l-57.867,100.45c-2.102,3.641-2.102,8.236,0,11.877l57.867,99.847
12 c2.102,3.64,5.986,5.501,10.19,5.501h115.735c4.203,0,8.087-1.805,10.188-5.446l57.867-100.01
13 C275.439,132.396,275.439,128.128,273.336,124.488 M225.419,172.898c0,1.48-0.891,2.849-2.174,3.59l-73.71,42.527
14 c-1.282,0.74-2.888,0.74-4.17,0l-73.767-42.527c-1.282-0.741-2.179-2.109-2.179-3.59V87.843c0-1.481,0.884-2.849,2.167-3.59
15 l73.707-42.527c1.282-0.741,2.886-0.741,4.168,0l73.772,42.527c1.283,0.741,2.186,2.109,2.186,3.59V172.898z"/>
16</g>
17</svg>