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 @@
11 [
22 [
33 "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>"
55 ], [
66 "2017-11-18",
77 "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
247247 '2010-2017 Ericsson AB',
248248 'Apache',
249249 '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'
250255 ], [
251256 'Express',
252257 '2017 StrongLoop, IBM, and other expressjs.com contributors.',
assets/stylesheets/global/_icons.scss+1−0
@@ -165,3 +165,4 @@ · 164 unmodified lines
165165 ._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
166166 ._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }
167167 ._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
33 class CleanHtmlFilter < Filter
44 def call
55 @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+
624 doc
725 end
826 end
lib/docs/filters/eslint/entries.rb+10−12
@@ -2,24 +2,22 @@ module Docs · 1 unmodified line
22 class Eslint
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
5− at_css('h1').content
5+ 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
612 end
713
814 def get_type
9− if subpath.start_with?('docs/developer-guide/')
10− type = 'Developer Guide'
11− elsif subpath.start_with?('docs/user-guide/')
12− type = 'User Guide'
13− elsif subpath.start_with?('docs/rules')
15+ if subpath.include?('guide')
16+ type = 'Guide'
17+ elsif subpath.start_with?('rules')
1418 type = 'Rules'
15− elsif subpath.start_with?('docs/about')
16− type = 'User Guide'
17− else
18− type = nil
1919 end
20− type
2120 end
22−
2321 end
2422 end
2523 end
lib/docs/scrapers/eslint.rb+7−9
@@ -1,11 +1,10 @@
11 module Docs
22 class Eslint < UrlScraper
33 self.name = 'ESLint'
4− self.type = 'eslint'
5− self.release = '4.9.0'
6− self.base_url = 'https://eslint.org/'
7− self.root_path = 'docs/user-guide/getting-started'
8−
4+ self.type = 'simple'
5+ self.release = '4.12.0'
6+ self.base_url = 'https://eslint.org/docs/'
7+ self.root_path = 'user-guide/getting-started'
98 self.links = {
109 home: 'https://eslint.org/',
1110 code: 'https://github.com/eslint/eslint'
@@ -13,12 +12,11 @@ module Docs · 1 unmodified line
1312
1413 html_filters.push 'eslint/entries', 'eslint/clean_html'
1514
16− options[:container] = 'body'
17−
18− options[:skip_patterns] = [/\Ablog/, /\Ademo/, /\Aparser/, /formatters\//]
15+ options[:skip_patterns] = [/developer-guide/, /maintainer-guide/]
16+ options[:skip] = %w(about about/ rules)
1917
2018 options[:attribution] = <<-HTML
21− &copy; Copyright JS Foundation and other contributors, https://js.foundation/<br>
19+ &copy; JS Foundation and other contributors<br>
2220 Licensed under the MIT License.
2321 HTML
2422 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 @@
1+https://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>