First initial release of TailwindCSS DevDoc

pull/1711/head
Damilola Olowookere 4 years ago committed by IgnusG
parent 900cfc3554
commit 39aa5b1c90

@ -842,6 +842,11 @@ credits = [
'2004-2017 Fabien Potencier',
'MIT',
'https://symfony.com/doc/current/contributing/code/license.html'
], [
'TailwindCSS',
'Adam Wathan',
'MIT',
'https://raw.githubusercontent.com/tailwindlabs/tailwindcss/master/LICENSE'
], [
'Tcl/Tk',
'The Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties',

@ -0,0 +1,77 @@
module Docs
class Tailwindcss
class CleanHtmlFilter < Filter
def call
clean_up
# Remove code highlighting
css('pre').each do |node|
node.content = node.content
node['data-language'] = 'php'
end
doc
end
def clean_up
@doc = doc.at_css('#content-wrapper')
css('.location').remove
# Replace .header with <h1>
css('.page-header > h1').each do |node|
node.content = 'Tailwind' if root_page?
node.parent.before(node).remove
end
css('.container-fluid').each do |node|
node.name = 'table'
node.css('.row').each { |n| n.name = 'tr' }
node.css('div[class^="col"]').each { |n| n.name = 'td' }
end
css('> div').each do |node|
node.before(node.children).remove
end
# Remove <abbr>
css('a > abbr').each do |node|
node.parent['title'] = node['title']
node.before(node.children).remove
end
# Clean up headings
css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node|
node.before(node.children).remove
end
# Remove empty <td>
css('td').each do |node|
node.remove if node.content =~ /\A\s+\z/
end
# @doc = at_css('.docs_body')
# Clean up headings
css('h2 > a').each do |node|
node.before(node.children).remove
end
css('p > a[name]').each do |node|
node.parent.next_element['id'] = node['name']
end
css('blockquote').each do |node|
node['class'] = 'tip' if node.inner_html.include?('{tip}')
node.inner_html = node.inner_html.remove(/\{(tip|note)\}\s?/)
end
css('blockquote').each do |node|
if node.inner_html.include?('You\'re browsing the documentation for an old version of Laravel.')
node.remove
end
end
end
end
end
end

@ -0,0 +1,51 @@
module Docs
class Tailwindcss
class EntriesFilter < Docs::EntriesFilter
# def get_name
# if api_page?
# name = at_css('h1').content.strip.remove('Illuminate\\')
# name << " (#{type})" unless name.start_with?(self.type)
# name
# else
# at_css('h1').content
# end
# end
def get_type
# /customizing-colors rediects to /colors, hence making css
# selector below not to match the href
if result[:path] == 'customizing-colors'
selector = "#sidebar a[href='#{result[:path]}']"
else
selector = "#sidebar a[href='#{result[:path]}']"
end
check = at_css(selector).parent.parent.parent.css('h5').inner_text
check
end
# def additional_entries
# return [] if root_page? || !api_page?
# base_name = self.name.remove(/\(.+\)/).strip
# css('h3[id^="method_"]').each_with_object [] do |node, entries|
# next if node.at_css('.location').content.start_with?('in')
# name = node['id'].remove('method_')
# name.prepend "#{base_name}::"
# name << '()'
# entries << [name, node['id']]
# end
# end
# def api_page?
# subpath.start_with?('/api')
# end
# def include_default_entry?
# true
# end
end
end
end

@ -0,0 +1,31 @@
module Docs
class Tailwindcss < UrlScraper
self.name = 'Tailwind CSS'
self.type = 'tailwindcss'
self.slug = 'tailwindcss'
self.base_url = 'https://tailwindcss.com/docs'
self.root_path = '/installation'
self.release = '8.5'
html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html'
# options[:container] = 'body';
options[:skip_patterns] = [
%r{\/guides\/.*},
%r{\/colors\z}
]
#Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE
options[:attribution] = <<-HTML
MIT License<br>
Copyright (c) Adam Wathan <adam.wathan@gmail.com><br>
Copyright (c) Jonathan Reinink <jonathan@reinink.ca><br>
HTML
def get_latest_version(opts)
doc = fetch_doc('https://tailwindcss.com/docs/installation', opts)
doc.at_css('select option[value=v2]').inner_text
end
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Loading…
Cancel
Save