Unified · Split
| @@ -2,58 +2,42 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Relay |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − @doc = at_css('.inner-content, article.withtoc') | |
| 6 | 5 | |
| 7 | − if root_page? | |
| 8 | − at_css('h1').content = 'Relay Documentation' | |
| 9 | − end | |
| 6 | + if slug == 'index' | |
| 7 | + css('img').remove | |
| 10 | 8 | |
| 11 | − css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 'a.show', 'a.hide', 'hr').remove | |
| 9 | + css('.projectTitle').each do |node| | |
| 10 | + node.name = 'h1' | |
| 11 | + node.content = 'Relay' | |
| 12 | + end | |
| 12 | 13 | |
| 13 | − css('table h1', 'table h2', 'table h3').each do |node| | |
| 14 | − table = node | |
| 15 | − table = table.parent until table.name == 'table' | |
| 16 | − table.replace(node) | |
| 17 | − end | |
| 14 | + css('pre').remove | |
| 18 | 15 | |
| 19 | − css('a.anchor', 'a.hashref').each do |node| | |
| 20 | − node.parent['id'] ||= node['name'] || node['id'] | |
| 21 | 16 | end |
| 22 | 17 | |
| 23 | − css('.highlight').each do |node| | |
| 24 | − node.name = 'pre' | |
| 25 | − node.css('.gutter').remove | |
| 26 | − node['data-language'] = node.at_css('[data-lang]').try(:[], 'data-lang') || 'js' | |
| 27 | − node.content = node.content.strip | |
| 28 | − end | |
| 18 | + css('.docLastUpdate').remove | |
| 29 | 19 | |
| 30 | − css('table.highlighttable').each do |node| | |
| 31 | − node.replace(node.at_css('pre.highlight')) | |
| 32 | − end | |
| 20 | + css('.docs-prevnext').remove | |
| 33 | 21 | |
| 34 | − css('.prism').each do |node| | |
| 35 | − node.name = 'pre' | |
| 36 | − node['data-language'] = node['class'][/(?<=language\-)(\w+)/] | |
| 37 | − node.content = node.content | |
| 38 | − end | |
| 22 | + css('.edit-page-link').remove | |
| 39 | 23 | |
| 40 | − css('blockquote > p:first-child').each do |node| | |
| 41 | − node.remove if node.content.strip == 'Note:' | |
| 24 | + css('h2, h3').each do |node| | |
| 25 | + node.css('a').remove | |
| 26 | + node['id'] = node.content.gsub(/\s/, '-').downcase | |
| 42 | 27 | end |
| 43 | 28 | |
| 44 | − css('h3#props', 'h3#methods').each { |node| node.name = 'h2' } | |
| 45 | − css('h4.propTitle').each { |node| node.name = 'h3' } | |
| 29 | + css('.onPageNav').remove | |
| 46 | 30 | |
| 47 | − css('> div > div', '> div', 'div > span', '.props', '.prop').each do |node| | |
| 48 | − node.before(node.children).remove | |
| 49 | − end | |
| 31 | + css('#docsNav').remove | |
| 50 | 32 | |
| 51 | − css('a pre', 'h3 .propType').each do |node| | |
| 52 | − node.name = 'code' | |
| 53 | − end | |
| 33 | + css('.fixedHeaderContainer').remove | |
| 34 | + | |
| 35 | + css('footer').remove | |
| 54 | 36 | |
| 55 | − css('a[target]').each do |node| | |
| 56 | − node.remove_attribute('target') | |
| 37 | + # syntax highlight | |
| 38 | + css('pre').each do |node| | |
| 39 | + node['data-language'] = 'javascript' | |
| 40 | + node.add_class('highlight') | |
| 57 | 41 | end |
| 58 | 42 | |
| 59 | 43 | doc |
| @@ -1,43 +1,53 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Relay |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | + | |
| 4 | 5 | def get_name |
| 5 | − at_css('h1').children.select(&:text?).map(&:content).join.strip | |
| 6 | + if slug == 'index' | |
| 7 | + return 'Relay' | |
| 8 | + end | |
| 9 | + | |
| 10 | + at_css('h1').content | |
| 6 | 11 | end |
| 7 | 12 | |
| 8 | 13 | def get_type |
| 9 | − link = at_css('.nav-docs-section .active, .toc .active') | |
| 10 | − section = link.ancestors('.nav-docs-section, section').first | |
| 11 | − type = section.at_css('h3').content.strip | |
| 12 | − type | |
| 14 | + if slug == 'index' | |
| 15 | + return 'Relay' | |
| 16 | + end | |
| 17 | + | |
| 18 | + at_css('h1').content | |
| 13 | 19 | end |
| 14 | 20 | |
| 15 | 21 | def additional_entries |
| 16 | 22 | entries = [] |
| 17 | 23 | |
| 18 | − css('.inner-content h3 code, .inner-content h4 code').each do |node| | |
| 19 | − name = node.content | |
| 20 | − name.remove! %r{[#\(\)]} | |
| 21 | − name.remove! %r{\w+\:} | |
| 22 | − name.strip! | |
| 23 | − id = name.parameterize | |
| 24 | − node.parent['id'] = id | |
| 25 | − entries << [name, id, 'Reference'] | |
| 24 | + if slug == 'index' | |
| 25 | + return entries | |
| 26 | 26 | end |
| 27 | 27 | |
| 28 | − css('.apiIndex a pre').each do |node| | |
| 29 | − next unless node.parent['href'].start_with?('#') | |
| 30 | − id = node.parent['href'].remove('#') | |
| 31 | − name = node.content.strip | |
| 32 | − sep = name.start_with?('static') ? '.' : '#' | |
| 33 | − name.remove! %r{(abstract|static) } | |
| 34 | − name.sub! %r{\(.*\)}, '()' | |
| 35 | − name.prepend(self.name + sep) | |
| 36 | − entries << [name, id] | |
| 28 | + ## avoid adding non-desired entries removing tags | |
| 29 | + # remove header which contains a <h2> tag | |
| 30 | + css('.fixedHeaderContainer').remove | |
| 31 | + | |
| 32 | + # remove table of content whose title is an <h2> tag | |
| 33 | + css('.toc').remove | |
| 34 | + ## | |
| 35 | + | |
| 36 | + css('h2, h3').each do |node| | |
| 37 | + next if node.content.include?('Argument') | |
| 38 | + entry_name = node.content | |
| 39 | + | |
| 40 | + if entry_name.include?('(') | |
| 41 | + entry_name = entry_name.match(/.*\(/)[0] + ')' | |
| 42 | + end | |
| 43 | + | |
| 44 | + entry_id = node.content.gsub(/\s/, '-').downcase | |
| 45 | + entries << [entry_name, entry_id] | |
| 37 | 46 | end |
| 38 | 47 | |
| 39 | 48 | entries |
| 40 | 49 | end |
| 50 | + | |
| 41 | 51 | end |
| 42 | 52 | end |
| 43 | 53 | end |
| @@ -1,27 +1,38 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Relay < UrlScraper |
| 3 | 3 | self.type = 'simple' |
| 4 | − self.release = '1.4.1' | |
| 5 | − self.base_url = 'https://facebook.github.io/relay/docs/' | |
| 6 | − self.root_path = 'getting-started.html' | |
| 4 | + self.release = '10.1.0' | |
| 5 | + self.base_url = 'https://relay.dev' | |
| 6 | + self.root_path = 'index.html' | |
| 7 | 7 | self.links = { |
| 8 | − home: 'https://facebook.github.io/relay/', | |
| 8 | + home: 'https://relay.dev/', | |
| 9 | 9 | code: 'https://github.com/facebook/relay' |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | html_filters.push 'relay/entries', 'relay/clean_html' |
| 13 | 13 | |
| 14 | − options[:container] = '.documentationContent' | |
| 15 | − options[:skip] = %w(videos.html graphql-further-reading.html) | |
| 14 | + options[:only] = [ | |
| 15 | + '/docs/en/graphql-in-relay', | |
| 16 | + '/docs/en//relay-environment', | |
| 17 | + '/docs/en/network-layer', | |
| 18 | + '/docs/en/query-renderer', | |
| 19 | + '/docs/en/fragment-container', | |
| 20 | + '/docs/en/refetch-container', | |
| 21 | + '/docs/en/pagination-container', | |
| 22 | + '/docs/en/mutations', | |
| 23 | + '/docs/en/subscriptions', | |
| 24 | + '/docs/en/relay-store', | |
| 25 | + '/docs/en/fetch-query' | |
| 26 | + ] | |
| 16 | 27 | |
| 17 | 28 | options[:attribution] = <<-HTML |
| 18 | − © 2013–present Facebook Inc.<br> | |
| 29 | + © 2020–present Facebook Inc.<br> | |
| 19 | 30 | Licensed under the BSD License. |
| 20 | 31 | HTML |
| 21 | 32 | |
| 22 | 33 | def get_latest_version(opts) |
| 23 | − doc = fetch_doc('http://facebook.github.io/relay/en/', opts) | |
| 24 | − doc.at_css('header > a > h3').content[1..-1] | |
| 34 | + get_latest_github_release('facebook', 'relay', opts) | |
| 25 | 35 | end |
| 36 | + | |
| 26 | 37 | end |
| 27 | 38 | end |