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