Add npm documentation

pull/205/head
Thibaut 10 years ago
parent 0aa1ff4e80
commit cb0b2e02d7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

@ -1,5 +1,8 @@
[
[
"2015-04-26",
"New <a href=\"/npm/\">npm</a> documentation"
], [
"2015-03-22",
"New <a href=\"/meteor/\">Meteor</a> and <a href=\"/mocha/\">mocha</a> documentations"
], [

@ -265,6 +265,11 @@ credits = [
'2008-2014 2014 Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo, Patrick Mahoney, Yoko Harada, Akinori Musha',
'MIT',
'https://github.com/sparklemotion/nokogiri/blob/master/README.rdoc#license'
], [
'npm',
'npm, Inc. and Contributors<br>npm is a trademark of npm, Inc.',
'npm',
'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
], [
'PHP',
'1997-2015 The PHP Documentation Group',

@ -52,6 +52,7 @@
'pages/moment',
'pages/nginx',
'pages/node',
'pages/npm',
'pages/php',
'pages/phpunit',
'pages/postgres',

@ -52,6 +52,7 @@
'pages/moment',
'pages/nginx',
'pages/node',
'pages/npm',
'pages/php',
'pages/phpunit',
'pages/postgres',

@ -99,3 +99,4 @@
._icon-symfony:before { background-position: -5rem -7rem; }
._icon-mocha:before { background-position: -6rem -7rem; }
._icon-meteor:before { background-position: -7rem -7rem; @extend %darkIconFix !optional; }
._icon-npm:before { background-position: -8rem -7rem }

@ -27,3 +27,4 @@
._sinon {
@extend %simple;
}

@ -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
&copy; npm, Inc. and Contributors<br>
Licensed under the npm License.<br>
npm is a trademark of npm, Inc.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

@ -0,0 +1 @@
https://www.npmjs.com/
Loading…
Cancel
Save