cpp20.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module Docs
  2. class Cpp20 < UrlScraper
  3. self.name = 'C++20'
  4. self.slug = 'cpp20'
  5. self.type = 'c'
  6. self.base_url = 'https://en.cppreference.com/w/cpp/'
  7. self.root_path = 'header'
  8. html_filters.insert_before 'clean_html', 'c/fix_code'
  9. html_filters.push 'cpp20/entries', 'c/clean_html', 'title'
  10. options[:decode_and_clean_paths] = true
  11. options[:container] = '#content'
  12. options[:title] = false
  13. options[:root_title] = 'C++ Programming Language'
  14. options[:skip] = %w(
  15. language/extending_std.html
  16. language/history.html
  17. regex/ecmascript.html
  18. regex/regex_token_iterator/operator_cmp.html
  19. )
  20. options[:skip_patterns] = [/experimental/]
  21. options[:attribution] = <<-HTML
  22. &copy; cppreference.com<br>
  23. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
  24. HTML
  25. # Same as get_latest_version in lib/docs/scrapers/c.rb
  26. def get_latest_version(opts)
  27. doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
  28. link = doc.at_css('a[title^="File:"]')
  29. date = link.content.scan(/(\d+)\./)[0][0]
  30. DateTime.strptime(date, '%Y%m%d').to_time.to_i
  31. end
  32. end
  33. end