Merge pull request #1399 from MasterEnoc/relay

Update Relay to 10.1.0
pull/1402/head
Simon Legner 4 years ago committed by GitHub
commit c93270d8ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,58 +2,42 @@ module Docs
class Relay class Relay
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
@doc = at_css('.inner-content, article.withtoc')
if root_page? if slug == 'index'
at_css('h1').content = 'Relay Documentation' css('img').remove
end
css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 'a.show', 'a.hide', 'hr').remove css('.projectTitle').each do |node|
node.name = 'h1'
node.content = 'Relay'
end
css('table h1', 'table h2', 'table h3').each do |node| css('pre').remove
table = node
table = table.parent until table.name == 'table'
table.replace(node)
end
css('a.anchor', 'a.hashref').each do |node|
node.parent['id'] ||= node['name'] || node['id']
end end
css('.highlight').each do |node| css('.docLastUpdate').remove
node.name = 'pre'
node.css('.gutter').remove
node['data-language'] = node.at_css('[data-lang]').try(:[], 'data-lang') || 'js'
node.content = node.content.strip
end
css('table.highlighttable').each do |node| css('.docs-prevnext').remove
node.replace(node.at_css('pre.highlight'))
end
css('.prism').each do |node| css('.edit-page-link').remove
node.name = 'pre'
node['data-language'] = node['class'][/(?<=language\-)(\w+)/]
node.content = node.content
end
css('blockquote > p:first-child').each do |node| css('h2, h3').each do |node|
node.remove if node.content.strip == 'Note:' node.css('a').remove
node['id'] = node.content.gsub(/\s/, '-').downcase
end end
css('h3#props', 'h3#methods').each { |node| node.name = 'h2' } css('.onPageNav').remove
css('h4.propTitle').each { |node| node.name = 'h3' }
css('> div > div', '> div', 'div > span', '.props', '.prop').each do |node| css('#docsNav').remove
node.before(node.children).remove
end
css('a pre', 'h3 .propType').each do |node| css('.fixedHeaderContainer').remove
node.name = 'code'
end css('footer').remove
css('a[target]').each do |node| # syntax highlight
node.remove_attribute('target') css('pre').each do |node|
node['data-language'] = 'javascript'
node.add_class('highlight')
end end
doc doc

@ -1,43 +1,53 @@
module Docs module Docs
class Relay class Relay
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
at_css('h1').children.select(&:text?).map(&:content).join.strip if slug == 'index'
return 'Relay'
end
at_css('h1').content
end end
def get_type def get_type
link = at_css('.nav-docs-section .active, .toc .active') if slug == 'index'
section = link.ancestors('.nav-docs-section, section').first return 'Relay'
type = section.at_css('h3').content.strip end
type
at_css('h1').content
end end
def additional_entries def additional_entries
entries = [] entries = []
css('.inner-content h3 code, .inner-content h4 code').each do |node| if slug == 'index'
name = node.content return entries
name.remove! %r{[#\(\)]}
name.remove! %r{\w+\:}
name.strip!
id = name.parameterize
node.parent['id'] = id
entries << [name, id, 'Reference']
end end
css('.apiIndex a pre').each do |node| ## avoid adding non-desired entries removing tags
next unless node.parent['href'].start_with?('#') # remove header which contains a <h2> tag
id = node.parent['href'].remove('#') css('.fixedHeaderContainer').remove
name = node.content.strip
sep = name.start_with?('static') ? '.' : '#' # remove table of content whose title is an <h2> tag
name.remove! %r{(abstract|static) } css('.toc').remove
name.sub! %r{\(.*\)}, '()' ##
name.prepend(self.name + sep)
entries << [name, id] css('h2, h3').each do |node|
next if node.content.include?('Argument')
entry_name = node.content
if entry_name.include?('(')
entry_name = entry_name.match(/.*\(/)[0] + ')'
end
entry_id = node.content.gsub(/\s/, '-').downcase
entries << [entry_name, entry_id]
end end
entries entries
end end
end end
end end
end end

@ -1,27 +1,38 @@
module Docs module Docs
class Relay < UrlScraper class Relay < UrlScraper
self.type = 'simple' self.type = 'simple'
self.release = '1.4.1' self.release = '10.1.0'
self.base_url = 'https://facebook.github.io/relay/docs/' self.base_url = 'https://relay.dev'
self.root_path = 'getting-started.html' self.root_path = 'index.html'
self.links = { self.links = {
home: 'https://facebook.github.io/relay/', home: 'https://relay.dev/',
code: 'https://github.com/facebook/relay' code: 'https://github.com/facebook/relay'
} }
html_filters.push 'relay/entries', 'relay/clean_html' html_filters.push 'relay/entries', 'relay/clean_html'
options[:container] = '.documentationContent' options[:only] = [
options[:skip] = %w(videos.html graphql-further-reading.html) '/docs/en/graphql-in-relay',
'/docs/en//relay-environment',
'/docs/en/network-layer',
'/docs/en/query-renderer',
'/docs/en/fragment-container',
'/docs/en/refetch-container',
'/docs/en/pagination-container',
'/docs/en/mutations',
'/docs/en/subscriptions',
'/docs/en/relay-store',
'/docs/en/fetch-query'
]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2013&ndash;present Facebook Inc.<br> &copy; 2020&ndash;present Facebook Inc.<br>
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(opts) def get_latest_version(opts)
doc = fetch_doc('http://facebook.github.io/relay/en/', opts) get_latest_github_release('facebook', 'relay', opts)
doc.at_css('header > a > h3').content[1..-1]
end end
end end
end end

Loading…
Cancel
Save