tailwindcss.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 = '/'
  8. self.release = '2.0.3'
  9. html_filters.push 'tailwindcss/entries', 'tailwindcss/clean_html'
  10. # options[:container] = 'body';
  11. # Fix redirects from older tailwind 2 docs
  12. options[:fix_urls] = lambda do |url|
  13. if url.include? "installation/"
  14. break "/docs/installation"
  15. end
  16. if url.end_with? "/breakpoints"
  17. break "/docs/screens#{/#.*$/.match(url)}"
  18. end
  19. if url.end_with? "/adding-base-styles"
  20. break "/docs/adding-custom-styles#adding-base-styles"
  21. end
  22. if url.end_with? "/ring-opacity"
  23. break "/docs/ring-color#changing-the-opacity"
  24. end
  25. if url.match(/\/colors#?/)
  26. break "/docs/customizing-colors#{/#.*$/.match(url)}"
  27. end
  28. end
  29. options[:skip_patterns] = [
  30. # Skip setup instructions
  31. /\/browser-support$/,
  32. /\/editor-setup$/,
  33. /\/installation$/,
  34. /\/optimizing-for-production$/,
  35. /\/upgrade-guide/,
  36. /\/using-with-preprocessors/
  37. ]
  38. #Obtainable from https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE
  39. options[:attribution] = <<-HTML
  40. &copy; Adam Wathan, Jonathan Reinink
  41. Licensed under the MIT License.
  42. HTML
  43. def get_latest_version(opts)
  44. doc = fetch_doc('https://tailwindcss.com/docs/installation', opts)
  45. doc.at_css('select option[value=v2]').inner_text[1..]
  46. end
  47. end
  48. end