ocaml.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. module Docs
  2. class Ocaml < UrlScraper
  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. /\Aapi\/type_/,
  17. /\Aapi\/Stdlib\.\w+\.html/,
  18. ]
  19. options[:attribution] = <<-HTML
  20. &copy; 1995-2024 INRIA.
  21. HTML
  22. version '' do
  23. self.release = '5.3'
  24. self.base_url = "https://ocaml.org/manual/#{self.release}/"
  25. end
  26. version '5.0' do
  27. self.release = '5.0'
  28. self.base_url = "https://v2.ocaml.org/releases/#{self.release}/htmlman/"
  29. end
  30. version '4.14' do
  31. self.release = '4.14'
  32. self.base_url = "https://v2.ocaml.org/releases/#{self.release}/htmlman/"
  33. end
  34. def get_latest_version(opts)
  35. get_latest_github_release('ocaml', 'ocaml', opts)
  36. end
  37. private
  38. def parse(response) # Hook here because Nokogori removes whitespace from code fragments
  39. response.body.gsub! %r{<div\ class="pre([^"]*)"[^>]*>([\W\w]+?)</div>}, '<pre class="\1">\2</pre>'
  40. super
  41. end
  42. end
  43. end