Skip to content

Commit a0cfe45

Browse files
committed
Add Yarn documentation
1 parent fd15168 commit a0cfe45

13 files changed

Lines changed: 112 additions & 2 deletions

File tree

assets/images/docs.png

288 Bytes
Loading

assets/images/[email protected]

576 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
"2016-11-20",
4-
"New documentation: <a href=\"/immutable/\">Immutable.js</a>"
4+
"New documentations: <a href=\"/yarn/\">Yarn</a> and <a href=\"/immutable/\">Immutable.js</a>"
55
], [
66
"2016-10-10",
77
"New documentations: <a href=\"/scikit_learn/\">scikit-learn</a> and <a href=\"/statsmodels/\">Statsmodels</a>"

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@ credits = [
574574
'2012-2016 Tobias Koppers',
575575
'MIT',
576576
'https://raw.githubusercontent.com/webpack/webpack/master/LICENSE'
577+
], [
578+
'Yarn',
579+
'2016 Yarn Contributors',
580+
'BSD',
581+
'https://raw.githubusercontent.com/yarnpkg/yarn/master/LICENSE'
577582
], [
578583
'Yii',
579584
'2008-2016 by Yii Software LLC',

assets/javascripts/views/pages/simple.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ app.views.UnderscorePage =
6060
app.views.VagrantPage =
6161
app.views.VuePage =
6262
app.views.WebpackPage =
63+
app.views.YarnPage =
6364
app.views.YiiPage =
6465
app.views.SimplePage

assets/stylesheets/global/_icons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
._icon-angularjs:before { background-position: -9rem -1rem; }
7373
._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; }
7474
._icon-ember:before { background-position: -1rem -2rem; }
75+
._icon-yarn:before { background-position: -2rem -2rem; }
7576
._icon-immutable:before { background-position: -3rem -2rem; @extend %darkIconFix !optional; }
7677
._icon-jqueryui:before { background-position: -4rem -2rem; }
7778
._icon-jquerymobile:before { background-position: -5rem -2rem; }

assets/stylesheets/pages/_simple.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
._redux,
3737
._sinon,
3838
._typescript,
39-
._webpack {
39+
._webpack,
40+
._yarn {
4041
@extend %simple;
4142
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
module Docs
2+
class Yarn
3+
class CleanHtmlFilter < Filter
4+
def call
5+
root_page? ? root : other
6+
doc
7+
end
8+
9+
def root
10+
@doc = at_css('.hero + .container')
11+
12+
at_css('.row').remove
13+
css('> .container', 'hr').remove
14+
15+
css('.row', '.col-lg-4', '.card-block').each do |node|
16+
node.before(node.children).remove
17+
end
18+
19+
css('a.card').each do |node|
20+
node.at_css('.float-right').replace %(<br><a href="#{node['href']}">Read more</a>)
21+
node.before(node.children).remove
22+
end
23+
end
24+
25+
def other
26+
@doc = at_css('.guide')
27+
28+
css('a.toc', '.nav-tabs', '#select-platform', '.guide-controls + .list-group', '.guide-controls').remove
29+
30+
css('.guide-content', '.tabs', '.tab-content').each do |node|
31+
node.before(node.children).remove
32+
end
33+
34+
unless at_css('h2')
35+
css('h3', 'h4', 'h5').each do |node|
36+
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
37+
end
38+
end
39+
40+
unless at_css('h3')
41+
css('h4', 'h5').each do |node|
42+
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
43+
end
44+
end
45+
46+
css('div.highlighter-rouge').each do |node|
47+
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
48+
node.content = node.content.strip
49+
node.name = 'pre'
50+
end
51+
52+
css('.highlighter-rouge').remove_attr('class')
53+
end
54+
end
55+
end
56+
end

lib/docs/filters/yarn/entries.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Docs
2+
class Yarn
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
name = at_css('h1').content
6+
7+
unless type == 'CLI'
8+
name.prepend "#{css('.guide-nav a').to_a.index(at_css('.guide-nav a.active')) + 1}. "
9+
end
10+
11+
name
12+
end
13+
14+
def get_type
15+
type = at_css('.guide-nav a').content.strip
16+
type.remove! ' Introduction'
17+
type
18+
end
19+
end
20+
end
21+
end

lib/docs/scrapers/yarn.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Docs
2+
class Yarn < UrlScraper
3+
self.type = 'yarn'
4+
self.release = '0.17.6'
5+
self.base_url = 'https://yarnpkg.com/en/docs/'
6+
self.links = {
7+
home: 'https://yarnpkg.com/',
8+
code: 'https://github.com/yarnpkg/yarn'
9+
}
10+
11+
html_filters.push 'yarn/entries', 'yarn/clean_html', 'title'
12+
13+
options[:root_title] = 'Yarn'
14+
options[:trailing_slash] = false
15+
16+
options[:skip] = %w(nightly)
17+
options[:skip_patterns] = [/\Aorg\//]
18+
19+
options[:attribution] = <<-HTML
20+
&copy; 2016 Yarn Contributors<br>
21+
Licensed under the BSD License.
22+
HTML
23+
end
24+
end

0 commit comments

Comments
 (0)