mirror of https://github.com/freeCodeCamp/devdocs
parent
4eb4bfe5da
commit
db0746c16e
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
© INRIA 1995-2020.
|
||||
HTML
|
||||
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 606 B |
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…
Reference in new issue