diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee
index fc256fd9..81a3cdfc 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -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'
], [
diff --git a/lib/docs/filters/jest/clean_html.rb b/lib/docs/filters/jest/clean_html.rb
index d1ced3f3..082fdb30 100644
--- a/lib/docs/filters/jest/clean_html.rb
+++ b/lib/docs/filters/jest/clean_html.rb
@@ -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
diff --git a/lib/docs/filters/jest/entries.rb b/lib/docs/filters/jest/entries.rb
index 82c346f9..368d8ffd 100644
--- a/lib/docs/filters/jest/entries.rb
+++ b/lib/docs/filters/jest/entries.rb
@@ -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
diff --git a/lib/docs/scrapers/jest.rb b/lib/docs/scrapers/jest.rb
index 50fb3397..879cec8b 100644
--- a/lib/docs/scrapers/jest.rb
+++ b/lib/docs/scrapers/jest.rb
@@ -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
- © 2020 Facebook, Inc.
+ © 2021 Facebook, Inc.
Licensed under the MIT License.
HTML