diff --git a/assets/images/icons.png b/assets/images/icons.png index eb4fa489..1b1906a8 100644 Binary files a/assets/images/icons.png and b/assets/images/icons.png differ diff --git a/assets/images/icons@2x.png b/assets/images/icons@2x.png index a027c705..8d236a2b 100644 Binary files a/assets/images/icons@2x.png and b/assets/images/icons@2x.png differ diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index f18e4523..d333742b 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,5 +1,8 @@ [ [ + "2015-04-26", + "New npm documentation" + ], [ "2015-03-22", "New Meteor and mocha documentations" ], [ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index d9591eef..81ee046f 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -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
npm is a trademark of npm, Inc.', + 'npm', + 'https://raw.githubusercontent.com/npm/npm/master/LICENSE' ], [ 'PHP', '1997-2015 The PHP Documentation Group', diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 0e40ef14..34eb902d 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -52,6 +52,7 @@ 'pages/moment', 'pages/nginx', 'pages/node', + 'pages/npm', 'pages/php', 'pages/phpunit', 'pages/postgres', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index a7810b94..4fc1fc87 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -52,6 +52,7 @@ 'pages/moment', 'pages/nginx', 'pages/node', + 'pages/npm', 'pages/php', 'pages/phpunit', 'pages/postgres', diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index abe57e13..3093a756 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -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 } diff --git a/assets/stylesheets/pages/_base.scss b/assets/stylesheets/pages/_base.scss index 0d61b1ab..59bfaf48 100644 --- a/assets/stylesheets/pages/_base.scss +++ b/assets/stylesheets/pages/_base.scss @@ -27,3 +27,4 @@ ._sinon { @extend %simple; } + diff --git a/assets/stylesheets/pages/_npm.scss b/assets/stylesheets/pages/_npm.scss new file mode 100644 index 00000000..9bbcc74c --- /dev/null +++ b/assets/stylesheets/pages/_npm.scss @@ -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; } +} diff --git a/lib/docs/filters/npm/clean_html.rb b/lib/docs/filters/npm/clean_html.rb new file mode 100644 index 00000000..c86dcdfd --- /dev/null +++ b/lib/docs/filters/npm/clean_html.rb @@ -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)/, "\n") + end + + css('pre').each do |node| + node.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/npm/entries.rb b/lib/docs/filters/npm/entries.rb new file mode 100644 index 00000000..690f2e6f --- /dev/null +++ b/lib/docs/filters/npm/entries.rb @@ -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 diff --git a/lib/docs/scrapers/npm.rb b/lib/docs/scrapers/npm.rb new file mode 100644 index 00000000..e3bc6f8a --- /dev/null +++ b/lib/docs/scrapers/npm.rb @@ -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
+ Licensed under the npm License.
+ npm is a trademark of npm, Inc. + HTML + end +end diff --git a/public/icons/docs/npm/16.png b/public/icons/docs/npm/16.png new file mode 100644 index 00000000..7c2f7787 Binary files /dev/null and b/public/icons/docs/npm/16.png differ diff --git a/public/icons/docs/npm/16@2x.png b/public/icons/docs/npm/16@2x.png new file mode 100644 index 00000000..17f4c2d6 Binary files /dev/null and b/public/icons/docs/npm/16@2x.png differ diff --git a/public/icons/docs/npm/SOURCE b/public/icons/docs/npm/SOURCE new file mode 100644 index 00000000..82a6a1d4 --- /dev/null +++ b/public/icons/docs/npm/SOURCE @@ -0,0 +1 @@ +https://www.npmjs.com/