Browse Source

Update OCaml documentation (5.2)

Simon Legner 1 year ago
parent
commit
2b8d9b6c33
3 changed files with 11 additions and 15 deletions
  1. 0 11
      docs/file-scrapers.md
  2. 2 0
      lib/docs/filters/ocaml/clean_html.rb
  3. 9 4
      lib/docs/scrapers/ocaml.rb

+ 0 - 11
docs/file-scrapers.md

@@ -157,17 +157,6 @@ curl https://numpy.org/doc/$VERSION/numpy-html.zip | \
 bsdtar --extract --file=- --directory=docs/numpy~$VERSION/
 ```
 
-## OCaml
-
-Download from https://www.ocaml.org/docs/ the HTML reference:
-https://v2.ocaml.org/releases/4.14/ocaml-4.14-refman-html.tar.gz
-and extract it as `docs/ocaml`:
-
-```sh
-curl https://v2.ocaml.org/releases/$VERSION/ocaml-$VERSION-refman-html.tar.gz | \
-tar xz --transform 's/htmlman/ocaml/' --directory docs/
-```
-
 ## OpenGL
 
 ```sh

+ 2 - 0
lib/docs/filters/ocaml/clean_html.rb

@@ -3,6 +3,8 @@ module Docs
     class CleanHtmlFilter < Filter
       def call
 
+        css('#sidebar').remove
+
         css('pre').each do |node|
           span = node.at_css('span[id]')
           node['id'] = span['id'] if span

+ 9 - 4
lib/docs/scrapers/ocaml.rb

@@ -1,5 +1,5 @@
 module Docs
-  class Ocaml < FileScraper
+  class Ocaml < UrlScraper
     self.name = 'OCaml'
     self.type = 'ocaml'
     self.root_path = 'index.html'
@@ -16,15 +16,20 @@ module Docs
 
     options[:skip_patterns] = [
       /\Acompilerlibref\//,
-      /\Alibref\/type_/,
-      /\Alibref\/Stdlib\.\w+\.html/,
+      /\Aapi\/type_/,
+      /\Aapi\/Stdlib\.\w+\.html/,
     ]
 
     options[:attribution] = <<-HTML
-      &copy; 1995-2022 INRIA.
+      &copy; 1995-2024 INRIA.
     HTML
 
     version '' do
+      self.release = '5.2'
+      self.base_url = "https://ocaml.org/manual/#{self.release}/"
+    end
+
+    version '5.0' do
       self.release = '5.0'
       self.base_url = "https://v2.ocaml.org/releases/#{self.release}/htmlman/"
     end