mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1549 from Cimbali/webexts
This commit is contained in:
commit
df7fa0ba5e
3 changed files with 51 additions and 0 deletions
9
lib/docs/filters/web_extensions/clean_html.rb
Normal file
9
lib/docs/filters/web_extensions/clean_html.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Docs
|
||||
class WebExtensions
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
24
lib/docs/filters/web_extensions/entries.rb
Normal file
24
lib/docs/filters/web_extensions/entries.rb
Normal 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
|
18
lib/docs/scrapers/mdn/web_extensions.rb
Normal file
18
lib/docs/scrapers/mdn/web_extensions.rb
Normal 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
|
Loading…
Reference in a new issue