Add documentation for OCaml

pull/1236/head
Antoine Pietri 5 years ago
parent 4eb4bfe5da
commit db0746c16e

@ -541,6 +541,11 @@ credits = [
'2005-2019 NumPy Developers',
'BSD',
'https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt'
], [
'OCaml',
'1995-2020 Inria',
'CC BY-SA',
'https://ocaml.org/docs/'
], [
'Octave',
'1996-2018 John W. Eaton',

File diff suppressed because it is too large Load Diff

@ -78,6 +78,18 @@ $GS = '/usr/local/opt/ghostscript/bin/gs'; # GhostScript
## NumPy
## OCaml
Download the HTML reference here:
https://ocaml.org/releases/4.10/ocaml-4.10-refman-html.tar.gz
and extract it as `/path/to/devdocs/docs/ocaml`:
```sh
cd /path/to/devdocs/docs
wget https://ocaml.org/releases/4.10/ocaml-4.10-refman-html.tar.gz
tar xf ocaml-4.10-refman-html.tar.gz --transform 's/htmlman/ocaml/'
```
## OpenJDK
## Perl

@ -0,0 +1,13 @@
module Docs
class Ocaml
class CleanHtmlFilter < Filter
def call
css('pre').each do |node|
node['data-language'] = 'ocaml'
end
doc
end
end
end
end

@ -0,0 +1,65 @@
module Docs
class Ocaml
class EntriesFilter < Docs::EntriesFilter
def get_name
title = context[:html_title].gsub(/\u00A0/, " ")
title = title.split.join(" ").strip
title.gsub!(/^Chapter /, "")
# Move preface at the beginning
title.gsub!(/^(Contents)/, '00.1 \1')
title.gsub!(/^(Foreword)/, '00.2 \1')
# Pad chapter numbers with zeros to sort lexicographically
title.gsub!(/(^\d[\. ])/, '0\1')
title.gsub!(/(?<ma>^\d+\.)(?<mb>\d[\. ])/, '\k<ma>0\k<mb>')
# Add dot between chapter number and title
title.gsub!(/(^[\d.]+)/, '\1. ')
title
end
def get_type
if slug.start_with?('libref')
if slug.start_with?('libref/index_')
'Indexes'
else
'Library reference'
end
else
'Documentation'
end
end
def additional_entries
entries = []
module_node = css('h1').at_css('span')
css('pre').each do |node|
next unless span = node.at_css('span')
if span['id'].nil?
next
elsif span['id'].start_with?('VAL')
entry_type = 'Values'
elsif span['id'].start_with?('MODULE')
entry_type = 'Modules'
elsif span['id'].start_with?('EXCEPTION')
entry_type = 'Exceptions'
else
next
end
name = span.content
if not module_node.nil?
name = "#{name} [#{module_node.content}]"
end
entries << [name, span['id'], entry_type]
end
entries
end
end
end
end

@ -0,0 +1,28 @@
module Docs
class Ocaml < FileScraper
self.name = 'OCaml'
self.type = 'ocaml'
self.root_path = 'index.html'
self.links = {
home: 'https://ocaml.org/',
code: 'https://github.com/ocaml/ocaml'
}
html_filters.push 'ocaml/entries', 'ocaml/clean_html'
options[:skip] = %w(
libref/index.html
)
options[:skip_patterns] = [
/\Acompilerlibref\//,
/\Alibref\/type_/,
/\Alibref\/Stdlib\.\w+\.html/,
]
options[:attribution] = <<-HTML
&copy; INRIA 1995-2020.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,2 @@
https://ocaml.org/docs/logos.html
https://github.com/ocaml/ocaml-logo/tree/master/Colour/Favicon
Loading…
Cancel
Save