[devdocsgjs/main: 1713/1867] Update Jest documentation (27.0.4)




commit de58a6366a78d7cc0060ba13c280698d0f1dfbba
Author: Enoc <brianhernandez222 hotmail com>
Date:   Thu Jun 10 00:59:01 2021 -0600

    Update Jest documentation (27.0.4)

 .../javascripts/templates/pages/about_tmpl.coffee  |  2 +-
 lib/docs/filters/jest/clean_html.rb                | 25 +++++++++++++++-------
 lib/docs/filters/jest/entries.rb                   | 21 ++++++++++++------
 lib/docs/scrapers/jest.rb                          | 16 ++++++++++----
 4 files changed, 44 insertions(+), 20 deletions(-)
---
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
-      &copy; 2020 Facebook, Inc.<br>
+      &copy; 2021 Facebook, Inc.<br>
       Licensed under the MIT License.
     HTML
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]