Update Jest documentation (27.0.4)

pull/1569/head
Enoc 4 years ago
parent 03c4c68ee5
commit de58a6366a

@ -408,7 +408,7 @@ credits = [
'https://raw.githubusercontent.com/jekyll/jekyll/master/LICENSE'
], [
'Jest',
'2020 Facebook, Inc.',
'2021 Facebook, Inc.',
'MIT',
'https://raw.githubusercontent.com/facebook/jest/master/LICENSE'
], [

@ -2,24 +2,33 @@ module Docs
class Jest
class CleanHtmlFilter < Filter
def call
@doc = at_css('.mainContainer .post')
@doc = at_css('article')
at_css('h1').content = 'Jest' if root_page?
at_css('h1').content = 'Jest Documentation' if root_page?
css('.edit-page-link', '.hash-link', 'hr').remove
css('.postHeader', 'article', 'div:not([class])').each do |node|
node.before(node.children).remove
end
css('hr', '.hash-link', 'button', '.badge').remove
css('.anchor').each do |node|
node.parent['id'] = node['id']
node.remove
end
css('pre').each do |node|
css('.prism-code').each do |node|
node.name = 'pre'
node['data-language'] = 'js'
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
counter = 0
node.css('.token-line').each do |subnode| # add newline each line of the code snippets
if counter == 0
else
subnode.content = "\n#{subnode.content}"
end
counter += 1
end
node.content = node.content
end

@ -2,28 +2,35 @@ module Docs
class Jest
class EntriesFilter < Docs::EntriesFilter
def get_name
at_css('.mainContainer h1').content
at_css('h1').content
end
def get_type
type = at_css('.navListItemActive').ancestors('.navGroup').first.at_css('h3').content
type = at_css('.menu__link--sublist.menu__link--active') # active sidebar element
if type.nil?
type = 'API Reference'
else
type = type.content
end
if type == 'Introduction'
'Guides: Introduction'
elsif type == 'API Reference'
self.name
name
else
type
end
end
def additional_entries
return [] unless !root_page? && self.type == self.name # api page
return [] if self.slug == 'environment-variables'
return [] unless !root_page? && type == name # api page
return [] if slug == 'environment-variables'
return [] if slug == 'code-transformation'
entries = []
at_css('.mainContainer h2 + ul, ul.toc-headings').css('li > a').each do |node|
css('h3').each do |node|
code = node.at_css('code')
next if code.nil?
@ -32,7 +39,7 @@ module Docs
name.remove! %r{[\s=<].*}
name.prepend 'jest ' if name.start_with?('--')
name.prepend 'Config: ' if slug == 'configuration'
id = node['href'].remove('#')
id = node.at_css('.anchor')['id']
entries << [name, id]
end

@ -1,8 +1,14 @@
module Docs
class Jest < UrlScraper
include MultipleBaseUrls
self.type = 'simple'
self.release = '26.6'
self.base_url = 'https://jestjs.io/docs/en/'
self.release = '27.0.4'
self.base_urls = [
'https://jestjs.io/docs/',
'https://jestjs.io/docs/expect'
]
self.root_path = 'getting-started'
self.links = {
home: 'https://jestjs.io/',
@ -11,10 +17,12 @@ module Docs
html_filters.push 'jest/entries', 'jest/clean_html'
options[:container] = '.docMainWrapper'
options[:skip_patterns] = [
/\d*.x/ # avoid deprecated versions
]
options[:attribution] = <<-HTML
&copy; 2020 Facebook, Inc.<br>
&copy; 2021 Facebook, Inc.<br>
Licensed under the MIT License.
HTML

Loading…
Cancel
Save