Skip to content

Commit 66d3228

Browse files
committed
Finish ESLint scraper
1 parent 9fdaf07 commit 66d3228

12 files changed

Lines changed: 43 additions & 39 deletions

File tree

assets/images/docs-2.png

355 Bytes
Loading

assets/images/[email protected]

1009 Bytes
Loading

assets/javascripts/news.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ credits = [
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,4 @@
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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ class Eslint
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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ module Docs
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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
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'
1211
}
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

-175 Bytes
Loading
-341 Bytes
Loading

0 commit comments

Comments
 (0)