|
|
@ -1,69 +1,33 @@
|
|
|
|
module Docs
|
|
|
|
module Docs
|
|
|
|
class React
|
|
|
|
class React
|
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
|
API_SLUGS = %w(
|
|
|
|
|
|
|
|
docs/top-level-api
|
|
|
|
|
|
|
|
docs/component-api
|
|
|
|
|
|
|
|
docs/component-specs
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REPLACE_TYPES = {
|
|
|
|
|
|
|
|
'Quick Start' => 'Guides',
|
|
|
|
|
|
|
|
'User Guide' => 'Guides',
|
|
|
|
|
|
|
|
'The Basics' => 'Getting Started',
|
|
|
|
|
|
|
|
'apis' => 'APIs',
|
|
|
|
|
|
|
|
'components' => 'Components'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_name
|
|
|
|
def get_name
|
|
|
|
at_css('h1').children.select(&:text?).map(&:content).join.strip
|
|
|
|
at_css('h1').children.select(&:text?).map(&:content).join.strip
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_type
|
|
|
|
def get_type
|
|
|
|
link = at_css('.nav-docs-section .active, .toc .active')
|
|
|
|
link = at_css('.nav-docs-section .active, .toc .active')
|
|
|
|
return 'Miscellaneous' unless link
|
|
|
|
|
|
|
|
section = link.ancestors('.nav-docs-section, section').first
|
|
|
|
section = link.ancestors('.nav-docs-section, section').first
|
|
|
|
type = section.at_css('h3').content.strip
|
|
|
|
type = section.at_css('h3').content.strip
|
|
|
|
type = REPLACE_TYPES[type] || type
|
|
|
|
|
|
|
|
type += ": #{name}" if type == 'Components'
|
|
|
|
|
|
|
|
type
|
|
|
|
type
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def additional_entries
|
|
|
|
def additional_entries
|
|
|
|
if API_SLUGS.include?(slug)
|
|
|
|
css('.inner-content h3 code, .inner-content h4 code').each_with_object([]) do |node, entries|
|
|
|
|
css('.inner-content h3, .inner-content h4').map do |node|
|
|
|
|
name = node.content
|
|
|
|
name = node.content
|
|
|
|
name.remove! %r{[#\(\)]}
|
|
|
|
name.remove! %r{[#\(\)]}
|
|
|
|
name.remove! %r{\w+\:}
|
|
|
|
name.remove! %r{\w+\:}
|
|
|
|
name.strip!
|
|
|
|
id = node.at_css('.anchor')['name']
|
|
|
|
name = 'createFragmentobject' if name.include?('createFragmentobject')
|
|
|
|
type = slug.include?('component') ? 'Component' : 'React'
|
|
|
|
id = node.parent.at_css('.anchor')['name']
|
|
|
|
[name, id, type]
|
|
|
|
type = if slug == 'react-component'
|
|
|
|
end
|
|
|
|
'Reference: Component'
|
|
|
|
else
|
|
|
|
elsif slug == 'react-api'
|
|
|
|
entries = []
|
|
|
|
'Reference: React'
|
|
|
|
|
|
|
|
else
|
|
|
|
css('.props > .prop > .propTitle', '.props > .prop > .methodTitle').each do |node| # react-native
|
|
|
|
'Reference'
|
|
|
|
name = node.children.find(&:text?).try(:content)
|
|
|
|
|
|
|
|
next if name.blank?
|
|
|
|
|
|
|
|
sep = node.content.include?('static') ? '.' : '#'
|
|
|
|
|
|
|
|
name.prepend(self.name + sep)
|
|
|
|
|
|
|
|
name << '()' if node['class'].include?('methodTitle')
|
|
|
|
|
|
|
|
id = node.at_css('.anchor')['name']
|
|
|
|
|
|
|
|
entries << [name, id]
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
entries << [name, id, type]
|
|
|
|
css('.apiIndex a pre').each do |node| # relay
|
|
|
|
|
|
|
|
next unless node.parent['href'].start_with?('#')
|
|
|
|
|
|
|
|
id = node.parent['href'].remove('#')
|
|
|
|
|
|
|
|
name = node.content.strip
|
|
|
|
|
|
|
|
sep = name.start_with?('static') ? '.' : '#'
|
|
|
|
|
|
|
|
name.remove! %r{(abstract|static) }
|
|
|
|
|
|
|
|
name.sub! %r{\(.*\)}, '()'
|
|
|
|
|
|
|
|
name.prepend(self.name + sep)
|
|
|
|
|
|
|
|
entries << [name, id]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entries
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|