Unified · Split
| @@ -842,6 +842,11 @@ credits = [ · 841 unmodified lines | ||
| 842 | 842 | '2004-2017 Fabien Potencier', |
| 843 | 843 | 'MIT', |
| 844 | 844 | 'https://symfony.com/doc/current/contributing/code/license.html' |
| 845 | + ], [ | |
| 846 | + 'TailwindCSS', | |
| 847 | + 'Adam Wathan', | |
| 848 | + 'MIT', | |
| 849 | + 'https://raw.githubusercontent.com/tailwindlabs/tailwindcss/master/LICENSE' | |
| 845 | 850 | ], [ |
| 846 | 851 | 'Tcl/Tk', |
| 847 | 852 | 'The Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties', |
| @@ -0,0 +1,77 @@ | ||
| 1 | +module Docs | |
| 2 | + class Tailwindcss | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + clean_up | |
| 6 | + | |
| 7 | + # Remove code highlighting | |
| 8 | + css('pre').each do |node| | |
| 9 | + node.content = node.content | |
| 10 | + node['data-language'] = 'php' | |
| 11 | + end | |
| 12 | + | |
| 13 | + doc | |
| 14 | + end | |
| 15 | + | |
| 16 | + def clean_up | |
| 17 | + @doc = doc.at_css('#content-wrapper') | |
| 18 | + | |
| 19 | + css('.location').remove | |
| 20 | + | |
| 21 | + # Replace .header with <h1> | |
| 22 | + css('.page-header > h1').each do |node| | |
| 23 | + node.content = 'Tailwind' if root_page? | |
| 24 | + node.parent.before(node).remove | |
| 25 | + end | |
| 26 | + | |
| 27 | + css('.container-fluid').each do |node| | |
| 28 | + node.name = 'table' | |
| 29 | + node.css('.row').each { |n| n.name = 'tr' } | |
| 30 | + node.css('div[class^="col"]').each { |n| n.name = 'td' } | |
| 31 | + end | |
| 32 | + | |
| 33 | + css('> div').each do |node| | |
| 34 | + node.before(node.children).remove | |
| 35 | + end | |
| 36 | + | |
| 37 | + # Remove <abbr> | |
| 38 | + css('a > abbr').each do |node| | |
| 39 | + node.parent['title'] = node['title'] | |
| 40 | + node.before(node.children).remove | |
| 41 | + end | |
| 42 | + | |
| 43 | + # Clean up headings | |
| 44 | + css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node| | |
| 45 | + node.before(node.children).remove | |
| 46 | + end | |
| 47 | + | |
| 48 | + # Remove empty <td> | |
| 49 | + css('td').each do |node| | |
| 50 | + node.remove if node.content =~ /\A\s+\z/ | |
| 51 | + end | |
| 52 | + | |
| 53 | + # @doc = at_css('.docs_body') | |
| 54 | + | |
| 55 | + # Clean up headings | |
| 56 | + css('h2 > a').each do |node| | |
| 57 | + node.before(node.children).remove | |
| 58 | + end | |
| 59 | + | |
| 60 | + css('p > a[name]').each do |node| | |
| 61 | + node.parent.next_element['id'] = node['name'] | |
| 62 | + end | |
| 63 | + | |
| 64 | + css('blockquote').each do |node| | |
| 65 | + node['class'] = 'tip' if node.inner_html.include?('{tip}') | |
| 66 | + node.inner_html = node.inner_html.remove(/\{(tip|note)\}\s?/) | |
| 67 | + end | |
| 68 | + | |
| 69 | + css('blockquote').each do |node| | |
| 70 | + if node.inner_html.include?('You\'re browsing the documentation for an old version of Laravel.') | |
| 71 | + node.remove | |
| 72 | + end | |
| 73 | + end | |
| 74 | + end | |
| 75 | + end | |
| 76 | + end | |
| 77 | +end | |
| @@ -0,0 +1,51 @@ | ||
| 1 | +module Docs | |
| 2 | + class Tailwindcss | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + # def get_name | |
| 5 | + # if api_page? | |
| 6 | + # name = at_css('h1').content.strip.remove('Illuminate\\') | |
| 7 | + # name << " (#{type})" unless name.start_with?(self.type) | |
| 8 | + # name | |
| 9 | + # else | |
| 10 | + # at_css('h1').content | |
| 11 | + # end | |
| 12 | + # end | |
| 13 | + | |
| 14 | + def get_type | |
| 15 | + # /customizing-colors rediects to /colors, hence making css | |
| 16 | + # selector below not to match the href | |
| 17 | + if result[:path] == 'customizing-colors' | |
| 18 | + selector = "#sidebar a[href='#{result[:path]}']" | |
| 19 | + else | |
| 20 | + selector = "#sidebar a[href='#{result[:path]}']" | |
| 21 | + end | |
| 22 | + | |
| 23 | + check = at_css(selector).parent.parent.parent.css('h5').inner_text | |
| 24 | + check | |
| 25 | + end | |
| 26 | + | |
| 27 | + # def additional_entries | |
| 28 | + # return [] if root_page? || !api_page? | |
| 29 | + # base_name = self.name.remove(/\(.+\)/).strip | |
| 30 | + | |
| 31 | + # css('h3[id^="method_"]').each_with_object [] do |node, entries| | |
| 32 | + # next if node.at_css('.location').content.start_with?('in') | |
| 33 | + | |
| 34 | + # name = node['id'].remove('method_') | |
| 35 | + # name.prepend "#{base_name}::" | |
| 36 | + # name << '()' | |
| 37 | + | |
| 38 | + # entries << [name, node['id']] | |
| 39 | + # end | |
| 40 | + # end | |
| 41 | + | |
| 42 | + # def api_page? | |
| 43 | + # subpath.start_with?('/api') | |
| 44 | + # end | |
| 45 | + | |
| 46 | + # def include_default_entry? | |
| 47 | + # true | |
| 48 | + # end | |
| 49 | + end | |
| 50 | + end | |
| 51 | +end | |
| @@ -0,0 +1,31 @@ | ||
| 1 | +module Docs | |
| 2 | + class Tailwindcss < UrlScraper | |
| 3 | + self.name = 'Tailwind CSS' | |
| 4 | + self.type = 'tailwindcss' | |
| 5 | + self.slug = 'tailwindcss' | |
| 6 | + self.base_url = 'https://tailwindcss.com/docs' | |
| 7 | + self.root_path = '/installation' | |
| 8 | + self.release = '8.5' | |
| 9 | + | |
| 10 | + html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html' | |
| 11 | + | |
| 12 | + # options[:container] = 'body'; | |
| 13 | + | |
| 14 | + options[:skip_patterns] = [ | |
| 15 | + %r{\/guides\/.*}, | |
| 16 | + %r{\/colors\z} | |
| 17 | + ] | |
| 18 | + | |
| 19 | + #Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE | |
| 20 | + options[:attribution] = <<-HTML | |
| 21 | + MIT License<br> | |
| 22 | + Copyright (c) Adam Wathan <adam.wathan@gmail.com><br> | |
| 23 | + Copyright (c) Jonathan Reinink <jonathan@reinink.ca><br> | |
| 24 | + HTML | |
| 25 | + | |
| 26 | + def get_latest_version(opts) | |
| 27 | + doc = fetch_doc('https://tailwindcss.com/docs/installation', opts) | |
| 28 | + doc.at_css('select option[value=v2]').inner_text | |
| 29 | + end | |
| 30 | + end | |
| 31 | +end | |
Binary file not shown.
Binary file not shown.