diff --git a/lib/docs/filters/web_extensions/clean_html.rb b/lib/docs/filters/web_extensions/clean_html.rb new file mode 100644 index 00000000..88ec0373 --- /dev/null +++ b/lib/docs/filters/web_extensions/clean_html.rb @@ -0,0 +1,9 @@ +module Docs + class WebExtensions + class CleanHtmlFilter < Filter + def call + doc + end + end + end +end diff --git a/lib/docs/filters/web_extensions/entries.rb b/lib/docs/filters/web_extensions/entries.rb new file mode 100644 index 00000000..f04efb37 --- /dev/null +++ b/lib/docs/filters/web_extensions/entries.rb @@ -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 diff --git a/lib/docs/scrapers/mdn/web_extensions.rb b/lib/docs/scrapers/mdn/web_extensions.rb new file mode 100644 index 00000000..1a5f528a --- /dev/null +++ b/lib/docs/scrapers/mdn/web_extensions.rb @@ -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