History

mdn: update scraper to mdn/yari

Simon Legner committed 5 years ago

Commit 4dc95571 parent 92d8a8e4 files · +18 −12Browse files

Unified · Split

4 files
  1. assets/stylesheets/pages/_mdn.scss +1 −0
  2. lib/docs/filters/mdn/clean_html.rb +15 −0
  3. lib/docs/filters/svg/clean_html.rb +1 −1
  4. lib/docs/scrapers/mdn/mdn.rb +1 −11
assets/stylesheets/pages/_mdn.scss+1−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
27 p > code, li > code { @extend %label; }27 p > code, li > code { @extend %label; }
28 28
29 > .note,29 > .note,
30 .notecard, // MDN 2021
30 .notice,31 .notice,
31 .warning,32 .warning,
32 .overheadIndicator,33 .overheadIndicator,
lib/docs/filters/mdn/clean_html.rb+15−0
@@ -41,6 +41,18 @@ module Docs · 40 unmodified lines
41 node.parent['id'] = node['name']41 node.parent['id'] = node['name']
42 node.before(node.content).remove42 node.before(node.content).remove
43 end43 end
44 css('h2 > a, h3 > a').each do |node|
45 node.parent.content = node.content
46 end
47
48 css('.notecard > h4').each do |node|
49 node.name = 'strong'
50 end
51
52 css('svg.deprecated').each do |node|
53 node.name = 'span'
54 node.content = node.content
55 end
44 56
45 css('dt > a[id]').each do |node|57 css('dt > a[id]').each do |node|
46 next if node['href']58 next if node['href']
@@ -64,6 +76,9 @@ module Docs · 17 unmodified lines
64 end76 end
65 77
66 # New compatibility tables78 # New compatibility tables
79 # FIXME(2021):
80 # - fetched from external JSON: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/alignment-baseline/bcd.json
81 # - https://github.com/mdn/yari/blob/master/build/bcd-urls.js
67 82
68 css('.bc-data #Legend + dl', '.bc-data #Legend', '.bc-data #Legend_2 + dl', '.bc-data #Legend_2', '.bc-browser-name').remove83 css('.bc-data #Legend + dl', '.bc-data #Legend', '.bc-data #Legend_2 + dl', '.bc-data #Legend_2', '.bc-browser-name').remove
69 84
lib/docs/filters/svg/clean_html.rb+1−1
@@ -11,7 +11,7 @@ module Docs · 10 unmodified lines
11 end11 end
12 12
13 def other13 def other
14 css('.prevnext').remove14 css('.prev-next').remove
15 15
16 if at_css('p').content.include?("\u{00AB}")16 if at_css('p').content.include?("\u{00AB}")
17 at_css('p').remove17 at_css('p').remove
lib/docs/scrapers/mdn/mdn.rb+1−11
@@ -3,12 +3,9 @@ module Docs · 2 unmodified lines
3 self.abstract = true3 self.abstract = true
4 self.type = 'mdn'4 self.type = 'mdn'
5 5
6 params[:raw] = 1
7 params[:macros] = 1
8
9 html_filters.push 'mdn/clean_html'6 html_filters.push 'mdn/clean_html'
10 7
11 options[:rate_limit] = 2008 options[:container] = '#content'
12 options[:trailing_slash] = false9 options[:trailing_slash] = false
13 10
14 options[:skip_link] = ->(link) {11 options[:skip_link] = ->(link) {
@@ -23,12 +20,5 @@ module Docs · 8 unmodified lines
23 def get_latest_version(opts)20 def get_latest_version(opts)
24 get_latest_github_commit_date('mdn', 'content', opts)21 get_latest_github_commit_date('mdn', 'content', opts)
25 end22 end
26
27 private
28
29 def process_response?(response)
30 response.effective_url.host = 'developer.mozilla.org' if response.effective_url.host == 'wiki.developer.mozilla.org'
31 super && response.effective_url.query == 'raw=1&macros=1'
32 end
33 end23 end
34end24end