History

Add npm documentation

Thibaut committed 11 years ago

Commit cb0b2e01 parent 0aa1ff415 files · +126 −-4Browse files

Unified · Split

15 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/application-dark.css.scss +1 −0
  6. assets/stylesheets/application.css.scss +1 −0
  7. assets/stylesheets/global/_icons.scss +1 −0
  8. assets/stylesheets/pages/_base.scss +1 −0
  9. assets/stylesheets/pages/_npm.scss +15 −0
  10. lib/docs/filters/npm/clean_html.rb +28 −0
  11. lib/docs/filters/npm/entries.rb +43 −0
  12. lib/docs/scrapers/npm.rb +31 −0
  13. public/icons/docs/npm/16.png +0 −0
  14. public/icons/docs/npm/16@2x.png +0 −0
  15. public/icons/docs/npm/SOURCE +1 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
11 [
22 [
3+ "2015-04-26",
4+ "New <a href=\"/npm/\">npm</a> documentation"
5+ ], [
36 "2015-03-22",
47 "New <a href=\"/meteor/\">Meteor</a> and <a href=\"/mocha/\">mocha</a> documentations"
58 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -265,6 +265,11 @@ credits = [ · 264 unmodified lines
265265 '2008-2014 2014 Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo, Patrick Mahoney, Yoko Harada, Akinori Musha',
266266 'MIT',
267267 'https://github.com/sparklemotion/nokogiri/blob/master/README.rdoc#license'
268+ ], [
269+ 'npm',
270+ 'npm, Inc. and Contributors<br>npm is a trademark of npm, Inc.',
271+ 'npm',
272+ 'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
268273 ], [
269274 'PHP',
270275 '1997-2015 The PHP Documentation Group',
assets/stylesheets/application-dark.css.scss+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 'pages/moment',
5353 'pages/nginx',
5454 'pages/node',
55+ 'pages/npm',
5556 'pages/php',
5657 'pages/phpunit',
5758 'pages/postgres',
assets/stylesheets/application.css.scss+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 'pages/moment',
5353 'pages/nginx',
5454 'pages/node',
55+ 'pages/npm',
5556 'pages/php',
5657 'pages/phpunit',
5758 'pages/postgres',
assets/stylesheets/global/_icons.scss+1−0
@@ -99,3 +99,4 @@ · 98 unmodified lines
9999 ._icon-symfony:before { background-position: -5rem -7rem; }
100100 ._icon-mocha:before { background-position: -6rem -7rem; }
101101 ._icon-meteor:before { background-position: -7rem -7rem; @extend %darkIconFix !optional; }
102+._icon-npm:before { background-position: -8rem -7rem }
assets/stylesheets/pages/_base.scss+1−0
@@ -27,3 +27,4 @@ · 26 unmodified lines
2727 ._sinon {
2828 @extend %simple;
2929 }
30+
assets/stylesheets/pages/_npm.scss+15−0
@@ -0,0 +1,15 @@
1+._npm {
2+ @extend %simple;
3+
4+ .pageColumns {
5+ padding-left: 0;
6+ list-style: none;
7+ }
8+
9+ .faint.heading {
10+ font-size: .9em;
11+ color: $textColorLight;
12+ }
13+
14+ .youtube-video iframe { width: 420px; height: 315px; }
15+}
lib/docs/filters/npm/clean_html.rb+28−0
@@ -0,0 +1,28 @@
1+module Docs
2+ class Npm
3+ class CleanHtmlFilter < Filter
4+ def call
5+ if root_page?
6+ css('#enterprise', '#policies', '#viewAll').remove
7+ else
8+ @doc = doc.at_css('#page')
9+ css('meta', '.colophon').remove
10+ end
11+
12+ css('> section', '.deep-link > a').each do |node|
13+ node.before(node.children).remove
14+ end
15+
16+ css('pre.editor').each do |node|
17+ node.inner_html = node.inner_html.gsub(/<\/div>(?!\n|\z)/, "</div>\n")
18+ end
19+
20+ css('pre').each do |node|
21+ node.content = node.content
22+ end
23+
24+ doc
25+ end
26+ end
27+ end
28+end
lib/docs/filters/npm/entries.rb+43−0
@@ -0,0 +1,43 @@
1+module Docs
2+ class Npm
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ if slug.start_with?('api') && at_css('pre').content =~ /\A\s*npm\.([\w\-]+\.)*[\w\-]+/
6+ name = $&.strip
7+ else
8+ name = at_css('nav > section.active a.active').content
9+ end
10+
11+ name << ' (CLI)' if slug.start_with?('cli')
12+ name
13+ end
14+
15+ def get_type
16+ case slug
17+ when 'files/package.json'
18+ 'package.json'
19+ when 'misc/config'
20+ 'Config'
21+ else
22+ at_css('nav > section.active > h2').content
23+ end
24+ end
25+
26+ def additional_entries
27+ case slug
28+ when 'files/package.json'
29+ css('#page > h2[id]').each_with_object [] do |node, entries|
30+ next if node.content =~ /\A[A-Z]/
31+ entries << ["package.json: #{node.content}", node['id']]
32+ end
33+ when 'misc/config'
34+ css('#config-settings ~ h3[id]').map do |node|
35+ ["config: #{node.content}", node['id']]
36+ end
37+ else
38+ []
39+ end
40+ end
41+ end
42+ end
43+end
lib/docs/scrapers/npm.rb+31−0
@@ -0,0 +1,31 @@
1+module Docs
2+ class Npm < UrlScraper
3+ self.name = 'npm'
4+ self.type = 'npm'
5+ self.version = '2.8.4'
6+ self.base_url = 'https://docs.npmjs.com/'
7+ self.links = {
8+ home: 'https://www.npmjs.com/',
9+ code: 'https://github.com/npm/npm'
10+ }
11+
12+ html_filters.push 'npm/entries', 'npm/clean_html', 'title'
13+
14+ options[:container] = ->(filter) { filter.root_page? ? '.toc' : nil }
15+ options[:title] = false
16+ options[:root_title] = 'npm'
17+
18+ options[:skip] = %w(all)
19+ options[:skip_patterns] = [
20+ /\Aenterprise/,
21+ /\Acompany/,
22+ /\Apolicies/
23+ ]
24+
25+ options[:attribution] = <<-HTML
26+ &copy; npm, Inc. and Contributors<br>
27+ Licensed under the npm License.<br>
28+ npm is a trademark of npm, Inc.
29+ HTML
30+ end
31+end
public/icons/docs/npm/16.png+0−0

Binary file not shown.

public/icons/docs/npm/16@2x.png+0−0

Binary file not shown.

public/icons/docs/npm/SOURCE+1−0
@@ -0,0 +1 @@
1+https://www.npmjs.com/