mirror of https://github.com/freeCodeCamp/devdocs
commit
c93270d8ef
@ -1,43 +1,53 @@
|
||||
module Docs
|
||||
class Relay
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
|
||||
def get_name
|
||||
at_css('h1').children.select(&:text?).map(&:content).join.strip
|
||||
if slug == 'index'
|
||||
return 'Relay'
|
||||
end
|
||||
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
link = at_css('.nav-docs-section .active, .toc .active')
|
||||
section = link.ancestors('.nav-docs-section, section').first
|
||||
type = section.at_css('h3').content.strip
|
||||
type
|
||||
if slug == 'index'
|
||||
return 'Relay'
|
||||
end
|
||||
|
||||
at_css('h1').content
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
css('.inner-content h3 code, .inner-content h4 code').each do |node|
|
||||
name = node.content
|
||||
name.remove! %r{[#\(\)]}
|
||||
name.remove! %r{\w+\:}
|
||||
name.strip!
|
||||
id = name.parameterize
|
||||
node.parent['id'] = id
|
||||
entries << [name, id, 'Reference']
|
||||
if slug == 'index'
|
||||
return entries
|
||||
end
|
||||
|
||||
css('.apiIndex a pre').each do |node|
|
||||
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]
|
||||
## avoid adding non-desired entries removing tags
|
||||
# remove header which contains a <h2> tag
|
||||
css('.fixedHeaderContainer').remove
|
||||
|
||||
# remove table of content whose title is an <h2> tag
|
||||
css('.toc').remove
|
||||
##
|
||||
|
||||
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
|
||||
|
||||
entries
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,27 +1,38 @@
|
||||
module Docs
|
||||
class Relay < UrlScraper
|
||||
self.type = 'simple'
|
||||
self.release = '1.4.1'
|
||||
self.base_url = 'https://facebook.github.io/relay/docs/'
|
||||
self.root_path = 'getting-started.html'
|
||||
self.release = '10.1.0'
|
||||
self.base_url = 'https://relay.dev'
|
||||
self.root_path = 'index.html'
|
||||
self.links = {
|
||||
home: 'https://facebook.github.io/relay/',
|
||||
home: 'https://relay.dev/',
|
||||
code: 'https://github.com/facebook/relay'
|
||||
}
|
||||
|
||||
html_filters.push 'relay/entries', 'relay/clean_html'
|
||||
|
||||
options[:container] = '.documentationContent'
|
||||
options[:skip] = %w(videos.html graphql-further-reading.html)
|
||||
options[:only] = [
|
||||
'/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
|
||||
© 2013–present Facebook Inc.<br>
|
||||
© 2020–present Facebook Inc.<br>
|
||||
Licensed under the BSD License.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
doc = fetch_doc('http://facebook.github.io/relay/en/', opts)
|
||||
doc.at_css('header > a > h3').content[1..-1]
|
||||
get_latest_github_release('facebook', 'relay', opts)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in new issue