Index HTML attributes

pull/129/head
Thibaut 11 years ago
parent 4a72a972df
commit fd203212ac

@ -3,13 +3,17 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
HTML5 = %w(content element video) HTML5 = %w(content element video)
OBSOLETE = %w(frame frameset hgroup noframes) OBSOLETE = %w(frame frameset hgroup noframes)
ADDITIONAL_ENTRIES = { 'Heading_Elements' => (1..6).map { |n| ["h#{n}"] } } ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } }
def get_name def get_name
super.downcase name = super
name.remove!('Element.').try(:downcase!)
name
end end
def get_type def get_type
slug = self.slug.remove('Element/')
if at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug) if at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)
'Obsolete' 'Obsolete'
else else
@ -23,11 +27,21 @@ module Docs
end end
def include_default_entry? def include_default_entry?
slug != 'Heading_Elements' !%w(Attributes Element/Heading_Elements).include?(slug)
end end
def additional_entries def additional_entries
ADDITIONAL_ENTRIES[slug] || [] return ADDITIONAL_ENTRIES[slug] if ADDITIONAL_ENTRIES.key?(slug)
if slug == 'Attributes'
css('.standard-table td:first-child').map do |node|
name = node.content.strip
id = node.parent['id'] = name.parameterize
[name, id, 'Attributes']
end
else
[]
end
end end
def html5_spec?(spec) def html5_spec?(spec)

@ -1,26 +1,32 @@
module Docs module Docs
class Html < Mdn class Html < Mdn
self.name = 'HTML' self.name = 'HTML'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element' self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'
self.root_path = '/Element'
self.initial_paths = %w(/Attributes)
html_filters.push 'html/clean_html', 'html/entries', 'title' html_filters.push 'html/clean_html', 'html/entries', 'title'
options[:root_title] = 'HTML' options[:root_title] = 'HTML'
options[:title] = ->(filter) do options[:title] = ->(filter) do
if filter.slug == 'Heading_Elements' if filter.slug == 'Element/Heading_Elements'
'Heading Elements' 'Heading Elements'
elsif filter.slug == 'Attributes'
'Attributes'
else else
"<#{filter.default_title}>" "<#{filter.default_title}>"
end end
end end
options[:only_patterns] = [/\A\/Element/]
options[:replace_paths] = { options[:replace_paths] = {
'/h1' => '/Heading_Elements', '/Element/h1' => '/Element/Heading_Elements',
'/h2' => '/Heading_Elements', '/Element/h2' => '/Element/Heading_Elements',
'/h3' => '/Heading_Elements', '/Element/h3' => '/Element/Heading_Elements',
'/h4' => '/Heading_Elements', '/Element/h4' => '/Element/Heading_Elements',
'/h5' => '/Heading_Elements', '/Element/h5' => '/Element/Heading_Elements',
'/h6' => '/Heading_Elements' } '/Element/h6' => '/Element/Heading_Elements' }
end end
end end

Loading…
Cancel
Save