History

Update npm documentation (10.2.5)

Simon Legner committed 2 years ago

Commit bf894451 parent 93cc8b33 files · +12 −14Browse files

Unified · Split

3 files
  1. lib/docs/filters/npm/clean_html.rb +5 −11
  2. lib/docs/filters/npm/entries.rb +2 −1
  3. lib/docs/scrapers/npm.rb +5 −2
lib/docs/filters/npm/clean_html.rb+5−11
@@ -2,18 +2,13 @@ module Docs · 1 unmodified line
22 class Npm
33 class CleanHtmlFilter < Filter
44 def call
5−
6− at_css('#___gatsby').before(at_css('h1'))
5+ @doc = at_css('main')
76
87 css('details').remove
9−
10− css('.dZYhXG', '.fONtKn').remove
11−
12− css('.kSYjyK').remove
13−
14− css('.cDvIaH').remove
15−
16− css('.jRndWL').remove_attribute('style')
8+ css('nav[aria-label="Breadcrumbs"]').remove
9+ css('.gtWOdv').remove # Select CLI Version
10+ css('.ezMiXD').remove # Navbox
11+ css('.gOhcvK').remove # Edit this page on GitHub
1712
1813 css('pre').each do |node|
1914 node.content = node.css('.token-line').map(&:content).join("\n")
@@ -21,7 +16,6 @@ module Docs · 1 unmodified line
2116 end
2217
2318 doc
24−
2519 end
2620 end
2721 end
lib/docs/filters/npm/entries.rb+2−1
@@ -7,7 +7,7 @@ module Docs · 6 unmodified lines
77 end
88
99 def get_type
10− at_css('.active').content
10+ at_css('nav[aria-label="Breadcrumbs"] li').content
1111 end
1212
1313 def additional_entries
@@ -21,6 +21,7 @@ module Docs · 7 unmodified lines
2121
2222 if name == 'package.json'
2323 css('h3').each do |node|
24+ next unless node['id']
2425 entries << [node['id'], slug + '#' + node['id'], 'Package.json Settings']
2526 end
2627 end
lib/docs/scrapers/npm.rb+5−2
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
22 class Npm < UrlScraper
33 self.name = 'npm'
44 self.type = 'npm'
5− self.release = '8.3.0'
5+ self.release = '10.2.5'
66 self.base_url = 'https://docs.npmjs.com/'
77 self.force_gzip = true
88 self.links = {
@@ -12,7 +12,8 @@ module Docs · 3 unmodified lines
1212
1313 html_filters.push 'npm/entries', 'npm/clean_html'
1414
15− options[:max_image_size] = 130_000
15+ options[:download_images] = false
16+ # options[:max_image_size] = 130_000
1617
1718 options[:skip] = [
1819 'all',
@@ -31,6 +32,8 @@ module Docs · 12 unmodified lines
3132 /\Apolicies/,
3233 /cli\/v6/,
3334 /cli\/v7/,
35+ /cli\/v8/,
36+ /cli\/v9/,
3437 /\/\Z/ # avoid pages with a trailing slash, those pages mess up the entries
3538 ]
3639