mirror of https://github.com/freeCodeCamp/devdocs
parent
fd15168ebd
commit
a0cfe45f21
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 134 KiB |
@ -0,0 +1,56 @@
|
||||
module Docs
|
||||
class Yarn
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
@doc = at_css('.hero + .container')
|
||||
|
||||
at_css('.row').remove
|
||||
css('> .container', 'hr').remove
|
||||
|
||||
css('.row', '.col-lg-4', '.card-block').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('a.card').each do |node|
|
||||
node.at_css('.float-right').replace %(<br><a href="#{node['href']}">Read more</a>)
|
||||
node.before(node.children).remove
|
||||
end
|
||||
end
|
||||
|
||||
def other
|
||||
@doc = at_css('.guide')
|
||||
|
||||
css('a.toc', '.nav-tabs', '#select-platform', '.guide-controls + .list-group', '.guide-controls').remove
|
||||
|
||||
css('.guide-content', '.tabs', '.tab-content').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
unless at_css('h2')
|
||||
css('h3', 'h4', 'h5').each do |node|
|
||||
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
|
||||
end
|
||||
end
|
||||
|
||||
unless at_css('h3')
|
||||
css('h4', 'h5').each do |node|
|
||||
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
|
||||
end
|
||||
end
|
||||
|
||||
css('div.highlighter-rouge').each do |node|
|
||||
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
|
||||
node.content = node.content.strip
|
||||
node.name = 'pre'
|
||||
end
|
||||
|
||||
css('.highlighter-rouge').remove_attr('class')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Docs
|
||||
class Yarn
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
|
||||
unless type == 'CLI'
|
||||
name.prepend "#{css('.guide-nav a').to_a.index(at_css('.guide-nav a.active')) + 1}. "
|
||||
end
|
||||
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
type = at_css('.guide-nav a').content.strip
|
||||
type.remove! ' Introduction'
|
||||
type
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,24 @@
|
||||
module Docs
|
||||
class Yarn < UrlScraper
|
||||
self.type = 'yarn'
|
||||
self.release = '0.17.6'
|
||||
self.base_url = 'https://yarnpkg.com/en/docs/'
|
||||
self.links = {
|
||||
home: 'https://yarnpkg.com/',
|
||||
code: 'https://github.com/yarnpkg/yarn'
|
||||
}
|
||||
|
||||
html_filters.push 'yarn/entries', 'yarn/clean_html', 'title'
|
||||
|
||||
options[:root_title] = 'Yarn'
|
||||
options[:trailing_slash] = false
|
||||
|
||||
options[:skip] = %w(nightly)
|
||||
options[:skip_patterns] = [/\Aorg\//]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2016 Yarn Contributors<br>
|
||||
Licensed under the BSD License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 611 B |
@ -0,0 +1 @@
|
||||
https://raw.githubusercontent.com/yarnpkg/website/master/favicon.ico
|
Loading…
Reference in new issue