Unified · Split
| @@ -408,7 +408,7 @@ credits = [ · 407 unmodified lines | ||
| 408 | 408 | 'https://raw.githubusercontent.com/jekyll/jekyll/master/LICENSE' |
| 409 | 409 | ], [ |
| 410 | 410 | 'Jest', |
| 411 | − '2020 Facebook, Inc.', | |
| 411 | + '2021 Facebook, Inc.', | |
| 412 | 412 | 'MIT', |
| 413 | 413 | 'https://raw.githubusercontent.com/facebook/jest/master/LICENSE' |
| 414 | 414 | ], [ |
| @@ -2,24 +2,33 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Jest |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − @doc = at_css('.mainContainer .post') | |
| 5 | + @doc = at_css('article') | |
| 6 | 6 | |
| 7 | − at_css('h1').content = 'Jest' if root_page? | |
| 7 | + at_css('h1').content = 'Jest Documentation' if root_page? | |
| 8 | 8 | |
| 9 | − css('.edit-page-link', '.hash-link', 'hr').remove | |
| 10 | − | |
| 11 | − css('.postHeader', 'article', 'div:not([class])').each do |node| | |
| 12 | − node.before(node.children).remove | |
| 13 | − end | |
| 9 | + css('hr', '.hash-link', 'button', '.badge').remove | |
| 14 | 10 | |
| 15 | 11 | css('.anchor').each do |node| |
| 16 | 12 | node.parent['id'] = node['id'] |
| 17 | 13 | node.remove |
| 18 | 14 | end |
| 19 | 15 | |
| 20 | − css('pre').each do |node| | |
| 16 | + css('.prism-code').each do |node| | |
| 17 | + node.name = 'pre' | |
| 21 | 18 | node['data-language'] = 'js' |
| 22 | 19 | node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] |
| 20 | + | |
| 21 | + counter = 0 | |
| 22 | + | |
| 23 | + node.css('.token-line').each do |subnode| # add newline each line of the code snippets | |
| 24 | + if counter == 0 | |
| 25 | + else | |
| 26 | + subnode.content = "\n#{subnode.content}" | |
| 27 | + end | |
| 28 | + | |
| 29 | + counter += 1 | |
| 30 | + end | |
| 31 | + | |
| 23 | 32 | node.content = node.content |
| 24 | 33 | end |
| 25 | 34 | |
| @@ -2,28 +2,35 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Jest |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | − at_css('.mainContainer h1').content | |
| 5 | + at_css('h1').content | |
| 6 | 6 | end |
| 7 | 7 | |
| 8 | 8 | def get_type |
| 9 | − type = at_css('.navListItemActive').ancestors('.navGroup').first.at_css('h3').content | |
| 9 | + type = at_css('.menu__link--sublist.menu__link--active') # active sidebar element | |
| 10 | + | |
| 11 | + if type.nil? | |
| 12 | + type = 'API Reference' | |
| 13 | + else | |
| 14 | + type = type.content | |
| 15 | + end | |
| 10 | 16 | |
| 11 | 17 | if type == 'Introduction' |
| 12 | 18 | 'Guides: Introduction' |
| 13 | 19 | elsif type == 'API Reference' |
| 14 | − self.name | |
| 20 | + name | |
| 15 | 21 | else |
| 16 | 22 | type |
| 17 | 23 | end |
| 18 | 24 | end |
| 19 | 25 | |
| 20 | 26 | def additional_entries |
| 21 | − return [] unless !root_page? && self.type == self.name # api page | |
| 22 | − return [] if self.slug == 'environment-variables' | |
| 27 | + return [] unless !root_page? && type == name # api page | |
| 28 | + return [] if slug == 'environment-variables' | |
| 29 | + return [] if slug == 'code-transformation' | |
| 23 | 30 | |
| 24 | 31 | entries = [] |
| 25 | 32 | |
| 26 | − at_css('.mainContainer h2 + ul, ul.toc-headings').css('li > a').each do |node| | |
| 33 | + css('h3').each do |node| | |
| 27 | 34 | code = node.at_css('code') |
| 28 | 35 | next if code.nil? |
| 29 | 36 | |
| @@ -32,7 +39,7 @@ module Docs · 2 unmodified lines | ||
| 32 | 39 | name.remove! %r{[\s=<].*} |
| 33 | 40 | name.prepend 'jest ' if name.start_with?('--') |
| 34 | 41 | name.prepend 'Config: ' if slug == 'configuration' |
| 35 | − id = node['href'].remove('#') | |
| 42 | + id = node.at_css('.anchor')['id'] | |
| 36 | 43 | |
| 37 | 44 | entries << [name, id] |
| 38 | 45 | end |
| @@ -1,8 +1,14 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Jest < UrlScraper |
| 3 | + include MultipleBaseUrls | |
| 3 | 4 | self.type = 'simple' |
| 4 | − self.release = '26.6' | |
| 5 | − self.base_url = 'https://jestjs.io/docs/en/' | |
| 5 | + self.release = '27.0.4' | |
| 6 | + | |
| 7 | + self.base_urls = [ | |
| 8 | + 'https://jestjs.io/docs/', | |
| 9 | + 'https://jestjs.io/docs/expect' | |
| 10 | + ] | |
| 11 | + | |
| 6 | 12 | self.root_path = 'getting-started' |
| 7 | 13 | self.links = { |
| 8 | 14 | home: 'https://jestjs.io/', |
| @@ -11,10 +17,12 @@ module Docs · 2 unmodified lines | ||
| 11 | 17 | |
| 12 | 18 | html_filters.push 'jest/entries', 'jest/clean_html' |
| 13 | 19 | |
| 14 | − options[:container] = '.docMainWrapper' | |
| 20 | + options[:skip_patterns] = [ | |
| 21 | + /\d*.x/ # avoid deprecated versions | |
| 22 | + ] | |
| 15 | 23 | |
| 16 | 24 | options[:attribution] = <<-HTML |
| 17 | − © 2020 Facebook, Inc.<br> | |
| 25 | + © 2021 Facebook, Inc.<br> | |
| 18 | 26 | Licensed under the MIT License. |
| 19 | 27 | HTML |
| 20 | 28 | |