mirror of https://github.com/freeCodeCamp/devdocs
parent
0aa1ff4e80
commit
cb0b2e02d7
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
@ -0,0 +1,15 @@
|
||||
._npm {
|
||||
@extend %simple;
|
||||
|
||||
.pageColumns {
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.faint.heading {
|
||||
font-size: .9em;
|
||||
color: $textColorLight;
|
||||
}
|
||||
|
||||
.youtube-video iframe { width: 420px; height: 315px; }
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
module Docs
|
||||
class Npm
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
css('#enterprise', '#policies', '#viewAll').remove
|
||||
else
|
||||
@doc = doc.at_css('#page')
|
||||
css('meta', '.colophon').remove
|
||||
end
|
||||
|
||||
css('> section', '.deep-link > a').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('pre.editor').each do |node|
|
||||
node.inner_html = node.inner_html.gsub(/<\/div>(?!\n|\z)/, "</div>\n")
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,43 @@
|
||||
module Docs
|
||||
class Npm
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
if slug.start_with?('api') && at_css('pre').content =~ /\A\s*npm\.([\w\-]+\.)*[\w\-]+/
|
||||
name = $&.strip
|
||||
else
|
||||
name = at_css('nav > section.active a.active').content
|
||||
end
|
||||
|
||||
name << ' (CLI)' if slug.start_with?('cli')
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
case slug
|
||||
when 'files/package.json'
|
||||
'package.json'
|
||||
when 'misc/config'
|
||||
'Config'
|
||||
else
|
||||
at_css('nav > section.active > h2').content
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
case slug
|
||||
when 'files/package.json'
|
||||
css('#page > h2[id]').each_with_object [] do |node, entries|
|
||||
next if node.content =~ /\A[A-Z]/
|
||||
entries << ["package.json: #{node.content}", node['id']]
|
||||
end
|
||||
when 'misc/config'
|
||||
css('#config-settings ~ h3[id]').map do |node|
|
||||
["config: #{node.content}", node['id']]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
module Docs
|
||||
class Npm < UrlScraper
|
||||
self.name = 'npm'
|
||||
self.type = 'npm'
|
||||
self.version = '2.8.4'
|
||||
self.base_url = 'https://docs.npmjs.com/'
|
||||
self.links = {
|
||||
home: 'https://www.npmjs.com/',
|
||||
code: 'https://github.com/npm/npm'
|
||||
}
|
||||
|
||||
html_filters.push 'npm/entries', 'npm/clean_html', 'title'
|
||||
|
||||
options[:container] = ->(filter) { filter.root_page? ? '.toc' : nil }
|
||||
options[:title] = false
|
||||
options[:root_title] = 'npm'
|
||||
|
||||
options[:skip] = %w(all)
|
||||
options[:skip_patterns] = [
|
||||
/\Aenterprise/,
|
||||
/\Acompany/,
|
||||
/\Apolicies/
|
||||
]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© npm, Inc. and Contributors<br>
|
||||
Licensed under the npm License.<br>
|
||||
npm is a trademark of npm, Inc.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 88 B |
After Width: | Height: | Size: 96 B |
@ -0,0 +1 @@
|
||||
https://www.npmjs.com/
|
Loading…
Reference in new issue