Merge pull request #1236 from seirl/ocaml

Add documentation for OCaml
pull/1356/head
Simon Legner 4 years ago committed by GitHub
commit 9d1649233c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -576,6 +576,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 one or more lines are too long

@ -108,6 +108,18 @@ $GS = '/usr/local/opt/ghostscript/bin/gs'; # GhostScript
## NumPy
## OCaml
Download from https://www.ocaml.org/docs/ the HTML reference:
https://ocaml.org/releases/4.11/ocaml-4.11-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.11/ocaml-4.11-refman-html.tar.gz
tar xf ocaml-4.10-refman-html.tar.gz --transform 's/htmlman/ocaml/'
```
## OpenJDK
https://packages.debian.org/sid/openjdk-11-doc

@ -0,0 +1,35 @@
module Docs
class Ocaml
class CleanHtmlFilter < Filter
def call
css('pre, .caml-example').each do |node|
span = node.at_css('span[id]')
node['id'] = span['id'] if span
node['data-type'] = "#{span.content} [#{at_css('h1').content}]" if span
node['data-language'] = 'ocaml'
node.name = 'pre'
node.content = node.content
end
css('.caml-input').each do |node|
node.content = '# ' + node.content.strip
end
css('.maintitle *[style]').each do |node|
node.remove_attribute 'style'
end
css('h1').each do |node|
node.content = node.content
table = node.ancestors('table.center')
table.first.before(node).remove if table.present?
end
css('.navbar').remove
doc
end
end
end
end

@ -0,0 +1,59 @@
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 > span[id]').each do |span|
if 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
name += " [#{module_node.content}]" unless module_node.nil?
entries << [name, span['id'], entry_type]
end
entries
end
end
end
end

@ -0,0 +1,30 @@
module Docs
class Ocaml < FileScraper
self.name = 'OCaml'
self.type = 'ocaml'
self.root_path = 'index.html'
self.release = '4.11'
self.base_url = "https://www.ocaml.org/releases/#{self.release}/htmlman/"
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