Merge pull request #1549 from Cimbali/webexts

This commit is contained in:
Simon Legner 2021-05-31 21:08:51 +02:00 committed by GitHub
commit df7fa0ba5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,9 @@
module Docs
class WebExtensions
class CleanHtmlFilter < Filter
def call
doc
end
end
end
end

View file

@ -0,0 +1,24 @@
module Docs
class WebExtensions
class EntriesFilter < Docs::EntriesFilter
TYPE_BY_PATH = {
'manifest.json' => 'manifest.json',
'user_interface' => 'User Interface',
'WebRequest' => 'webRequest',
}
def get_name
at_css('h1').text
end
def get_type
slug_parts = slug.split('/')
if slug_parts[0] == 'API' and slug_parts.length() > 1
return TYPE_BY_PATH.fetch(slug_parts[1], slug_parts[1])
else
return TYPE_BY_PATH.fetch(slug_parts[0], slug_parts.length() > 1 ? slug_parts[0] : 'Miscellaneous')
end
end
end
end
end

View file

@ -0,0 +1,18 @@
module Docs
class WebExtensions < Mdn
self.name = 'Web Extensions'
self.slug = 'web_extensions'
self.links = {
home: 'https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions'
}
self.base_url = 'https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions'
html_filters.push 'web_extensions/entries', 'web_extensions/clean_html'
options[:skip_patterns] = [
/\/contributors\.txt$/
]
end
end