ocaml.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. module Docs
  2. class Ocaml < FileScraper
  3. self.name = 'OCaml'
  4. self.type = 'ocaml'
  5. self.root_path = 'index.html'
  6. self.links = {
  7. home: 'https://ocaml.org/',
  8. code: 'https://github.com/ocaml/ocaml'
  9. }
  10. html_filters.push 'ocaml/entries', 'ocaml/clean_html'
  11. options[:skip] = %w(
  12. libref/index.html
  13. )
  14. options[:skip_patterns] = [
  15. /\Acompilerlibref\//,
  16. /\Alibref\/type_/,
  17. /\Alibref\/Stdlib\.\w+\.html/,
  18. ]
  19. options[:attribution] = <<-HTML
  20. &copy; 1995-2022 INRIA.
  21. HTML
  22. version '' do
  23. self.release = '5.0'
  24. self.base_url = "https://v2.ocaml.org/releases/#{self.release}/htmlman/"
  25. end
  26. version '4.14' do
  27. self.release = '4.14'
  28. self.base_url = "https://v2.ocaml.org/releases/#{self.release}/htmlman/"
  29. end
  30. def get_latest_version(opts)
  31. get_latest_github_release('ocaml', 'ocaml', opts)
  32. end
  33. private
  34. def parse(response) # Hook here because Nokogori removes whitespace from code fragments
  35. response.body.gsub! %r{<div\ class="pre([^"]*)"[^>]*>([\W\w]+?)</div>}, '<pre class="\1">\2</pre>'
  36. super
  37. end
  38. end
  39. end