bootstrap.rb 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. module Docs
  2. class Bootstrap < UrlScraper
  3. self.type = 'bootstrap'
  4. self.links = {
  5. home: 'https://getbootstrap.com/',
  6. code: 'https://github.com/twbs/bootstrap'
  7. }
  8. options[:trailing_slash] = true
  9. # https://github.com/twbs/bootstrap/blob/master/LICENSE
  10. options[:attribution] = <<-HTML
  11. &copy; 2011&ndash;2022 Twitter, Inc.<br>
  12. &copy; 2011&ndash;2022 The Bootstrap Authors<br>
  13. Code licensed under the MIT License.<br>
  14. Documentation licensed under the Creative Commons Attribution License v3.0.
  15. HTML
  16. version '5' do
  17. self.release = '5.2'
  18. self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
  19. self.root_path = 'getting-started/introduction/'
  20. html_filters.push 'bootstrap/entries_v5', 'bootstrap/clean_html_v5'
  21. options[:only_patterns] = [
  22. /\Agetting-started\//, /\Alayout\//, /\Acontent\//,
  23. /\Acomponents\//, /\Autilities\/.+/, /\Ahelpers\//
  24. ]
  25. options[:replace_paths] = {
  26. 'components/breadcrumb//' => '/components/breadcrumb/'
  27. }
  28. end
  29. version '4' do
  30. self.release = '4.5'
  31. self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
  32. self.root_path = 'getting-started/introduction/'
  33. html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
  34. options[:only_patterns] = [
  35. /\Agetting-started\//, /\Alayout\//, /\Acontent\//,
  36. /\Acomponents\//, /\Autilities\/.+/, /\Amigration\//
  37. ]
  38. end
  39. version '3' do
  40. self.release = '3.4.1'
  41. self.base_url = 'https://getbootstrap.com/docs/3.4/'
  42. self.root_path = 'getting-started/'
  43. html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'
  44. options[:only] = %w(getting-started/ css/ components/ javascript/)
  45. end
  46. def get_latest_version(opts)
  47. doc = fetch_doc('https://getbootstrap.com/docs/versions/', opts)
  48. doc.at_css('span:contains("Latest")').parent.content.split(' ').first
  49. end
  50. end
  51. end