bootstrap.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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;2023 The Bootstrap Authors<br>
  12. Code licensed under the MIT License.<br>
  13. Documentation licensed under the Creative Commons Attribution License v3.0.
  14. HTML
  15. version '5' do
  16. self.release = '5.3'
  17. self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
  18. self.root_path = 'getting-started/introduction/'
  19. html_filters.push 'bootstrap/entries_v5', 'bootstrap/clean_html_v5'
  20. options[:skip_patterns] = [
  21. /\Aabout\//
  22. ]
  23. options[:replace_paths] = {
  24. 'components/breadcrumb//' => '/components/breadcrumb/'
  25. }
  26. end
  27. version '4' do
  28. self.release = '4.5'
  29. self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
  30. self.root_path = 'getting-started/introduction/'
  31. html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
  32. options[:only_patterns] = [
  33. /\Agetting-started\//, /\Alayout\//, /\Acontent\//,
  34. /\Acomponents\//, /\Autilities\/.+/, /\Amigration\//
  35. ]
  36. end
  37. version '3' do
  38. self.release = '3.4.1'
  39. self.base_url = 'https://getbootstrap.com/docs/3.4/'
  40. self.root_path = 'getting-started/'
  41. html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'
  42. options[:only] = %w(getting-started/ css/ components/ javascript/)
  43. end
  44. def get_latest_version(opts)
  45. doc = fetch_doc('https://getbootstrap.com/docs/versions/', opts)
  46. doc.at_css('span:contains("Latest")').parent.content.split(' ').first
  47. end
  48. end
  49. end