Merge pull request #1638 from freeCodeCamp/mdn

Update MDN documentation
pull/1642/head
Simon Legner 3 years ago committed by GitHub
commit 10448a0a0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2222,7 +2222,7 @@ function urlencode(o) {
return pairs.join('&');
}
// borrowed from https://tools.ietf.org/html/rfc3986#appendix-B
// borrowed from https://datatracker.ietf.org/doc/html/rfc3986#appendix-B
// intentionally using regex and not <a/> href parsing trick because React Native and other
// environments where DOM might not be available
function parseUrl(url) {

@ -107,7 +107,7 @@
code > strong { font-weight: normal; }
// Compatibility tablees
// Compatibility tables
.bc-github-link {
float: right;
@ -115,6 +115,7 @@
}
.bc-supports-yes, .bc-supports-yes + dd, .bc-supports-yes + dd + dd { background: var(--noteGreenBackground); }
.bc-supports-unknown, .bc-supports-unknown + dd, .bc-supports-unknown + dd + dd { background: var(--noteBackground); }
.bc-supports-partial, .bc-supports-partial + dd, .bc-supports-partial + dd + dd { background: var(--noteOrangeBackground); }
.bc-supports-no, .bc-supports-no + dd, .bc-supports-no + dd + dd { background: var(--noteRedBackground); }
@ -130,4 +131,8 @@
dd { margin: 0; }
}
iframe.interactive {
width: 100%;
}
}

@ -2,7 +2,7 @@ module Docs
class Http
class CleanHtmlFilter < Filter
def call
current_url.host == 'tools.ietf.org' ? ietf : mdn
current_url.host == 'datatracker.ietf.org' ? ietf : mdn
doc
end
@ -43,7 +43,7 @@ module Docs
end
css('.selflink').each do |node|
node.parent['id'] = node['name']
node.parent['id'] = node['id']
node.before(node.children).remove
end

@ -2,7 +2,7 @@ module Docs
class Http
class EntriesFilter < Docs::EntriesFilter
def get_name
if current_url.host == 'tools.ietf.org'
if current_url.host == 'datatracker.ietf.org'
name = at_css('h1').content
name.remove! %r{\A.+\:}
name.remove! %r{\A.+\-\-}
@ -22,7 +22,7 @@ module Docs
end
def get_type
return name if current_url.host == 'tools.ietf.org'
return name if current_url.host == 'datatracker.ietf.org'
if slug.start_with?('Headers/Content-Security-Policy')
'CSP'
@ -101,7 +101,7 @@ module Docs
LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/
def additional_entries
return [] unless current_url.host == 'tools.ietf.org'
return [] unless current_url.host == 'datatracker.ietf.org'
type = nil
css('a[href^="#section-"]').each_with_object([]) do |node, entries|

@ -46,7 +46,9 @@ module Docs
end
def request_bcd_uris
index_json = JSON.load(Net::HTTP.get(URI(current_url.to_s + '/index.json')))
url = current_url.to_s + '/index.json'
response = Request.run url
index_json = JSON.load response.body
uris = []
@ -63,9 +65,9 @@ module Docs
return uris
end
def generate_compatibility_table_wrapper(uri)
@json_data = JSON.load(Net::HTTP.get(URI(uri)))['data']
def generate_compatibility_table_wrapper(url)
response = Request.run url
@json_data = JSON.load(response.body)['data']
html_table = generate_basic_html_table()
@ -163,15 +165,14 @@ module Docs
version_added.map! do |version|
if version == true
version = 'Yes'
'Yes'
elsif version == false
version = 'No'
'No'
elsif version.is_a?(String)
version
else
version = '?'
'?'
end
version
end
if version_removed[0]
@ -179,6 +180,8 @@ module Docs
else
if version_added[0] == 'No'
format_string = "<td class=bc-supports-no>"
elsif version_added[0] == '?'
format_string = "<td class=bc-supports-unknown>"
else
format_string = "<td class=bc-supports-yes>"
end
@ -201,7 +204,7 @@ module Docs
end
else
format_string = "<td class=bc-supports-no><div>?</div></td>"
format_string = "<td class=bc-supports-unknown><div>?</div></td>"
end
entry.add_child(format_string)

@ -2,15 +2,25 @@ module Docs
class Http < Mdn
include MultipleBaseUrls
# release = '2021-10-22'
self.name = 'HTTP'
self.base_urls = ['https://developer.mozilla.org/en-US/docs/Web/HTTP', 'https://tools.ietf.org/html/']
self.base_urls = [
'https://developer.mozilla.org/en-US/docs/Web/HTTP',
'https://datatracker.ietf.org/doc/html/',
]
html_filters.push 'http/clean_html', 'http/entries', 'title'
options[:root_title] = 'HTTP'
options[:title] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title }
options[:container] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? '.content' : nil }
options[:skip_links] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? true : false }
options[:title] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? false : filter.default_title
end
options[:container] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? '.content .draftcontent' : Docs::Mdn.options[:container]
end
options[:skip_links] = ->(filter) do
filter.current_url.host == 'datatracker.ietf.org' ? true : false
end
options[:replace_paths] = { '/Access_control_CORS' => '/CORS' }
options[:fix_urls] = ->(url) do
url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
@ -18,7 +28,7 @@ module Docs
end
options[:attribution] = ->(filter) do
if filter.current_url.host == 'tools.ietf.org'
if filter.current_url.host == 'datatracker.ietf.org'
"&copy; document authors. All rights reserved."
else
Docs::Mdn.options[:attribution]
@ -27,16 +37,16 @@ module Docs
def initial_urls
%w(https://developer.mozilla.org/en-US/docs/Web/HTTP
https://tools.ietf.org/html/rfc2616
https://tools.ietf.org/html/rfc4918
https://tools.ietf.org/html/rfc7230
https://tools.ietf.org/html/rfc7231
https://tools.ietf.org/html/rfc7232
https://tools.ietf.org/html/rfc7233
https://tools.ietf.org/html/rfc7234
https://tools.ietf.org/html/rfc7235
https://tools.ietf.org/html/rfc7540
https://tools.ietf.org/html/rfc5023)
https://datatracker.ietf.org/doc/html/rfc2616
https://datatracker.ietf.org/doc/html/rfc4918
https://datatracker.ietf.org/doc/html/rfc7230
https://datatracker.ietf.org/doc/html/rfc7231
https://datatracker.ietf.org/doc/html/rfc7232
https://datatracker.ietf.org/doc/html/rfc7233
https://datatracker.ietf.org/doc/html/rfc7234
https://datatracker.ietf.org/doc/html/rfc7235
https://datatracker.ietf.org/doc/html/rfc7540
https://datatracker.ietf.org/doc/html/rfc5023)
end
end
end

@ -1,5 +1,6 @@
module Docs
class Css < Mdn
# release = '2021-10-22'
self.name = 'CSS'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/CSS'
self.root_path = '/Reference'

@ -1,6 +1,7 @@
module Docs
class Dom < Mdn
# release = '2021-10-22'
self.name = 'DOM'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/API'

@ -2,6 +2,7 @@ module Docs
class Html < Mdn
prepend FixInternalUrlsBehavior
# release = '2021-10-22'
self.name = 'HTML'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'

@ -3,6 +3,7 @@ module Docs
prepend FixInternalUrlsBehavior
prepend FixRedirectionsBehavior
# release = '2021-10-22'
self.name = 'JavaScript'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference'

@ -3,6 +3,7 @@ module Docs
prepend FixInternalUrlsBehavior
prepend FixRedirectionsBehavior
# release = '2021-10-22'
self.name = 'SVG'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/SVG'

@ -1,5 +1,6 @@
module Docs
class WebExtensions < Mdn
# release = '2021-10-22'
self.name = 'Web Extensions'
self.slug = 'web_extensions'
self.links = {

@ -1,5 +1,6 @@
module Docs
class XsltXpath < Mdn
# release = '2021-10-22'
self.name = 'XSLT & XPath'
self.slug = 'xslt_xpath'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web'

Loading…
Cancel
Save