mirror of https://github.com/freeCodeCamp/devdocs
commit
c93270d8ef
@ -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
|
||||||
© 2013–present Facebook Inc.<br>
|
© 2020–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…
Reference in new issue