Skip to content

Commit 22e7767

Browse files
authored
Merge pull request #1473 from freeCodeCamp/mdn/yari
mdn: update scraper to mdn/yari
2 parents a721460 + a0776af commit 22e7767

File tree

14 files changed

+20
-152
lines changed

14 files changed

+20
-152
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ credits = [
203203
'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE'
204204
], [
205205
'CSS<br>DOM<br>HTTP<br>HTML<br>JavaScript<br>SVG<br>XPath',
206-
'2005-2020 Mozilla and individual contributors',
206+
'2005-2021 MDN contributors',
207207
'CC BY-SA',
208208
'https://creativecommons.org/licenses/by-sa/2.5/'
209209
], [

assets/stylesheets/pages/_mdn.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
p > code, li > code { @extend %label; }
2828

2929
> .note,
30+
.notecard, // MDN 2021
3031
.notice,
3132
.warning,
3233
.overheadIndicator,

lib/docs/filters/mdn/clean_html.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def call
4141
node.parent['id'] = node['name']
4242
node.before(node.content).remove
4343
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
4456

4557
css('dt > a[id]').each do |node|
4658
next if node['href']
@@ -64,6 +76,9 @@ def call
6476
end
6577

6678
# 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
6782

6883
css('.bc-data #Legend + dl', '.bc-data #Legend', '.bc-data #Legend_2 + dl', '.bc-data #Legend_2', '.bc-browser-name').remove
6984

lib/docs/filters/mdn/contribute_link.rb

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/docs/filters/svg/clean_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def root
1111
end
1212

1313
def other
14-
css('.prevnext').remove
14+
css('.prev-next').remove
1515

1616
if at_css('p').content.include?("\u{00AB}")
1717
at_css('p').remove

lib/docs/scrapers/http.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class Http < Mdn
77

88
html_filters.push 'http/clean_html', 'http/entries', 'title'
99

10-
options[:mdn_tag] = 'HTTP'
11-
1210
options[:root_title] = 'HTTP'
1311
options[:title] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title }
1412
options[:container] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? '.content' : nil }

lib/docs/scrapers/mdn/css.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ class Css < Mdn
66

77
html_filters.push 'css/clean_html', 'css/entries', 'title'
88

9-
options[:mdn_tag] = 'CSS'
10-
119
options[:root_title] = 'CSS'
1210

1311
options[:skip] = %w(/CSS3 /Media/Visual /paged_media /Media/TV /Media/Tactile)

lib/docs/scrapers/mdn/dom.rb

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,12 @@
11
module Docs
22
class Dom < Mdn
3-
prepend FixInternalUrlsBehavior
4-
prepend FixRedirectionsBehavior
53

64
self.name = 'DOM'
75
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/API'
86

97
html_filters.push 'dom/clean_html', 'dom/entries', 'title'
108

11-
options[:mdn_tag] = 'XSLT_Reference'
12-
139
options[:root_title] = 'DOM'
1410

15-
options[:skip] = %w(
16-
/Reference
17-
/Index
18-
/Document_Object_Model
19-
/document/createProcessingInstruction
20-
/document/documentURIObject
21-
/document/loadOverlay
22-
/document/tooltipNode
23-
/Document/cookie/Simple_document.cookie_framework
24-
/DOMErrorHandler
25-
/DOMLocator
26-
/DOMObject
27-
/DOMStringList
28-
/Event/Comparison_of_Event_Targets
29-
/Format
30-
/IDBDatabaseException
31-
/IndexedDB_API/Using_JavaScript_Generators_in_Firefox
32-
/Notation
33-
/ProcessingInstruction
34-
/TypeInfo
35-
/window/getAttention
36-
/window/messageManager
37-
/window/updateCommands
38-
/window/pkcs11
39-
/OES_texture_float)
40-
41-
options[:skip_patterns] = [
42-
/NS/,
43-
/XPC/,
44-
/moz/i,
45-
/gecko/i,
46-
/webkit/i,
47-
/gamepad/i,
48-
/UserData/,
49-
/Bluetooth/,
50-
/FMRadio/i,
51-
/XDomainRequest/i,
52-
/\A\/Camera/,
53-
/\A\/Data_Store_API/,
54-
/\A\/DataStore/,
55-
/\A\/DeviceStorage/,
56-
/\A\/DocumentTouch/,
57-
/\A\/document\/xml/,
58-
/\A\/XMLDocument/,
59-
/\A\/DOMCursor/,
60-
/\A\/DOMRequest/,
61-
/\A\/InstallTrigger/,
62-
/\A\/Entity/,
63-
/\A\/Settings/,
64-
/telephony/i,
65-
/\A\/NFC_API/,
66-
/\A\/Window\/\w+bar/i,
67-
/\A\/Apps/,
68-
/\A\/Contact/,
69-
/\A\/L10n/,
70-
/\A\/Permission/]
71-
72-
options[:fix_urls] = ->(url) do
73-
return if url.include?('_') || url.include?('?')
74-
url.sub! 'https://developer.mozilla.org/en-US/docs/DOM/', "#{Dom.base_url}/"
75-
url.sub! 'https://developer.mozilla.org/en/DOM/', "#{Dom.base_url}/"
76-
url.sub! 'https://developer.mozilla.org/Web/API/', "#{Dom.base_url}/"
77-
url.sub! "#{Dom.base_url}/Console", "#{Dom.base_url}/console"
78-
url.sub! "#{Dom.base_url}/Document\/", "#{Dom.base_url}/document\/"
79-
url.sub! "#{Dom.base_url}/Element", "#{Dom.base_url}/element"
80-
url.sub! "#{Dom.base_url}/History", "#{Dom.base_url}/history"
81-
url.sub! "#{Dom.base_url}/Location", "#{Dom.base_url}/location"
82-
url.sub! "#{Dom.base_url}/Navigator", "#{Dom.base_url}/navigator"
83-
url.sub! "#{Dom.base_url}/Screen", "#{Dom.base_url}/screen"
84-
url.sub! "#{Dom.base_url}/Window\/", "#{Dom.base_url}/window\/"
85-
url.sub! "#{Dom.base_url}/notification", "#{Dom.base_url}/Notification"
86-
url.sub! "#{Dom.base_url}/range", "#{Dom.base_url}/Range"
87-
url.sub! "#{Dom.base_url}/event", "#{Dom.base_url}/Event"
88-
url.sub! '/en/DOM/Manipulating_the_browser_history', "/en-US/docs/Web/API/History_API"
89-
url
90-
end
9111
end
9212
end

lib/docs/scrapers/mdn/dom_events.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/docs/scrapers/mdn/html.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class Html < Mdn
77

88
html_filters.push 'html/clean_html', 'html/entries', 'title'
99

10-
options[:mdn_tag] = 'HTML'
11-
1210
options[:root_title] = 'HTML'
1311

1412
options[:title] = ->(filter) do

0 commit comments

Comments
 (0)