Unified · Split
| @@ -1,4 +1,4 @@ | ||
| 1 | −/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+d+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+crystal+rust+scss+sql+typescript */ | |
| 1 | +/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+d+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript */ | |
| 2 | 2 | var _self = (typeof window !== 'undefined') |
| 3 | 3 | ? window // if in browser |
| 4 | 4 | : ( |
| @@ -1681,6 +1681,44 @@ Prism.languages.python= { · 1676 unmodified lines | ||
| 1681 | 1681 | 'punctuation' : /[{}[\];(),.:]/ |
| 1682 | 1682 | }; |
| 1683 | 1683 | |
| 1684 | +(function(Prism) { | |
| 1685 | + | |
| 1686 | +var javascript = Prism.util.clone(Prism.languages.javascript); | |
| 1687 | + | |
| 1688 | +Prism.languages.jsx = Prism.languages.extend('markup', javascript); | |
| 1689 | +Prism.languages.jsx.tag.pattern= /<\/?[\w\.:-]+\s*(?:\s+(?:[\w\.:-]+(?:=(?:("|')(\\?[\s\S])*?\1|[^\s'">=]+|(\{[\s\S]*?\})))?|\{\.{3}\w+\}))*\s*\/?>/i; | |
| 1690 | + | |
| 1691 | +Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:('|")[\s\S]*?(\1)|[^\s>]+)/i; | |
| 1692 | + | |
| 1693 | +Prism.languages.insertBefore('inside', 'attr-name', { | |
| 1694 | + 'spread': { | |
| 1695 | + pattern: /\{\.{3}\w+\}/, | |
| 1696 | + inside: { | |
| 1697 | + 'punctuation': /\{|\}|\./, | |
| 1698 | + 'attr-value': /\w+/ | |
| 1699 | + } | |
| 1700 | + } | |
| 1701 | +}, Prism.languages.jsx.tag); | |
| 1702 | + | |
| 1703 | +var jsxExpression = Prism.util.clone(Prism.languages.jsx); | |
| 1704 | + | |
| 1705 | +delete jsxExpression.punctuation | |
| 1706 | + | |
| 1707 | +jsxExpression = Prism.languages.insertBefore('jsx', 'operator', { | |
| 1708 | + 'punctuation': /=(?={)|[{}[\];(),.:]/ | |
| 1709 | +}, { jsx: jsxExpression }); | |
| 1710 | + | |
| 1711 | +Prism.languages.insertBefore('inside', 'attr-value',{ | |
| 1712 | + 'script': { | |
| 1713 | + // Allow for one level of nesting | |
| 1714 | + pattern: /=(\{(?:\{[^}]*\}|[^}])+\})/i, | |
| 1715 | + inside: jsxExpression, | |
| 1716 | + 'alias': 'language-javascript' | |
| 1717 | + } | |
| 1718 | +}, Prism.languages.jsx.tag); | |
| 1719 | + | |
| 1720 | +}(Prism)); | |
| 1721 | + | |
| 1684 | 1722 | (function(Prism) { |
| 1685 | 1723 | Prism.languages.crystal = Prism.languages.extend('ruby', { |
| 1686 | 1724 | keyword: [ |
| @@ -2,59 +2,27 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class React |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − @doc = at_css('.inner-content, article.withtoc') | |
| 5 | + @doc = at_css('article') | |
| 6 | 6 | |
| 7 | 7 | if root_page? |
| 8 | − at_css('h1').content = context[:root_title] | |
| 8 | + at_css('h1').content = 'React Documentation' | |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | − css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 'a.show', 'a.hide', 'hr').remove | |
| 12 | − | |
| 13 | − css('table h1', 'table h2', 'table h3').each do |node| | |
| 14 | − table = node | |
| 15 | − table = table.parent until table.name == 'table' | |
| 16 | − table.replace(node) | |
| 17 | − end | |
| 18 | − | |
| 19 | − css('a.anchor', 'a.hashref').each do |node| | |
| 20 | − node.parent['id'] ||= node['name'] || node['id'] | |
| 21 | − end | |
| 22 | − | |
| 23 | − css('.highlight').each do |node| | |
| 24 | − node.name = 'pre' | |
| 25 | − node.css('.gutter').remove | |
| 26 | − node['data-language'] = node.at_css('[data-lang]').try(:[], 'data-lang') || 'js' | |
| 27 | − node.content = node.content.strip | |
| 28 | − end | |
| 29 | − | |
| 30 | − css('table.highlighttable').each do |node| | |
| 31 | − node.replace(node.at_css('pre.highlight')) | |
| 11 | + css('header', 'div[class^="css-"]', '.gatsby-resp-image-link span').each do |node| | |
| 12 | + node.before(node.children).remove | |
| 32 | 13 | end |
| 33 | 14 | |
| 34 | − css('.prism').each do |node| | |
| 35 | − node.name = 'pre' | |
| 36 | − node['data-language'] = node['class'][/(?<=language\-)(\w+)/] | |
| 15 | + css('.gatsby-highlight > pre').each do |node| | |
| 37 | 16 | node.content = node.content |
| 17 | + node['data-language'] = node['class'][/(?<=gatsby\-code\-)(\w+)/] | |
| 18 | + node.remove_attribute('class') | |
| 19 | + node.parent.replace(node) | |
| 38 | 20 | end |
| 39 | 21 | |
| 40 | − css('blockquote > p:first-child').each do |node| | |
| 41 | − node.remove if node.content.strip == 'Note:' | |
| 42 | − end | |
| 43 | − | |
| 44 | − css('h3#props', 'h3#methods').each { |node| node.name = 'h2' } | |
| 45 | − css('h4.propTitle').each { |node| node.name = 'h3' } | |
| 46 | − | |
| 47 | − css('> div > div', '> div', 'div > span', '.props', '.prop').each do |node| | |
| 48 | − node.before(node.children).remove | |
| 49 | − end | |
| 50 | − | |
| 51 | − css('a pre', 'h3 .propType').each do |node| | |
| 52 | − node.name = 'code' | |
| 53 | − end | |
| 22 | + css('a.anchor', 'a:contains("Edit this page")', 'hr').remove | |
| 54 | 23 | |
| 55 | − css('a[target]').each do |node| | |
| 56 | − node.remove_attribute('target') | |
| 57 | − end | |
| 24 | + css('a').remove_attr('rel').remove_attr('target').remove_attr('class').remove_attr('style') | |
| 25 | + css('img').remove_attr('style').remove_attr('srcset').remove_attr('sizes').remove_attr('class') | |
| 58 | 26 | |
| 59 | 27 | doc |
| 60 | 28 | end |
| @@ -2,28 +2,24 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class React |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | − at_css('h1').children.select(&:text?).map(&:content).join.strip | |
| 5 | + at_css('article h1').content | |
| 6 | 6 | end |
| 7 | 7 | |
| 8 | 8 | def get_type |
| 9 | − link = at_css('.nav-docs-section .active, .toc .active') | |
| 10 | − return 'Miscellaneous' unless link | |
| 11 | − section = link.ancestors('.nav-docs-section, section').first | |
| 12 | − type = section.at_css('h3').content.strip | |
| 13 | − type | |
| 9 | + link = at_css("nav a[href='#{result[:path].split('/').last}']") | |
| 10 | + link.ancestors('ul').last.previous_element.content | |
| 14 | 11 | end |
| 15 | 12 | |
| 16 | 13 | def additional_entries |
| 17 | 14 | entries = [] |
| 18 | 15 | |
| 19 | − css('.inner-content h3 code, .inner-content h4 code').each do |node| | |
| 20 | − name = node.content | |
| 21 | − name.remove! %r{[#\(\)]} | |
| 22 | − name.remove! %r{\w+\:} | |
| 23 | − name.strip! | |
| 24 | − name = 'createFragmentobject' if name.include?('createFragmentobject') | |
| 25 | − id = name.parameterize | |
| 26 | − node.parent['id'] = id | |
| 16 | + css('article h3 code, article h4 code').each do |node| | |
| 17 | + next if node.previous.try(:content).present? | |
| 18 | + name = node.content.strip | |
| 19 | + # name.remove! %r{[#\(\)]} | |
| 20 | + # name.remove! %r{\w+\:} | |
| 21 | + # name.strip! | |
| 22 | + # name = 'createFragmentobject' if name.include?('createFragmentobject') | |
| 27 | 23 | type = if slug == 'react-component' |
| 28 | 24 | 'Reference: Component' |
| 29 | 25 | elsif slug == 'react-api' |
| @@ -31,18 +27,7 @@ module Docs · 1 unmodified line | ||
| 31 | 27 | else |
| 32 | 28 | 'Reference' |
| 33 | 29 | end |
| 34 | − entries << [name, id, type] | |
| 35 | − end | |
| 36 | − | |
| 37 | − css('.apiIndex a pre').each do |node| # relay | |
| 38 | − next unless node.parent['href'].start_with?('#') | |
| 39 | − id = node.parent['href'].remove('#') | |
| 40 | − name = node.content.strip | |
| 41 | − sep = name.start_with?('static') ? '.' : '#' | |
| 42 | − name.remove! %r{(abstract|static) } | |
| 43 | − name.sub! %r{\(.*\)}, '()' | |
| 44 | − name.prepend(self.name + sep) | |
| 45 | − entries << [name, id] | |
| 30 | + entries << [name, node.parent['id'], type] | |
| 46 | 31 | end |
| 47 | 32 | |
| 48 | 33 | entries |
| @@ -1,29 +1,29 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class React < UrlScraper |
| 3 | 3 | self.name = 'React' |
| 4 | − self.type = 'react' | |
| 5 | − self.release = '15.6.1' | |
| 6 | − self.base_url = 'https://facebook.github.io/react/docs/' | |
| 4 | + self.type = 'simple' | |
| 5 | + self.release = '16.0.0' | |
| 6 | + self.base_url = 'https://reactjs.org/docs/' | |
| 7 | 7 | self.root_path = 'hello-world.html' |
| 8 | 8 | self.links = { |
| 9 | − home: 'https://facebook.github.io/react/', | |
| 9 | + home: 'https://reactjs.org/', | |
| 10 | 10 | code: 'https://github.com/facebook/react' |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | html_filters.push 'react/entries', 'react/clean_html' |
| 14 | 14 | |
| 15 | − options[:root_title] = 'React Documentation' | |
| 16 | − options[:container] = '.documentationContent' | |
| 15 | + options[:skip] = %w( | |
| 16 | + codebase-overview.html | |
| 17 | + design-principles.html | |
| 18 | + how-to-contribute.html | |
| 19 | + implementation-notes.html | |
| 20 | + ) | |
| 17 | 21 | |
| 18 | 22 | options[:replace_paths] = { |
| 19 | − 'top-level-api.html' => 'react-api.html', | |
| 20 | − 'working-with-the-browser.html' => 'refs-and-the-dom.html', | |
| 21 | − 'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html', | |
| 22 | 23 | 'more-about-refs.html' => 'refs-and-the-dom.html', |
| 23 | − 'advanced-performance.html' => 'optimizing-performance.html', | |
| 24 | − 'component-api.html' => 'react-component.html', | |
| 25 | − 'component-specs.html' => 'react-component.html', | |
| 26 | − 'multiple-components.html' => 'composition-vs-inheritance.html', | |
| 24 | + 'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html', | |
| 25 | + 'working-with-the-browser.html' => 'refs-and-the-dom.html', | |
| 26 | + 'top-level-api.html' => 'react-api.html', | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | options[:attribution] = <<-HTML |