|
|
@ -2,22 +2,30 @@ module Docs
|
|
|
|
class React
|
|
|
|
class React
|
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
|
def get_name
|
|
|
|
def get_name
|
|
|
|
at_css('article h1').content
|
|
|
|
at_css('article h1').content.sub(' (Experimental)', '')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def get_type
|
|
|
|
def get_type
|
|
|
|
|
|
|
|
return 'API Reference' if slug == 'legacy-context'
|
|
|
|
|
|
|
|
return 'Glossary' if slug == 'glossary'
|
|
|
|
link = css("nav a[href='#{result[:path].split('/').last}']").last
|
|
|
|
link = css("nav a[href='#{result[:path].split('/').last}']").last
|
|
|
|
return 'Miscellaneous' unless link
|
|
|
|
return 'Miscellaneous' unless link
|
|
|
|
type = link.ancestors('ul').last.previous_element.content
|
|
|
|
type = link.ancestors('ul').last.previous_element.content
|
|
|
|
type.remove! %r{\s*\(.*\)}
|
|
|
|
type.remove! %r{\s*\(.*\)}
|
|
|
|
|
|
|
|
if type == 'Concurrent Mode'
|
|
|
|
|
|
|
|
type + ' (Experimental)' # TODO: Remove when CM is stable
|
|
|
|
|
|
|
|
else
|
|
|
|
type
|
|
|
|
type
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def additional_entries
|
|
|
|
def additional_entries
|
|
|
|
entries = []
|
|
|
|
entries = []
|
|
|
|
|
|
|
|
|
|
|
|
css('article h3 code, article h4 code').each do |node|
|
|
|
|
is_glossary = slug == 'glossary'
|
|
|
|
next if node.previous.try(:content).present?
|
|
|
|
css(is_glossary ? 'article h2, article h3' : 'article h3 code, article h4 code').each do |node|
|
|
|
|
|
|
|
|
next if !is_glossary && node.previous.try(:content).present?
|
|
|
|
|
|
|
|
next if slug == 'testing-recipes'
|
|
|
|
name = node.content.strip
|
|
|
|
name = node.content.strip
|
|
|
|
# name.remove! %r{[#\(\)]}
|
|
|
|
# name.remove! %r{[#\(\)]}
|
|
|
|
# name.remove! %r{\w+\:}
|
|
|
|
# name.remove! %r{\w+\:}
|
|
|
@ -29,10 +37,14 @@ module Docs
|
|
|
|
'Reference: React'
|
|
|
|
'Reference: React'
|
|
|
|
elsif slug == 'hooks-reference'
|
|
|
|
elsif slug == 'hooks-reference'
|
|
|
|
'Hooks'
|
|
|
|
'Hooks'
|
|
|
|
|
|
|
|
elsif slug == 'test-utils'
|
|
|
|
|
|
|
|
'Reference: Test Utilities'
|
|
|
|
|
|
|
|
elsif slug == 'glossary'
|
|
|
|
|
|
|
|
'Glossary'
|
|
|
|
else
|
|
|
|
else
|
|
|
|
'Reference'
|
|
|
|
'Reference'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
entries << [name, node.parent['id'], type]
|
|
|
|
entries << [name, node['id'] || node.ancestors('[id]').first['id'], type]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
entries
|
|
|
|
entries
|
|
|
|