cppref.rb 965 B

123456789101112131415161718192021222324252627282930313233
  1. module Docs
  2. class Cppref < UrlScraper
  3. self.abstract = true
  4. self.type = 'cppref'
  5. self.root_path = 'header'
  6. html_filters.insert_before 'clean_html', 'cppref/fix_code'
  7. html_filters.push 'cppref/clean_html', 'title'
  8. options[:decode_and_clean_paths] = true
  9. options[:container] = '#content'
  10. options[:title] = false
  11. options[:skip] = %w(language/history.html)
  12. options[:skip_patterns] = [
  13. /experimental/
  14. ]
  15. options[:attribution] = <<-HTML
  16. &copy; cppreference.com<br>
  17. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
  18. HTML
  19. # Check if the 'headers' page has changed
  20. def get_latest_version(opts)
  21. doc = fetch_doc(self.base_url + self.root_path, opts)
  22. date = doc.at_css('#footer-info-lastmod').content
  23. date = date.match(/[[:digit:]]{1,2} .* [[:digit:]]{4}/).to_s
  24. date = DateTime.strptime(date, '%e %B %Y').to_time.to_i
  25. end
  26. end
  27. end